dsr name changed and made it to landscape
This commit is contained in:
parent
fdfa5e386b
commit
dd06df1fb1
@ -5,7 +5,7 @@
|
|||||||
// docs under src/docs/api.
|
// docs under src/docs/api.
|
||||||
|
|
||||||
export const APP_ID = '434';
|
export const APP_ID = '434';
|
||||||
export const BASE_URL = 'https://sandbox.getzino.in';
|
export const BASE_URL = 'https://dev.getzino.in';
|
||||||
|
|
||||||
// --- Order Booking (src/docs/api/order_booking.md) ---
|
// --- Order Booking (src/docs/api/order_booking.md) ---
|
||||||
export const ORDER_BOOKING = {
|
export const ORDER_BOOKING = {
|
||||||
|
|||||||
@ -22,38 +22,43 @@ export function DailySalesReportPage() {
|
|||||||
const [reportData, setReportData] = useState<any>(null);
|
const [reportData, setReportData] = useState<any>(null);
|
||||||
|
|
||||||
const downloadPDF = () => {
|
const downloadPDF = () => {
|
||||||
const doc = new jsPDF();
|
const doc = new jsPDF('landscape');
|
||||||
|
const pageWidth = doc.internal.pageSize.getWidth();
|
||||||
|
const centerX = pageWidth / 2;
|
||||||
|
const rightMargin = pageWidth - 14;
|
||||||
|
|
||||||
// Headers
|
// Headers
|
||||||
doc.setFontSize(16);
|
doc.setFontSize(16);
|
||||||
doc.setFont('helvetica', 'bold');
|
doc.setFont('helvetica', 'bold');
|
||||||
doc.text('Krishna Flour Mills (Bangalore) Pvt. Limited', 105, 15, { align: 'center' });
|
doc.text('Krishna Flour Mills (Bangalore) Pvt. Limited', centerX, 15, { align: 'center' });
|
||||||
|
|
||||||
doc.setFontSize(11);
|
doc.setFontSize(11);
|
||||||
doc.setFont('helvetica', 'normal');
|
doc.setFont('helvetica', 'normal');
|
||||||
doc.text('19, Platform Road, Bengaluru - 560 020', 105, 22, { align: 'center' });
|
doc.text('19, Platform Road, Bengaluru - 560 020', centerX, 22, { align: 'center' });
|
||||||
|
|
||||||
doc.setFontSize(12);
|
doc.setFontSize(12);
|
||||||
doc.setFont('helvetica', 'bold');
|
doc.setFont('helvetica', 'bold');
|
||||||
doc.text('DAILY ORDER REPORT', 105, 30, { align: 'center' });
|
doc.text('DAILY ORDER REPORT', centerX, 30, { align: 'center' });
|
||||||
|
|
||||||
// Simple underline for DAILY ORDER REPORT
|
// Simple underline for DAILY ORDER REPORT
|
||||||
const textWidth = doc.getTextWidth('DAILY ORDER REPORT');
|
const textWidth = doc.getTextWidth('DAILY ORDER REPORT');
|
||||||
doc.setLineWidth(0.5);
|
doc.setLineWidth(0.5);
|
||||||
doc.line(105 - textWidth / 2, 31, 105 + textWidth / 2, 31);
|
doc.line(centerX - textWidth / 2, 31, centerX + textWidth / 2, 31);
|
||||||
|
|
||||||
// Meta Info
|
// Meta Info
|
||||||
doc.setFontSize(10);
|
doc.setFontSize(10);
|
||||||
doc.text(`Distributor Name : ${distributor}`, 14, 40);
|
doc.text(`Distributor Name : ${distributor}`, 14, 40);
|
||||||
doc.text(`Date : ${date}`, 196, 40, { align: 'right' });
|
doc.text(`Date : ${date}`, rightMargin, 40, { align: 'right' });
|
||||||
doc.text(`SO Name : ${soName}`, 196, 45, { align: 'right' });
|
doc.text(`SO Name : ${soName}`, rightMargin, 45, { align: 'right' });
|
||||||
|
|
||||||
// Table
|
// Table
|
||||||
autoTable(doc, {
|
autoTable(doc, {
|
||||||
html: '#report-table',
|
html: '#report-table',
|
||||||
startY: 50,
|
startY: 50,
|
||||||
theme: 'grid',
|
theme: 'grid',
|
||||||
styles: { fontSize: 8, textColor: [0, 0, 0], lineColor: [0, 0, 0], lineWidth: 0.2 },
|
horizontalPageBreak: true,
|
||||||
|
horizontalPageBreakRepeat: 0,
|
||||||
|
styles: { fontSize: 6, textColor: [0, 0, 0], lineColor: [0, 0, 0], lineWidth: 0.2, cellPadding: 1, minCellWidth: 10 },
|
||||||
headStyles: { fillColor: [243, 244, 246], fontStyle: 'bold', halign: 'center' },
|
headStyles: { fillColor: [243, 244, 246], fontStyle: 'bold', halign: 'center' },
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -61,38 +66,43 @@ export function DailySalesReportPage() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const printReport = async () => {
|
const printReport = async () => {
|
||||||
const doc = new jsPDF();
|
const doc = new jsPDF('landscape');
|
||||||
|
const pageWidth = doc.internal.pageSize.getWidth();
|
||||||
|
const centerX = pageWidth / 2;
|
||||||
|
const rightMargin = pageWidth - 14;
|
||||||
|
|
||||||
// Headers
|
// Headers
|
||||||
doc.setFontSize(16);
|
doc.setFontSize(16);
|
||||||
doc.setFont('helvetica', 'bold');
|
doc.setFont('helvetica', 'bold');
|
||||||
doc.text('Krishna Flour Mills (Bangalore) Pvt. Limited', 105, 15, { align: 'center' });
|
doc.text('Krishna Flour Mills (Bangalore) Pvt. Limited', centerX, 15, { align: 'center' });
|
||||||
|
|
||||||
doc.setFontSize(11);
|
doc.setFontSize(11);
|
||||||
doc.setFont('helvetica', 'normal');
|
doc.setFont('helvetica', 'normal');
|
||||||
doc.text('19, Platform Road, Bengaluru - 560 020', 105, 22, { align: 'center' });
|
doc.text('19, Platform Road, Bengaluru - 560 020', centerX, 22, { align: 'center' });
|
||||||
|
|
||||||
doc.setFontSize(12);
|
doc.setFontSize(12);
|
||||||
doc.setFont('helvetica', 'bold');
|
doc.setFont('helvetica', 'bold');
|
||||||
doc.text('DAILY ORDER REPORT', 105, 30, { align: 'center' });
|
doc.text('DAILY ORDER REPORT', centerX, 30, { align: 'center' });
|
||||||
|
|
||||||
// Simple underline for DAILY ORDER REPORT
|
// Simple underline for DAILY ORDER REPORT
|
||||||
const textWidth = doc.getTextWidth('DAILY ORDER REPORT');
|
const textWidth = doc.getTextWidth('DAILY ORDER REPORT');
|
||||||
doc.setLineWidth(0.5);
|
doc.setLineWidth(0.5);
|
||||||
doc.line(105 - textWidth / 2, 31, 105 + textWidth / 2, 31);
|
doc.line(centerX - textWidth / 2, 31, centerX + textWidth / 2, 31);
|
||||||
|
|
||||||
// Meta Info
|
// Meta Info
|
||||||
doc.setFontSize(10);
|
doc.setFontSize(10);
|
||||||
doc.text(`Distributor Name : ${distributor}`, 14, 40);
|
doc.text(`Distributor Name : ${distributor}`, 14, 40);
|
||||||
doc.text(`Date : ${date}`, 196, 40, { align: 'right' });
|
doc.text(`Date : ${date}`, rightMargin, 40, { align: 'right' });
|
||||||
doc.text(`SO Name : ${soName}`, 196, 45, { align: 'right' });
|
doc.text(`SO Name : ${soName}`, rightMargin, 45, { align: 'right' });
|
||||||
|
|
||||||
// Table
|
// Table
|
||||||
autoTable(doc, {
|
autoTable(doc, {
|
||||||
html: '#report-table',
|
html: '#report-table',
|
||||||
startY: 50,
|
startY: 50,
|
||||||
theme: 'grid',
|
theme: 'grid',
|
||||||
styles: { fontSize: 8, textColor: [0, 0, 0], lineColor: [0, 0, 0], lineWidth: 0.2 },
|
horizontalPageBreak: true,
|
||||||
|
horizontalPageBreakRepeat: 0,
|
||||||
|
styles: { fontSize: 6, textColor: [0, 0, 0], lineColor: [0, 0, 0], lineWidth: 0.2, cellPadding: 1, minCellWidth: 10 },
|
||||||
headStyles: { fillColor: [243, 244, 246], fontStyle: 'bold', halign: 'center' },
|
headStyles: { fillColor: [243, 244, 246], fontStyle: 'bold', halign: 'center' },
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -194,82 +204,87 @@ export function DailySalesReportPage() {
|
|||||||
<div className="p-4 pb-2 print:hidden">
|
<div className="p-4 pb-2 print:hidden">
|
||||||
<h2 className="text-lg font-bold text-strong m-0">Report Details</h2>
|
<h2 className="text-lg font-bold text-strong m-0">Report Details</h2>
|
||||||
</div>
|
</div>
|
||||||
<div className="w-full overflow-x-auto p-4 pt-2">
|
{(!reportData.response.rows || reportData.response.rows.length === 0) ? (
|
||||||
<div className="min-w-max">
|
<div className="p-8 text-center text-slate-500 font-medium bg-slate-50/50 rounded-xl m-4">
|
||||||
<div className="flex flex-col items-center text-center gap-1">
|
No records found for the selected criteria.
|
||||||
<h1 className="m-0 text-lg font-bold text-strong">Krishna Flour Mills (Bangalore) Pvt. Limited</h1>
|
</div>
|
||||||
<h2 className="m-0 text-sm font-normal text-strong">19, Platform Road, Bengaluru - 560 020</h2>
|
) : (
|
||||||
<h3 className="m-0 text-base font-bold text-strong underline mt-1 mb-4">DAILY ORDER REPORT</h3>
|
<>
|
||||||
</div>
|
<div className="w-full overflow-x-auto p-4 pt-2">
|
||||||
|
<div className="min-w-max">
|
||||||
|
<div className="flex flex-col items-center text-center gap-1">
|
||||||
|
<h1 className="m-0 text-lg font-bold text-strong">Krishna Flour Mills (Bangalore) Pvt. Limited</h1>
|
||||||
|
<h2 className="m-0 text-sm font-normal text-strong">19, Platform Road, Bengaluru - 560 020</h2>
|
||||||
|
<h3 className="m-0 text-base font-bold text-strong underline mt-1 mb-4">DAILY ORDER REPORT</h3>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div className="flex justify-between items-start text-sm font-bold text-strong mb-2">
|
<div className="flex justify-between items-start text-sm font-bold text-strong mb-2">
|
||||||
<div>Distributor Name : {distributor}</div>
|
<div>Distributor Name : {distributor}</div>
|
||||||
<div className="text-right flex flex-col gap-1.5">
|
<div className="text-right flex flex-col gap-1.5">
|
||||||
<div>Date : {date}</div>
|
<div>Date : {date}</div>
|
||||||
<div>SO Name : {soName}</div>
|
<div>SO Name : {soName}</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<table id="report-table" className="w-full text-sm text-left border border-black border-collapse mt-2">
|
||||||
|
<thead>
|
||||||
|
<tr className="border-b border-black bg-black/5">
|
||||||
|
<th className="py-2 px-3 font-bold text-black align-bottom border-r border-black" rowSpan={2}>Sl No</th>
|
||||||
|
<th className="py-2 px-3 font-bold text-black align-bottom" rowSpan={2}>Store</th>
|
||||||
|
{reportData.response.headers?.map((h: any) => (
|
||||||
|
<th key={h.br_code} colSpan={h.skus?.length || 1} className="py-1 px-3 font-bold text-black text-center border-l border-black">
|
||||||
|
{h.br_code}
|
||||||
|
</th>
|
||||||
|
))}
|
||||||
|
<th className="py-2 px-3 font-bold text-black align-bottom border-l border-black" rowSpan={2}>Total</th>
|
||||||
|
</tr>
|
||||||
|
<tr className="border-b border-black bg-black/5">
|
||||||
|
{reportData.response.headers?.flatMap((h: any) => h.skus || []).map((sku: string, idx: number) => (
|
||||||
|
<th key={`${sku}-${idx}`} className="py-1 px-3 font-bold text-black text-center border-l border-black whitespace-nowrap">
|
||||||
|
{sku}
|
||||||
|
</th>
|
||||||
|
))}
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{reportData.response.rows?.map((row: any) => (
|
||||||
|
<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">{row.sl_no}</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) => (
|
||||||
|
<td key={`${sku}-${idx}`} className="py-2 px-3 text-strong text-center border-l border-black">
|
||||||
|
{row.products?.[sku] ?? 0}
|
||||||
|
</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>
|
||||||
|
))}
|
||||||
|
{reportData.response.total_row && (
|
||||||
|
<tr className="border-b border-black bg-black/10 font-bold">
|
||||||
|
<td className="py-2 px-3 text-strong border-r border-black">{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>
|
||||||
|
{reportData.response.headers?.flatMap((h: any) => h.skus || []).map((sku: string, idx: number) => (
|
||||||
|
<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}
|
||||||
|
</td>
|
||||||
|
))}
|
||||||
|
<td className="py-2 px-3 text-strong text-center border-l border-black">{reportData.response.total_row.total ?? 0}</td>
|
||||||
|
</tr>
|
||||||
|
)}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div className="p-4 pt-4 pb-6 flex flex-col gap-4 print:hidden">
|
||||||
<table id="report-table" className="w-full text-sm text-left border border-black border-collapse mt-2">
|
<Button type="button" onClick={downloadPDF} variant="secondary" iconLeft={<Download size={18} />} full>
|
||||||
<thead>
|
Download PDF
|
||||||
<tr className="border-b border-black bg-black/5">
|
</Button>
|
||||||
<th className="py-2 px-3 font-bold text-black align-bottom border-r border-black" rowSpan={2}>Sl No</th>
|
<Button type="button" onClick={printReport} iconLeft={<Printer size={18} />} full>
|
||||||
<th className="py-2 px-3 font-bold text-black align-bottom" rowSpan={2}>Store</th>
|
Print PDF
|
||||||
{reportData.response.headers?.map((h: any) => (
|
</Button>
|
||||||
<th key={h.br_code} colSpan={h.skus?.length || 1} className="py-1 px-3 font-bold text-black text-center border-l border-black">
|
</div>
|
||||||
{h.br_code}
|
</>
|
||||||
</th>
|
)}
|
||||||
))}
|
|
||||||
<th className="py-2 px-3 font-bold text-black align-bottom border-l border-black" rowSpan={2}>Total</th>
|
|
||||||
</tr>
|
|
||||||
<tr className="border-b border-black bg-black/5">
|
|
||||||
{reportData.response.headers?.flatMap((h: any) => h.skus || []).map((sku: string, idx: number) => (
|
|
||||||
<th key={`${sku}-${idx}`} className="py-1 px-3 font-bold text-black text-center border-l border-black whitespace-nowrap">
|
|
||||||
{sku}
|
|
||||||
</th>
|
|
||||||
))}
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
{reportData.response.rows?.map((row: any) => (
|
|
||||||
<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">{row.sl_no}</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) => (
|
|
||||||
<td key={`${sku}-${idx}`} className="py-2 px-3 text-strong text-center border-l border-black">
|
|
||||||
{row.products?.[sku] ?? 0}
|
|
||||||
</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>
|
|
||||||
))}
|
|
||||||
{reportData.response.total_row && (
|
|
||||||
<tr className="border-b border-black bg-black/10 font-bold">
|
|
||||||
<td className="py-2 px-3 text-strong border-r border-black">{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>
|
|
||||||
{reportData.response.headers?.flatMap((h: any) => h.skus || []).map((sku: string, idx: number) => (
|
|
||||||
<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}
|
|
||||||
</td>
|
|
||||||
))}
|
|
||||||
<td className="py-2 px-3 text-strong text-center border-l border-black">{reportData.response.total_row.total ?? 0}</td>
|
|
||||||
</tr>
|
|
||||||
)}
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
{(!reportData.response.rows || reportData.response.rows.length === 0) && (
|
|
||||||
<div className="py-8 text-center text-faint">No records found.</div>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div className="p-4 pt-4 pb-6 flex flex-col gap-4 print:hidden">
|
|
||||||
<Button type="button" onClick={downloadPDF} variant="secondary" iconLeft={<Download size={18} />} full>
|
|
||||||
Download PDF
|
|
||||||
</Button>
|
|
||||||
<Button type="button" onClick={printReport} iconLeft={<Printer size={18} />} full>
|
|
||||||
Print PDF
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
</Card>
|
</Card>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -37,7 +37,7 @@ export const SCREENS: ScreenDef[] = [
|
|||||||
{ key: 'stores', label: 'Stores', icon: Store, View: StoresView, Detail: StoreDetail, noun: 'Store' },
|
{ key: 'stores', label: 'Stores', icon: Store, View: StoresView, Detail: StoreDetail, noun: 'Store' },
|
||||||
{ key: 'all-daily', label: 'All Logs', icon: ClipboardList, View: DailyLogsView, Detail: DailyLogDetail, noun: 'Daily Log' },
|
{ key: 'all-daily', label: 'All Logs', icon: ClipboardList, View: DailyLogsView, Detail: DailyLogDetail, noun: 'Daily Log' },
|
||||||
{ key: 'analytics', label: 'Analytics', icon: BarChart2, View: AnalyticsPage as any },
|
{ key: 'analytics', label: 'Analytics', icon: BarChart2, View: AnalyticsPage as any },
|
||||||
{ key: 'sales-report', label: 'Sales Report', icon: FileText, View: DailySalesReportPage as any }
|
{ key: 'sales-report', label: 'DSR', icon: FileText, View: DailySalesReportPage as any }
|
||||||
];
|
];
|
||||||
|
|
||||||
export function screenByKey(key: string | undefined): ScreenDef | undefined {
|
export function screenByKey(key: string | undefined): ScreenDef | undefined {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user