2
0
mirror of https://github.com/frappe/books.git synced 2024-11-10 07:40:55 +00:00

make hsn and sac code a regional thing

This commit is contained in:
Ankit Singhaniya 2021-12-16 11:47:25 +05:30 committed by Alan
parent 679904ac6a
commit 90c9bd61ab
10 changed files with 154 additions and 17 deletions

View File

@ -122,7 +122,7 @@ async function generateB2bData(invoices) {
items.forEach((item) => {
const itemRecord = {
num: item.itemCode || 0,
num: item.hsnCode || 0,
itm_det: {
txval: item.baseAmount,
rt: GST[item.tax],

View File

@ -0,0 +1,24 @@
import { cloneDeep } from 'lodash';
import FulfillmentItemOriginal from './FulfillmentItem';
export default function getAugmentedFulfillmentItem({ country }) {
const FulfillmentItem = cloneDeep(FulfillmentItemOriginal);
if (!country) {
return FulfillmentItem;
}
if (country === 'India') {
FulfillmentItem.fields = [
...FulfillmentItem.fields,
{
fieldname: 'hsnCode',
label: 'HSN/SAC',
fieldtype: 'Int',
formula: (row, doc) => doc.getFrom('Item', row.item, 'hsnCode'),
formulaDependsOn: ['item'],
},
];
}
return FulfillmentItem;
}

View File

@ -5,6 +5,7 @@ export default {
name: 'Item',
doctype: 'DocType',
isSingle: 0,
regional: 1,
keywordFields: ['name', 'description'],
fields: [
{
@ -112,17 +113,10 @@ export default {
}
},
},
{
fieldname: 'itemCode',
label: 'Item Code',
fieldtype: 'Int',
placeholder: 'Item Code',
},
],
quickEditFields: [
'rate',
'unit',
'itemCode',
'itemType',
'tax',
'description',

View File

@ -0,0 +1,29 @@
import { cloneDeep } from 'lodash';
import ItemOriginal from './Item';
export default function getAugmentedItem({ country }) {
const Item = cloneDeep(ItemOriginal);
if (!country) {
return Item;
}
if (country === 'India') {
const nameFieldIndex = Item.fields.findIndex(i => i.fieldname === 'name');
Item.fields = [
...Item.fields.slice(0, nameFieldIndex+1),
{
fieldname: 'hsnCode',
label: 'HSN/SAC',
fieldtype: 'Int',
placeholder: 'HSN/SAC Code',
required: 1
},
...Item.fields.slice(nameFieldIndex+1, Item.fields.length),
];
Item.quickEditFields.unshift('hsnCode');
}
return Item;
}

View File

@ -86,12 +86,5 @@ export default {
readOnly: 1,
formula: (row, doc) => row.amount * doc.exchangeRate,
},
{
fieldname: 'itemCode',
label: 'Item Code',
fieldtype: 'Int',
formula: (row, doc) => doc.getFrom('Item', row.item, 'itemCode'),
formulaDependsOn: ['item'],
},
],
};

View File

@ -0,0 +1,24 @@
import { cloneDeep } from 'lodash';
import PurchaseInvoiceItemOriginal from './PurchaseInvoiceItem';
export default function getAugmentedPurchaseInvoiceItem({ country }) {
const PurchaseInvoiceItem = cloneDeep(PurchaseInvoiceItemOriginal);
if (!country) {
return PurchaseInvoiceItem;
}
if (country === 'India') {
PurchaseInvoiceItem.fields = [
...PurchaseInvoiceItem.fields,
{
fieldname: 'hsnCode',
label: 'HSN/SAC',
fieldtype: 'Int',
formula: (row, doc) => doc.getFrom('Item', row.item, 'hsnCode'),
formulaDependsOn: ['item'],
},
];
}
return PurchaseInvoiceItem;
}

View File

@ -0,0 +1,24 @@
import { cloneDeep } from 'lodash';
import QuotationItemOriginal from './QuotationItem';
export default function getAugmentedQuotationItem({ country }) {
const QuotationItem = cloneDeep(QuotationItemOriginal);
if (!country) {
return QuotationItem;
}
if (country === 'India') {
QuotationItem.fields = [
...QuotationItem.fields,
{
fieldname: 'hsnCode',
label: 'HSN/SAC',
fieldtype: 'Int',
formula: (row, doc) => doc.getFrom('Item', row.item, 'hsnCode'),
formulaDependsOn: ['item'],
},
];
}
return QuotationItem;
}

View File

@ -0,0 +1,24 @@
import { cloneDeep } from 'lodash';
import SalesInvoiceItemOriginal from './SalesInvoiceItem';
export default function getAugmentedSalesInvoiceItem({ country }) {
const SalesInvoiceItem = cloneDeep(SalesInvoiceItemOriginal);
if (!country) {
return SalesInvoiceItem;
}
if (country === 'India') {
SalesInvoiceItem.fields = [
...SalesInvoiceItem.fields,
{
fieldname: 'hsnCode',
label: 'HSN/SAC',
fieldtype: 'Int',
formula: (row, doc) => doc.getFrom('Item', row.item, 'hsnCode'),
formulaDependsOn: ['item'],
},
];
}
return SalesInvoiceItem;
}

View File

@ -2,6 +2,7 @@ export default {
name: 'SalesInvoiceItem',
doctype: 'DocType',
isChild: 1,
regional: 1,
keywordFields: [],
tableFields: ['item', 'tax', 'quantity', 'rate', 'amount'],
fields: [
@ -88,10 +89,10 @@ export default {
formula: (row, doc) => row.amount * doc.exchangeRate,
},
{
fieldname: 'itemCode',
fieldname: 'hsnCode',
label: 'Item Code',
fieldtype: 'Int',
formula: (row, doc) => doc.getFrom('Item', row.item, 'itemCode'),
formula: (row, doc) => doc.getFrom('Item', row.item, 'hsnCode'),
formulaDependsOn: ['item'],
},
],

View File

@ -0,0 +1,24 @@
import { cloneDeep } from 'lodash';
import SalesOrderItemOriginal from './SalesOrderItem';
export default function getAugmentedSalesOrderItem({ country }) {
const SalesOrderItem = cloneDeep(SalesOrderItemOriginal);
if (!country) {
return SalesOrderItem;
}
if (country === 'India') {
SalesOrderItem.fields = [
...SalesOrderItem.fields,
{
fieldname: 'hsnCode',
label: 'HSN/SAC',
fieldtype: 'Int',
formula: (row, doc) => doc.getFrom('Item', row.item, 'hsnCode'),
formulaDependsOn: ['item'],
},
];
}
return SalesOrderItem;
}