2
0
mirror of https://github.com/frappe/books.git synced 2024-12-23 11:29:03 +00:00

Created the initial setup for GSTR-1 export as CSV

This commit is contained in:
Piyush Singhania 2022-01-12 22:26:40 +05:30 committed by Alan
parent f9d624c657
commit c8a314c5dc
2 changed files with 63 additions and 3 deletions

View File

@ -330,7 +330,59 @@ async function generateB2bCsvGstr2(rows, columns) {
] ]
return { return {
columns: csvColumns, columns: csvColumns || [],
rows: rows, rows: rows || [],
}
}
export async function generateGstr1Csv(getReportData) {
const { gstin } = frappe.AccountingSettings;
if (!gstin) {
showMessageDialog({
message: _('Export Failed'),
description: _('Please set GSTIN in General Settings.'),
});
return;
}
const {
rows,
columns,
filters: { transferType, toDate },
} = getReportData();
const { filePath, canceled } = await getSavePath('gstr-1', 'csv');
if (canceled || !filePath) return;
let gstData;
if (transferType === 'B2B') {
gstData = await generateB2bCsvGstr1(rows, columns);
} else if (transferType === 'B2CL') {
gstData = await generateB2clCsvGstr1(rows);
} else if (transferType === 'B2CS') {
gstData = await generateB2csCsvGstr1(rows);
}
await exportCsv(gstData.rows, gstData.columns, filePath);
}
async function generateB2bCsvGstr1(rows, columns) {
return {
columns: columns || [],
rows: rows || [],
}
}
async function generateB2csCsvGstr1(rows, columns) {
return {
columns: columns || [],
rows: rows || [],
}
}
async function generateB2clCsvGstr1(rows, columns) {
return {
columns: columns || [],
rows: rows || [],
} }
} }

View File

@ -1,6 +1,6 @@
const title = 'GSTR 1'; const title = 'GSTR 1';
import baseConfig from './BaseViewConfig'; import baseConfig from './BaseViewConfig';
import { generateGstr1Json } from '../../accounting/gst'; import { generateGstr1Json, generateGstr1Csv } from '../../accounting/gst';
const transferTypeMap = { const transferTypeMap = {
B2B: 'B2B', B2B: 'B2B',
@ -29,6 +29,14 @@ const actions = [
generateGstr1Json(report, filters); generateGstr1Json(report, filters);
}, },
}, },
{
group: 'Export',
label: 'CSV',
type: 'primary',
action: async (report, filters) => {
generateGstr1Csv(report, filters);
},
},
] ]
export default { export default {