mirror of
https://github.com/frappe/books.git
synced 2025-02-02 12:08:27 +00:00
Added ability to export B2B GSTR-2 CSV data
This commit is contained in:
parent
1798902835
commit
e3e2b43da0
@ -2,7 +2,7 @@ import { showMessageDialog } from '@/utils';
|
|||||||
import frappe from 'frappejs';
|
import frappe from 'frappejs';
|
||||||
import { _ } from 'frappejs/utils';
|
import { _ } from 'frappejs/utils';
|
||||||
import { DateTime } from 'luxon';
|
import { DateTime } from 'luxon';
|
||||||
import { saveExportData } from '../reports/commonExporter';
|
import { saveExportData, exportCsv } from '../reports/commonExporter';
|
||||||
import { getSavePath } from '../src/utils';
|
import { getSavePath } from '../src/utils';
|
||||||
|
|
||||||
// prettier-ignore
|
// prettier-ignore
|
||||||
@ -265,9 +265,72 @@ export async function generateGstr2Csv(getReportData) {
|
|||||||
|
|
||||||
const {
|
const {
|
||||||
rows,
|
rows,
|
||||||
|
columns,
|
||||||
filters: { transferType, toDate },
|
filters: { transferType, toDate },
|
||||||
} = getReportData();
|
} = getReportData();
|
||||||
|
|
||||||
const { filePath, canceled } = await getSavePath('gstr-2', 'csv');
|
const { filePath, canceled } = await getSavePath('gstr-2', 'csv');
|
||||||
if (canceled || !filePath) return;
|
if (canceled || !filePath) return;
|
||||||
|
|
||||||
|
let gstData;
|
||||||
|
if (transferType === 'B2B') {
|
||||||
|
gstData = await generateB2bCsvGstr2(rows, columns);
|
||||||
|
}
|
||||||
|
|
||||||
|
await exportCsv(gstData.rows, gstData.columns, filePath);
|
||||||
|
}
|
||||||
|
|
||||||
|
async function generateB2bCsvGstr2(rows, columns) {
|
||||||
|
|
||||||
|
const csvColumns = [
|
||||||
|
{
|
||||||
|
label: 'GSTIN of Supplier',
|
||||||
|
fieldname: 'gstin',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Invoice Number',
|
||||||
|
fieldname: 'invNo',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Invoice Date',
|
||||||
|
fieldname: 'invDate',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Invoice Value',
|
||||||
|
fieldname: 'invAmt',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Place of supply',
|
||||||
|
fieldname: 'place',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Reverse Charge',
|
||||||
|
fieldname: 'reverseCharge',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Rate',
|
||||||
|
fieldname: 'rate',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Taxable Value',
|
||||||
|
fieldname: 'taxVal',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Intergrated Tax Paid',
|
||||||
|
fieldname: 'igstAmt',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Central Tax Paid',
|
||||||
|
fieldname: 'cgstAmt',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'State/UT Tax Paid',
|
||||||
|
fieldname: 'sgstAmt',
|
||||||
|
},
|
||||||
|
]
|
||||||
|
|
||||||
|
return {
|
||||||
|
columns: csvColumns,
|
||||||
|
rows: rows,
|
||||||
|
}
|
||||||
}
|
}
|
@ -2,26 +2,10 @@ import { DateTime } from 'luxon';
|
|||||||
import { stateCodeMap } from '../../accounting/gst';
|
import { stateCodeMap } from '../../accounting/gst';
|
||||||
import { titleCase } from '../../src/utils';
|
import { titleCase } from '../../src/utils';
|
||||||
|
|
||||||
const transferTypeMap = {
|
|
||||||
B2B: 'B2B',
|
|
||||||
B2CL: 'B2C-Large',
|
|
||||||
B2CS: 'B2C-Small',
|
|
||||||
NR: 'Nil Rated, Exempted and Non GST supplies',
|
|
||||||
};
|
|
||||||
const stateList = Object.keys(stateCodeMap).map(titleCase).sort();
|
const stateList = Object.keys(stateCodeMap).map(titleCase).sort();
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
filterFields: [
|
filterFields: [
|
||||||
{
|
|
||||||
fieldtype: 'Select',
|
|
||||||
label: 'Transfer Type',
|
|
||||||
placeholder: 'Transfer Type',
|
|
||||||
fieldname: 'transferType',
|
|
||||||
options: Object.keys(transferTypeMap),
|
|
||||||
map: transferTypeMap,
|
|
||||||
default: 'B2B',
|
|
||||||
size: 'small',
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
fieldtype: 'AutoComplete',
|
fieldtype: 'AutoComplete',
|
||||||
label: 'Place',
|
label: 'Place',
|
||||||
|
@ -2,6 +2,24 @@ const title = 'GSTR 1';
|
|||||||
import baseConfig from './BaseViewConfig';
|
import baseConfig from './BaseViewConfig';
|
||||||
import { generateGstr1Json } from '../../accounting/gst';
|
import { generateGstr1Json } from '../../accounting/gst';
|
||||||
|
|
||||||
|
const transferTypeMap = {
|
||||||
|
B2B: 'B2B',
|
||||||
|
B2CL: 'B2C-Large',
|
||||||
|
B2CS: 'B2C-Small',
|
||||||
|
NR: 'Nil Rated, Exempted and Non GST supplies',
|
||||||
|
};
|
||||||
|
|
||||||
|
const transferType = {
|
||||||
|
fieldtype: 'Select',
|
||||||
|
label: 'Transfer Type',
|
||||||
|
placeholder: 'Transfer Type',
|
||||||
|
fieldname: 'transferType',
|
||||||
|
options: Object.keys(transferTypeMap),
|
||||||
|
map: transferTypeMap,
|
||||||
|
default: 'B2B',
|
||||||
|
size: 'small',
|
||||||
|
};
|
||||||
|
|
||||||
const actions = [
|
const actions = [
|
||||||
{
|
{
|
||||||
group: 'Export',
|
group: 'Export',
|
||||||
@ -16,7 +34,7 @@ const actions = [
|
|||||||
export default {
|
export default {
|
||||||
title: title,
|
title: title,
|
||||||
method: 'gstr-1',
|
method: 'gstr-1',
|
||||||
filterFields: baseConfig.filterFields,
|
filterFields: [ transferType, ...baseConfig.filterFields],
|
||||||
actions: actions,
|
actions: actions,
|
||||||
getColumns: baseConfig.getColumns,
|
getColumns: baseConfig.getColumns,
|
||||||
};
|
};
|
||||||
|
@ -16,9 +16,6 @@ class GSTR2 extends BaseGSTR {
|
|||||||
// prettier-ignore
|
// prettier-ignore
|
||||||
const conditions = {
|
const conditions = {
|
||||||
'B2B': row => row.gstin,
|
'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;
|
if (!params.transferType) return data;
|
||||||
|
@ -2,6 +2,21 @@ const title = 'GSTR 2';
|
|||||||
import baseConfig from './BaseViewConfig';
|
import baseConfig from './BaseViewConfig';
|
||||||
import { generateGstr2Csv } from '../../accounting/gst';
|
import { generateGstr2Csv } from '../../accounting/gst';
|
||||||
|
|
||||||
|
const transferTypeMap = {
|
||||||
|
B2B: 'B2B',
|
||||||
|
};
|
||||||
|
|
||||||
|
const transferType = {
|
||||||
|
fieldtype: 'Select',
|
||||||
|
label: 'Transfer Type',
|
||||||
|
placeholder: 'Transfer Type',
|
||||||
|
fieldname: 'transferType',
|
||||||
|
options: Object.keys(transferTypeMap),
|
||||||
|
map: transferTypeMap,
|
||||||
|
default: 'B2B',
|
||||||
|
size: 'small',
|
||||||
|
};
|
||||||
|
|
||||||
const actions = [
|
const actions = [
|
||||||
{
|
{
|
||||||
group: 'Export',
|
group: 'Export',
|
||||||
@ -16,7 +31,7 @@ const actions = [
|
|||||||
export default {
|
export default {
|
||||||
title: title,
|
title: title,
|
||||||
method: 'gstr-2',
|
method: 'gstr-2',
|
||||||
filterFields: baseConfig.filterFields,
|
filterFields: [ transferType, ...baseConfig.filterFields],
|
||||||
actions: actions,
|
actions: actions,
|
||||||
getColumns: baseConfig.getColumns,
|
getColumns: baseConfig.getColumns,
|
||||||
};
|
};
|
||||||
|
@ -34,7 +34,7 @@ function csvFormat(value) {
|
|||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function exportCsv(rows, columns, filePath) {
|
export async function exportCsv(rows, columns, filePath) {
|
||||||
const fieldnames = columns.map(({ fieldname }) => fieldname);
|
const fieldnames = columns.map(({ fieldname }) => fieldname);
|
||||||
const labels = columns.map(({ label }) => csvFormat(label));
|
const labels = columns.map(({ label }) => csvFormat(label));
|
||||||
const csvRows = [
|
const csvRows = [
|
||||||
|
Loading…
x
Reference in New Issue
Block a user