2
0
mirror of https://github.com/frappe/books.git synced 2024-12-24 11:55:46 +00:00
books/reports/GoodsAndServiceTax/GSTR2.js
18alantom 5a6d08edef fix: async call to b2b gstr gen
- use map to prevent issues later
2021-12-28 17:22:34 +05:30

30 lines
837 B
JavaScript

import BaseGSTR from './BaseGSTR';
class GSTR2 extends BaseGSTR {
async run(params) {
if (!Object.keys(params).length) return [];
let filters = {};
if (params.toDate || params.fromDate) {
filters.date = [];
if (params.toDate) filters.date.push('<=', params.toDate);
if (params.fromDate) filters.date.push('>=', params.fromDate);
}
const data = await this.getCompleteReport('GSTR-2', filters);
// prettier-ignore
const conditions = {
'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));
}
}
export default GSTR2;