pdf page spliting
This commit is contained in:
parent
1235d851ab
commit
4905f9ed53
@ -133,10 +133,12 @@ export function DailySalesReportPage() {
|
|||||||
const body = reportData?.response?.rows?.map((row: any) => {
|
const body = reportData?.response?.rows?.map((row: any) => {
|
||||||
const rowData = [row.sl_no, row.store];
|
const rowData = [row.sl_no, row.store];
|
||||||
chunkHeaders.flatMap((h: any) => h.skus || []).forEach((sku: string) => {
|
chunkHeaders.flatMap((h: any) => h.skus || []).forEach((sku: string) => {
|
||||||
rowData.push(row.products?.[sku] ?? 0);
|
const val = row.products?.[sku];
|
||||||
|
rowData.push({ content: val == 0 || !val ? '' : val, styles: { halign: 'center' } });
|
||||||
});
|
});
|
||||||
if (isLastChunk) {
|
if (isLastChunk) {
|
||||||
rowData.push(row.total ?? 0);
|
const tVal = row.total;
|
||||||
|
rowData.push({ content: tVal == 0 || !tVal ? '' : tVal, styles: { halign: 'center' } });
|
||||||
}
|
}
|
||||||
return rowData;
|
return rowData;
|
||||||
}) || [];
|
}) || [];
|
||||||
@ -144,10 +146,12 @@ export function DailySalesReportPage() {
|
|||||||
if (reportData?.response?.total_row) {
|
if (reportData?.response?.total_row) {
|
||||||
const totalRowData = [reportData.response.total_row.sl_no, reportData.response.total_row.store];
|
const totalRowData = [reportData.response.total_row.sl_no, reportData.response.total_row.store];
|
||||||
chunkHeaders.flatMap((h: any) => h.skus || []).forEach((sku: string) => {
|
chunkHeaders.flatMap((h: any) => h.skus || []).forEach((sku: string) => {
|
||||||
totalRowData.push(reportData.response.total_row.products?.[sku] ?? 0);
|
const val = reportData.response.total_row.products?.[sku];
|
||||||
|
totalRowData.push({ content: val == 0 || !val ? '' : val, styles: { halign: 'center' } });
|
||||||
});
|
});
|
||||||
if (isLastChunk) {
|
if (isLastChunk) {
|
||||||
totalRowData.push(reportData.response.total_row.total ?? 0);
|
const tVal = reportData.response.total_row.total;
|
||||||
|
totalRowData.push({ content: tVal == 0 || !tVal ? '' : tVal, styles: { halign: 'center' } });
|
||||||
}
|
}
|
||||||
body.push(totalRowData);
|
body.push(totalRowData);
|
||||||
}
|
}
|
||||||
@ -327,24 +331,34 @@ export function DailySalesReportPage() {
|
|||||||
<tr key={row.sl_no} className="border-b border-black hover:bg-black/5 transition-colors">
|
<tr key={row.sl_no} className="border-b border-black hover:bg-black/5 transition-colors">
|
||||||
<td className="py-2 px-3 text-strong border-r border-black whitespace-nowrap">{row.sl_no}</td>
|
<td className="py-2 px-3 text-strong border-r border-black whitespace-nowrap">{row.sl_no}</td>
|
||||||
<td className="py-2 px-3 text-strong whitespace-nowrap">{row.store}</td>
|
<td className="py-2 px-3 text-strong whitespace-nowrap">{row.store}</td>
|
||||||
{reportData.response.headers?.flatMap((h: any) => h.skus || []).map((sku: string, idx: number) => (
|
{reportData.response.headers?.flatMap((h: any) => h.skus || []).map((sku: string, idx: number) => {
|
||||||
|
const val = row.products?.[sku];
|
||||||
|
return (
|
||||||
<td key={`${sku}-${idx}`} className="py-2 px-3 text-strong text-center border-l border-black">
|
<td key={`${sku}-${idx}`} className="py-2 px-3 text-strong text-center border-l border-black">
|
||||||
{row.products?.[sku] ?? 0}
|
{val == 0 || !val ? '' : val}
|
||||||
|
</td>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
<td className="py-2 px-3 text-strong font-bold text-center border-l border-black bg-black/5">
|
||||||
|
{row.total == 0 || !row.total ? '' : row.total}
|
||||||
</td>
|
</td>
|
||||||
))}
|
|
||||||
<td className="py-2 px-3 text-strong font-bold text-center border-l border-black bg-black/5">{row.total ?? 0}</td>
|
|
||||||
</tr>
|
</tr>
|
||||||
))}
|
))}
|
||||||
{reportData.response.total_row && (
|
{reportData.response.total_row && (
|
||||||
<tr className="border-b border-black bg-black/10 font-bold">
|
<tr className="border-b border-black bg-black/10 font-bold">
|
||||||
<td className="py-2 px-3 text-strong border-r border-black whitespace-nowrap">{reportData.response.total_row.sl_no}</td>
|
<td className="py-2 px-3 text-strong border-r border-black whitespace-nowrap">{reportData.response.total_row.sl_no}</td>
|
||||||
<td className="py-2 px-3 text-strong whitespace-nowrap text-right">{reportData.response.total_row.store}</td>
|
<td className="py-2 px-3 text-strong whitespace-nowrap text-right">{reportData.response.total_row.store}</td>
|
||||||
{reportData.response.headers?.flatMap((h: any) => h.skus || []).map((sku: string, idx: number) => (
|
{reportData.response.headers?.flatMap((h: any) => h.skus || []).map((sku: string, idx: number) => {
|
||||||
|
const val = reportData.response.total_row.products?.[sku];
|
||||||
|
return (
|
||||||
<td key={`total-${sku}-${idx}`} className="py-2 px-3 text-strong text-center border-l border-black">
|
<td key={`total-${sku}-${idx}`} className="py-2 px-3 text-strong text-center border-l border-black">
|
||||||
{reportData.response.total_row.products?.[sku] ?? 0}
|
{val == 0 || !val ? '' : val}
|
||||||
|
</td>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
<td className="py-2 px-3 text-strong text-center border-l border-black">
|
||||||
|
{reportData.response.total_row.total == 0 || !reportData.response.total_row.total ? '' : reportData.response.total_row.total}
|
||||||
</td>
|
</td>
|
||||||
))}
|
|
||||||
<td className="py-2 px-3 text-strong text-center border-l border-black">{reportData.response.total_row.total ?? 0}</td>
|
|
||||||
</tr>
|
</tr>
|
||||||
)}
|
)}
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user