2
0
mirror of https://github.com/frappe/books.git synced 2024-11-09 23:30:56 +00:00

fix: async call to b2b gstr gen

- use map to prevent issues later
This commit is contained in:
18alantom 2021-12-28 17:04:39 +05:30 committed by Alan
parent 070b49d90f
commit 5a6d08edef
4 changed files with 22 additions and 17 deletions

View File

@ -85,10 +85,10 @@ export async function generateGstr1Json(getReportData) {
await saveExportData(jsonData, filePath);
}
async function generateB2bData(invoices) {
async function generateB2bData(rows) {
const b2b = [];
invoices.forEach(async (row) => {
for (let row of rows) {
const customer = {
ctin: row.gstin,
inv: [],
@ -134,7 +134,7 @@ async function generateB2bData(invoices) {
customer.inv.push(invRecord);
b2b.push(customer);
}
});
}
return b2b;
}

View File

@ -1,6 +1,13 @@
import { DateTime } from 'luxon';
import { generateGstr1Json } from '../../accounting/gst';
const transferTypeMap = {
B2B: 'B2B',
B2CL: 'B2C-Large',
B2CS: 'B2C-Small',
NR: 'Nil Rated, Exempted and Non GST supplies',
};
export default {
filterFields: [
{
@ -8,12 +15,8 @@ export default {
label: 'Transfer Type',
placeholder: 'Transfer Type',
fieldname: 'transferType',
options: [
'B2B',
'B2C-Large',
'B2C-Small',
'Nil Rated, Exempted and Non GST supplies',
],
options: Object.keys(transferTypeMap),
map: transferTypeMap,
default: 'B2B',
size: 'small',
},

View File

@ -14,15 +14,16 @@ class GSTR1 extends BaseGSTR {
const data = await this.getCompleteReport('GSTR-1', filters);
// prettier-ignore
const conditions = {
'B2B': row => row.gstin,
'B2C-Large': row => !row.gstin && !row.inState && row.invAmt >= 250000,
'B2C-Small': row => !row.gstin && (row.inState || (row.inState && row.invAmt < 250000)),
'Nil Rated, Exempted and Non GST supplies': row => (row.rate === 0), // this takes care of both nil rated, exempted goods
'B2CL': row => !row.gstin && !row.inState && row.invAmt >= 250000,
'B2CS': row => !row.gstin && (row.inState || (row.inState && row.invAmt < 250000)),
'NR': row => (row.rate === 0), // this takes care of both nil rated, exempted goods
};
if (!params.transferType) return data;
return data.filter(row => conditions[params.transferType](row));
return data.filter((row) => conditions[params.transferType](row));
}
}

View File

@ -13,15 +13,16 @@ class GSTR2 extends BaseGSTR {
const data = await this.getCompleteReport('GSTR-2', filters);
// prettier-ignore
const conditions = {
B2B: row => row.gstin,
'B2C-Large': row => !row.gstin && !row.inState && row.invAmt >= 250000,
'B2C-Small': row =>
'B2B': row => row.gstin,
'B2CL': row => !row.gstin && !row.inState && row.invAmt >= 250000,
'B2CS': row =>
!row.gstin && (row.inState || (row.inState && row.invAmt < 250000))
};
if (!params.transferType) return data;
return data.filter(row => conditions[params.transferType](row));
return data.filter((row) => conditions[params.transferType](row));
}
}