mirror of
https://github.com/frappe/books.git
synced 2024-11-09 23:30:56 +00:00
Created the initial setup for GSTR-1 export as CSV
This commit is contained in:
parent
f9d624c657
commit
c8a314c5dc
@ -330,7 +330,59 @@ async function generateB2bCsvGstr2(rows, columns) {
|
||||
]
|
||||
|
||||
return {
|
||||
columns: csvColumns,
|
||||
rows: rows,
|
||||
columns: csvColumns || [],
|
||||
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 || [],
|
||||
}
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
const title = 'GSTR 1';
|
||||
import baseConfig from './BaseViewConfig';
|
||||
import { generateGstr1Json } from '../../accounting/gst';
|
||||
import { generateGstr1Json, generateGstr1Csv } from '../../accounting/gst';
|
||||
|
||||
const transferTypeMap = {
|
||||
B2B: 'B2B',
|
||||
@ -29,6 +29,14 @@ const actions = [
|
||||
generateGstr1Json(report, filters);
|
||||
},
|
||||
},
|
||||
{
|
||||
group: 'Export',
|
||||
label: 'CSV',
|
||||
type: 'primary',
|
||||
action: async (report, filters) => {
|
||||
generateGstr1Csv(report, filters);
|
||||
},
|
||||
},
|
||||
]
|
||||
|
||||
export default {
|
||||
|
Loading…
Reference in New Issue
Block a user