csv lable changed, new lable added as claim_type and type (column separator) added
This commit is contained in:
parent
7b1df12a5b
commit
c50d481698
@ -1024,7 +1024,7 @@ export class DealerClaimController {
|
||||
taxationType = activity?.taxationType || (claimDetails.activityType.toLowerCase().includes('non') ? 'Non GST' : 'GST');
|
||||
}
|
||||
|
||||
// Construct CSV
|
||||
// Construct CSV with pipe separator
|
||||
const headers = [
|
||||
'TRNS_UNIQ_NO',
|
||||
'CLAIM_NUMBER',
|
||||
@ -1032,10 +1032,11 @@ export class DealerClaimController {
|
||||
'DEALER_CODE',
|
||||
'IO_NUMBER',
|
||||
'CLAIM_DOC_TYP',
|
||||
'CLAIM_TYPE',
|
||||
'CLAIM_DATE',
|
||||
'CLAIM_AMT',
|
||||
'GST_AMT',
|
||||
'GST_PERCENTAG'
|
||||
'GST_PERCENTAGE'
|
||||
];
|
||||
|
||||
const rows = items.map(item => {
|
||||
@ -1048,12 +1049,13 @@ export class DealerClaimController {
|
||||
const dealerCode = claimDetails?.dealerCode || '';
|
||||
const ioNumber = internalOrder?.ioNumber || '';
|
||||
const claimDocTyp = sapRefNo;
|
||||
const claimType = claimDetails?.activityType || '';
|
||||
const claimDate = invoice?.createdAt ? new Date(invoice.createdAt).toISOString().split('T')[0] : '';
|
||||
const claimAmt = item.assAmt;
|
||||
|
||||
// Zero out tax for Non-GST
|
||||
const totalTax = isNonGst ? 0 : (Number(item.igstAmt || 0) + Number(item.cgstAmt || 0) + Number(item.sgstAmt || 0) + Number(item.utgstAmt || 0));
|
||||
const gstPercentag = isNonGst ? 0 : (item.gstRt || 0);
|
||||
const gstPercentage = isNonGst ? 0 : (item.gstRt || 0);
|
||||
|
||||
return [
|
||||
trnsUniqNo,
|
||||
@ -1062,14 +1064,15 @@ export class DealerClaimController {
|
||||
dealerCode,
|
||||
ioNumber,
|
||||
claimDocTyp,
|
||||
claimType,
|
||||
claimDate,
|
||||
claimAmt,
|
||||
totalTax.toFixed(2),
|
||||
gstPercentag
|
||||
].join(',');
|
||||
gstPercentage
|
||||
].join('|');
|
||||
});
|
||||
|
||||
const csvContent = [headers.join(','), ...rows].join('\n');
|
||||
const csvContent = [headers.join('|'), ...rows].join('\n');
|
||||
|
||||
res.setHeader('Content-Type', 'text/csv');
|
||||
res.setHeader('Content-Disposition', `attachment; filename="Invoice_${requestNumber}.csv"`);
|
||||
|
||||
@ -3619,10 +3619,11 @@ export class DealerClaimService {
|
||||
DEALER_CODE: claimDetails.dealerCode,
|
||||
IO_NUMBER: internalOrder?.ioNumber || '',
|
||||
CLAIM_DOC_TYP: sapRefNo,
|
||||
CLAIM_TYPE: claimDetails.activityType,
|
||||
CLAIM_DATE: formatDate(invoice.invoiceDate || new Date()),
|
||||
CLAIM_AMT: item.assAmt,
|
||||
GST_AMT: totalTax.toFixed(2),
|
||||
GST_PERCENTAG: item.gstRt
|
||||
GST_PERCENTAGE: item.gstRt
|
||||
};
|
||||
});
|
||||
|
||||
|
||||
@ -43,9 +43,9 @@ export class WFMFileService {
|
||||
|
||||
const filePath = path.join(targetDir, fileName.endsWith('.csv') ? fileName : `${fileName}.csv`);
|
||||
|
||||
// Simple CSV generation logic
|
||||
const headers = Object.keys(data[0] || {}).join(',');
|
||||
const rows = data.map(item => Object.values(item).map(val => `"${val}"`).join(',')).join('\n');
|
||||
// Simple CSV generation logic with pipe separator and no quotes
|
||||
const headers = Object.keys(data[0] || {}).join('|');
|
||||
const rows = data.map(item => Object.values(item).map(val => val === null || val === undefined ? '' : String(val)).join('|')).join('\n');
|
||||
const csvContent = `${headers}\n${rows}`;
|
||||
|
||||
fs.writeFileSync(filePath, csvContent);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user