mirror of
https://github.com/frappe/books.git
synced 2026-08-24 10:04:45 -05:00
feat: add HSN code and tax fields to item group
This commit is contained in:
@@ -71,6 +71,9 @@ export class AccountingSettings extends Doc {
|
||||
enablePointOfSaleWithOutInventory: () => {
|
||||
return !!this.enablePointOfSaleWithOutInventory;
|
||||
},
|
||||
enableitemGroup: () => {
|
||||
return !!this.enableitemGroup;
|
||||
},
|
||||
};
|
||||
|
||||
override hidden: HiddenMap = {
|
||||
|
||||
@@ -299,11 +299,29 @@ export abstract class InvoiceItem extends Doc {
|
||||
},
|
||||
tax: {
|
||||
formula: async () => {
|
||||
return (await this.fyo.getValue(
|
||||
const itemTax = (await this.fyo.getValue(
|
||||
'Item',
|
||||
this.item as string,
|
||||
'tax'
|
||||
)) as string;
|
||||
|
||||
if (itemTax) {
|
||||
return itemTax;
|
||||
}
|
||||
|
||||
const itemGroup = (await this.fyo.getValue(
|
||||
'Item',
|
||||
this.item as string,
|
||||
'itemGroup'
|
||||
)) as string;
|
||||
|
||||
if (!itemGroup) {
|
||||
return '';
|
||||
}
|
||||
|
||||
const itemGroupDoc = await this.fyo.doc.getDoc('ItemGroup', itemGroup);
|
||||
|
||||
return itemGroupDoc?.tax as string;
|
||||
},
|
||||
dependsOn: ['item'],
|
||||
},
|
||||
|
||||
@@ -26,6 +26,7 @@ export class Item extends Doc {
|
||||
itemType?: 'Product' | 'Service';
|
||||
for?: 'Purchases' | 'Sales' | 'Both';
|
||||
hasBatch?: boolean;
|
||||
itemGroup?: string;
|
||||
hasSerialNumber?: boolean;
|
||||
uomConversions: UOMConversionItem[] = [];
|
||||
|
||||
@@ -63,6 +64,20 @@ export class Item extends Doc {
|
||||
},
|
||||
dependsOn: ['itemType', 'trackItem'],
|
||||
},
|
||||
hsnCode: {
|
||||
formula: async () => {
|
||||
if (!this.itemGroup) {
|
||||
return '';
|
||||
}
|
||||
|
||||
const itemGroupDoc = await this.fyo.doc.getDoc(
|
||||
'ItemGroup',
|
||||
this.itemGroup
|
||||
);
|
||||
return itemGroupDoc?.hsnCode as string;
|
||||
},
|
||||
dependsOn: ['itemGroup'],
|
||||
},
|
||||
};
|
||||
|
||||
async beforeSync(): Promise<void> {
|
||||
@@ -156,6 +171,7 @@ export class Item extends Doc {
|
||||
),
|
||||
uomConversions: () =>
|
||||
!this.fyo.singles.InventorySettings?.enableUomConversions,
|
||||
itemGroup: () => !this.fyo.singles.AccountingSettings?.enableitemGroup,
|
||||
};
|
||||
|
||||
readOnly: ReadOnlyMap = {
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
import { Doc } from 'fyo/model/doc';
|
||||
import { ListViewSettings } from 'fyo/model/types';
|
||||
|
||||
export class ItemGroup extends Doc {
|
||||
static getListViewSettings(): ListViewSettings {
|
||||
return {
|
||||
columns: ['name', 'tax', 'hsnCode'],
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -31,6 +31,7 @@ import { SalesInvoiceItem } from './baseModels/SalesInvoiceItem/SalesInvoiceItem
|
||||
import { SalesQuote } from './baseModels/SalesQuote/SalesQuote';
|
||||
import { SalesQuoteItem } from './baseModels/SalesQuoteItem/SalesQuoteItem';
|
||||
import { SetupWizard } from './baseModels/SetupWizard/SetupWizard';
|
||||
import { ItemGroup } from './baseModels/ItemGroup/ItemGroup';
|
||||
import { Tax } from './baseModels/Tax/Tax';
|
||||
import { TaxSummary } from './baseModels/TaxSummary/TaxSummary';
|
||||
import { Batch } from './inventory/Batch';
|
||||
@@ -64,6 +65,7 @@ export const models = {
|
||||
Batch,
|
||||
Defaults,
|
||||
Item,
|
||||
ItemGroup,
|
||||
JournalEntry,
|
||||
JournalEntryAccount,
|
||||
Misc,
|
||||
|
||||
@@ -78,6 +78,7 @@ import ERPNextSyncSettings from './app/ERPNextSyncSettings.json';
|
||||
import ERPNextSyncQueue from './app/ERPNextSyncQueue.json';
|
||||
import FetchFromERPNextQueue from './app/FetchFromERPNextQueue.json';
|
||||
import IntegrationErrorLog from './app/IntegrationErrorLog.json';
|
||||
import ItemGroup from './app/ItemGroup.json';
|
||||
import { Schema, SchemaStub } from './types';
|
||||
|
||||
export const coreSchemas: Schema[] = [
|
||||
@@ -113,6 +114,7 @@ export const appSchemas: Schema[] | SchemaStub[] = [
|
||||
Party as Schema,
|
||||
Lead as Schema,
|
||||
Address as Schema,
|
||||
ItemGroup as Schema,
|
||||
Item as Schema,
|
||||
UOM as Schema,
|
||||
UOMConversionItem as Schema,
|
||||
|
||||
@@ -6,6 +6,8 @@ export type ItemQtyMap = {
|
||||
|
||||
export type ItemSerialNumbers = { [item: string]: string };
|
||||
|
||||
export type ItemGroupMap = Record<string, string>;
|
||||
|
||||
export type DiscountType = 'percent' | 'amount';
|
||||
|
||||
export const modalNames = [
|
||||
@@ -26,6 +28,7 @@ export type PosEmits =
|
||||
| 'addItem'
|
||||
| 'toggleView'
|
||||
| 'toggleModal'
|
||||
| 'setItemGroup'
|
||||
| 'setPaidAmount'
|
||||
| 'setPaymentMethod'
|
||||
| 'setCouponsCount'
|
||||
@@ -50,4 +53,5 @@ export interface POSItem {
|
||||
unit: string;
|
||||
hasBatch: boolean;
|
||||
hasSerialNumber: boolean;
|
||||
itemGroup?: string;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user