mirror of
https://github.com/frappe/books.git
synced 2024-11-10 07:40:55 +00:00
Added item code field for items
This commit is contained in:
parent
23d21bdfb9
commit
38713ee2d0
@ -119,7 +119,7 @@ async function getB2bData(invoices) {
|
|||||||
|
|
||||||
items.forEach((item) => {
|
items.forEach((item) => {
|
||||||
const itemRecord = {
|
const itemRecord = {
|
||||||
num: item.item_code || 1801, // TODO: will be replaced by HSN CODE (item code)
|
num: item.itemCode || 0,
|
||||||
itm_det: {
|
itm_det: {
|
||||||
txval: item.baseAmount,
|
txval: item.baseAmount,
|
||||||
rt: GST[item.tax],
|
rt: GST[item.tax],
|
||||||
|
@ -112,10 +112,17 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
fieldname: 'itemCode',
|
||||||
|
label: 'Item Code',
|
||||||
|
fieldtype: 'Data',
|
||||||
|
placeholder: 'Item Code',
|
||||||
|
},
|
||||||
],
|
],
|
||||||
quickEditFields: [
|
quickEditFields: [
|
||||||
'rate',
|
'rate',
|
||||||
'unit',
|
'unit',
|
||||||
|
'itemCode',
|
||||||
'itemType',
|
'itemType',
|
||||||
'tax',
|
'tax',
|
||||||
'description',
|
'description',
|
||||||
|
@ -12,27 +12,27 @@ export default {
|
|||||||
target: 'Item',
|
target: 'Item',
|
||||||
required: 1,
|
required: 1,
|
||||||
getFilters(_, doc) {
|
getFilters(_, doc) {
|
||||||
let items = doc.parentdoc.items.map(d => d.item).filter(Boolean);
|
let items = doc.parentdoc.items.map((d) => d.item).filter(Boolean);
|
||||||
if (items.length > 0) {
|
if (items.length > 0) {
|
||||||
return {
|
return {
|
||||||
name: ['not in', items]
|
name: ['not in', items],
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
fieldname: 'description',
|
fieldname: 'description',
|
||||||
label: 'Description',
|
label: 'Description',
|
||||||
fieldtype: 'Text',
|
fieldtype: 'Text',
|
||||||
formula: (row, doc) => doc.getFrom('Item', row.item, 'description'),
|
formula: (row, doc) => doc.getFrom('Item', row.item, 'description'),
|
||||||
hidden: 1
|
hidden: 1,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
fieldname: 'quantity',
|
fieldname: 'quantity',
|
||||||
label: 'Quantity',
|
label: 'Quantity',
|
||||||
fieldtype: 'Float',
|
fieldtype: 'Float',
|
||||||
required: 1,
|
required: 1,
|
||||||
formula: () => 1
|
formula: () => 1,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
fieldname: 'rate',
|
fieldname: 'rate',
|
||||||
@ -44,14 +44,14 @@ export default {
|
|||||||
const exchangeRate = doc.exchangeRate ?? 1;
|
const exchangeRate = doc.exchangeRate ?? 1;
|
||||||
return baseRate / exchangeRate;
|
return baseRate / exchangeRate;
|
||||||
},
|
},
|
||||||
getCurrency: (row, doc) => doc.currency
|
getCurrency: (row, doc) => doc.currency,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
fieldname: 'baseRate',
|
fieldname: 'baseRate',
|
||||||
label: 'Rate (Company Currency)',
|
label: 'Rate (Company Currency)',
|
||||||
fieldtype: 'Currency',
|
fieldtype: 'Currency',
|
||||||
formula: (row, doc) => row.rate * doc.exchangeRate,
|
formula: (row, doc) => row.rate * doc.exchangeRate,
|
||||||
readOnly: 1
|
readOnly: 1,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
fieldname: 'account',
|
fieldname: 'account',
|
||||||
@ -59,7 +59,7 @@ export default {
|
|||||||
fieldtype: 'Link',
|
fieldtype: 'Link',
|
||||||
target: 'Account',
|
target: 'Account',
|
||||||
required: 1,
|
required: 1,
|
||||||
formula: (row, doc) => doc.getFrom('Item', row.item, 'expenseAccount')
|
formula: (row, doc) => doc.getFrom('Item', row.item, 'expenseAccount'),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
fieldname: 'tax',
|
fieldname: 'tax',
|
||||||
@ -69,22 +69,29 @@ export default {
|
|||||||
formula: (row, doc) => {
|
formula: (row, doc) => {
|
||||||
if (row.tax) return row.tax;
|
if (row.tax) return row.tax;
|
||||||
return doc.getFrom('Item', row.item, 'tax');
|
return doc.getFrom('Item', row.item, 'tax');
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
fieldname: 'amount',
|
fieldname: 'amount',
|
||||||
label: 'Amount',
|
label: 'Amount',
|
||||||
fieldtype: 'Currency',
|
fieldtype: 'Currency',
|
||||||
readOnly: 1,
|
readOnly: 1,
|
||||||
formula: row => row.quantity * row.rate,
|
formula: (row) => row.quantity * row.rate,
|
||||||
getCurrency: (row, doc) => doc.currency
|
getCurrency: (row, doc) => doc.currency,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
fieldname: 'baseAmount',
|
fieldname: 'baseAmount',
|
||||||
label: 'Amount (Company Currency)',
|
label: 'Amount (Company Currency)',
|
||||||
fieldtype: 'Currency',
|
fieldtype: 'Currency',
|
||||||
readOnly: 1,
|
readOnly: 1,
|
||||||
formula: (row, doc) => row.amount * doc.exchangeRate
|
formula: (row, doc) => row.amount * doc.exchangeRate,
|
||||||
}
|
},
|
||||||
]
|
{
|
||||||
|
fieldname: 'itemCode',
|
||||||
|
label: 'Item Code',
|
||||||
|
fieldtype: 'Data',
|
||||||
|
formula: (row, doc) => doc.getFrom('Item', row.item, 'itemCode'),
|
||||||
|
formulaDependsOn: ['item'],
|
||||||
|
},
|
||||||
|
],
|
||||||
};
|
};
|
||||||
|
@ -12,13 +12,13 @@ export default {
|
|||||||
target: 'Item',
|
target: 'Item',
|
||||||
required: 1,
|
required: 1,
|
||||||
getFilters(_, doc) {
|
getFilters(_, doc) {
|
||||||
let items = doc.parentdoc.items.map(d => d.item).filter(Boolean);
|
let items = doc.parentdoc.items.map((d) => d.item).filter(Boolean);
|
||||||
if (items.length > 0) {
|
if (items.length > 0) {
|
||||||
return {
|
return {
|
||||||
name: ['not in', items]
|
name: ['not in', items],
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
fieldname: 'description',
|
fieldname: 'description',
|
||||||
@ -26,14 +26,14 @@ export default {
|
|||||||
fieldtype: 'Text',
|
fieldtype: 'Text',
|
||||||
formula: (row, doc) => doc.getFrom('Item', row.item, 'description'),
|
formula: (row, doc) => doc.getFrom('Item', row.item, 'description'),
|
||||||
hidden: 1,
|
hidden: 1,
|
||||||
formulaDependsOn: ['item']
|
formulaDependsOn: ['item'],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
fieldname: 'quantity',
|
fieldname: 'quantity',
|
||||||
label: 'Quantity',
|
label: 'Quantity',
|
||||||
fieldtype: 'Float',
|
fieldtype: 'Float',
|
||||||
required: 1,
|
required: 1,
|
||||||
formula: row => row.quantity || 1
|
formula: (row) => row.quantity || 1,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
fieldname: 'rate',
|
fieldname: 'rate',
|
||||||
@ -46,14 +46,14 @@ export default {
|
|||||||
return baseRate / exchangeRate;
|
return baseRate / exchangeRate;
|
||||||
},
|
},
|
||||||
getCurrency: (row, doc) => doc.currency,
|
getCurrency: (row, doc) => doc.currency,
|
||||||
formulaDependsOn: ['item']
|
formulaDependsOn: ['item'],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
fieldname: 'baseRate',
|
fieldname: 'baseRate',
|
||||||
label: 'Rate (Company Currency)',
|
label: 'Rate (Company Currency)',
|
||||||
fieldtype: 'Currency',
|
fieldtype: 'Currency',
|
||||||
formula: (row, doc) => row.rate * doc.exchangeRate,
|
formula: (row, doc) => row.rate * doc.exchangeRate,
|
||||||
readOnly: 1
|
readOnly: 1,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
fieldname: 'account',
|
fieldname: 'account',
|
||||||
@ -62,7 +62,7 @@ export default {
|
|||||||
fieldtype: 'Link',
|
fieldtype: 'Link',
|
||||||
target: 'Account',
|
target: 'Account',
|
||||||
required: 1,
|
required: 1,
|
||||||
formula: (row, doc) => doc.getFrom('Item', row.item, 'incomeAccount')
|
formula: (row, doc) => doc.getFrom('Item', row.item, 'incomeAccount'),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
fieldname: 'tax',
|
fieldname: 'tax',
|
||||||
@ -70,22 +70,29 @@ export default {
|
|||||||
fieldtype: 'Link',
|
fieldtype: 'Link',
|
||||||
target: 'Tax',
|
target: 'Tax',
|
||||||
formula: (row, doc) => doc.getFrom('Item', row.item, 'tax'),
|
formula: (row, doc) => doc.getFrom('Item', row.item, 'tax'),
|
||||||
formulaDependsOn: ['item']
|
formulaDependsOn: ['item'],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
fieldname: 'amount',
|
fieldname: 'amount',
|
||||||
label: 'Amount',
|
label: 'Amount',
|
||||||
fieldtype: 'Currency',
|
fieldtype: 'Currency',
|
||||||
readOnly: 1,
|
readOnly: 1,
|
||||||
formula: row => row.quantity * row.rate,
|
formula: (row) => row.quantity * row.rate,
|
||||||
getCurrency: (row, doc) => doc.currency
|
getCurrency: (row, doc) => doc.currency,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
fieldname: 'baseAmount',
|
fieldname: 'baseAmount',
|
||||||
label: 'Amount (Company Currency)',
|
label: 'Amount (Company Currency)',
|
||||||
fieldtype: 'Currency',
|
fieldtype: 'Currency',
|
||||||
readOnly: 1,
|
readOnly: 1,
|
||||||
formula: (row, doc) => row.amount * doc.exchangeRate
|
formula: (row, doc) => row.amount * doc.exchangeRate,
|
||||||
}
|
},
|
||||||
]
|
{
|
||||||
|
fieldname: 'itemCode',
|
||||||
|
label: 'Item Code',
|
||||||
|
fieldtype: 'Data',
|
||||||
|
formula: (row, doc) => doc.getFrom('Item', row.item, 'itemCode'),
|
||||||
|
formulaDependsOn: ['item'],
|
||||||
|
},
|
||||||
|
],
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user