2
0
mirror of https://github.com/frappe/books.git synced 2025-01-05 16:12:21 +00:00

make place of supply and gst into seperate entries

This commit is contained in:
Ankit Singhaniya 2021-12-29 09:54:57 +05:30
parent 99dfc93129
commit 21dace3e03
4 changed files with 16 additions and 31 deletions

View File

@ -182,7 +182,6 @@ async function generateB2clData(invoices) {
const b2cl = []; const b2cl = [];
for (let invoice of invoices) { for (let invoice of invoices) {
const stateInvoiceRecord = { const stateInvoiceRecord = {
pos: stateCodeMap[invoice.place.toUpperCase()], pos: stateCodeMap[invoice.place.toUpperCase()],
inv: [] inv: []

View File

@ -7,6 +7,7 @@ export default {
'addressLine1', 'addressLine1',
'addressLine2', 'addressLine2',
'city', 'city',
'state',
'country', 'country',
'postalCode' 'postalCode'
], ],
@ -31,6 +32,12 @@ export default {
fieldtype: 'Data', fieldtype: 'Data',
required: 1 required: 1
}, },
{
fieldname: 'state',
label: 'State',
placeholder: 'State',
fieldtype: 'Data',
},
{ {
fieldname: 'country', fieldname: 'country',
label: 'Country', label: 'Country',
@ -84,6 +91,7 @@ export default {
'addressLine1', 'addressLine1',
'addressLine2', 'addressLine2',
'city', 'city',
'state',
'country', 'country',
'postalCode' 'postalCode'
], ],

View File

@ -8,44 +8,22 @@ export default function getAugmentedAddress({ country }) {
return Address; return Address;
} }
const cityFieldIndex = Address.fields.findIndex(
(i) => i.fieldname === 'city'
);
if (country === 'India') { if (country === 'India') {
Address.fields = [ Address.fields = [
...Address.fields.slice(0, cityFieldIndex + 1), ...Address.fields,
{ {
fieldname: 'state', fieldname: 'pos',
label: 'State / UT', label: 'Place of Supply',
fieldtype: 'Select', fieldtype: 'Select',
placeholder: 'State / UT', placeholder: 'Place of Supply',
options: Object.keys(stateCodeMap).map((key) => capitalize(key)), options: Object.keys(stateCodeMap).map((key) => capitalize(key)),
}, },
...Address.fields.slice(cityFieldIndex + 1, Address.fields.length),
];
// Setting country as India for customers as default for SMBs in India
Address.fields.forEach((field) => {
if (field.fieldname === 'country') {
field.default = 'India';
}
});
} else {
Address.fields = [
...Address.fields.slice(0, cityFieldIndex + 1),
{
fieldname: 'state',
label: 'State',
placeholder: 'State',
fieldtype: 'Data',
},
...Address.fields.slice(cityFieldIndex + 1, Address.fields.length),
]; ];
} }
Address.quickEditFields = [ Address.quickEditFields = [
...Address.quickEditFields.slice(0, cityFieldIndex + 1), ...Address.quickEditFields,
'state', 'pos',
...Address.quickEditFields.slice(cityFieldIndex + 1, Address.fields.length),
]; ];
return Address; return Address;

View File

@ -41,14 +41,14 @@ class BaseGSTR {
); );
if (party.address) { if (party.address) {
let addressDetails = await frappe.getDoc('Address', party.address); let addressDetails = await frappe.getDoc('Address', party.address);
row.place = addressDetails.state || ''; row.place = addressDetails.pos || '';
} }
row.gstin = party.gstin; row.gstin = party.gstin;
row.partyName = ledgerEntry.customer || ledgerEntry.supplier; row.partyName = ledgerEntry.customer || ledgerEntry.supplier;
row.invNo = ledgerEntry.name; row.invNo = ledgerEntry.name;
row.invDate = ledgerEntry.date; row.invDate = ledgerEntry.date;
row.rate = 0; row.rate = 0;
row.inState = gstin.substring(0, 2) === stateCodeMap[row.place]; row.inState = gstin && gstin.substring(0, 2) === stateCodeMap[row.place];
row.reverseCharge = !party.gstin ? 'Y' : 'N'; row.reverseCharge = !party.gstin ? 'Y' : 'N';
ledgerEntry.taxes?.forEach(tax => { ledgerEntry.taxes?.forEach(tax => {
row.rate += tax.rate; row.rate += tax.rate;