-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathitemReport.js
More file actions
130 lines (119 loc) · 4.74 KB
/
itemReport.js
File metadata and controls
130 lines (119 loc) · 4.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
function getItemReport() {
let burgerData = JSON.parse(localStorage.getItem('burgerData')) || [];
let submarineData = JSON.parse(localStorage.getItem('submarineData')) || [];
let friesData = JSON.parse(localStorage.getItem('friesData')) || [];
let pastaDta=JSON.parse(localStorage.getItem('PastaData')) || [];
let ChickenDta=JSON.parse(localStorage.getItem('ChickenData')) || [];
let BeavaragesDta=JSON.parse(localStorage.getItem('Beverages')) || [];
let reportData = [];
function addToReport(data, category) {
data.forEach(item => {
console.log('Item Quantity:', item.Qty);
reportData.push({
category: category,
itemCode: item.itemCode,
itemName: item.itemName,
price: item.price,
quantity: item.Qty
});
});
}
addToReport(burgerData, 'Burger');
addToReport(submarineData, 'Submarine');
addToReport(friesData,'Fries');
addToReport(pastaDta, 'Pasta');
addToReport(ChickenDta,'Chicken');
addToReport(BeavaragesDta, 'Bevarages');
let currentMonthValue = new Date().getMonth() + 1; // Months are zero-indexed
let currentYear = new Date().getFullYear();
let currentdate = new Date().getDate();
var Monthly = {
outputType: jsPDFInvoiceTemplate.OutputType.Save, // Use OutputType from jsPDFInvoiceTemplate
returnJsPDFDocObject: true,
fileName: "Monthly Sales Report",
orientationLandscape: false,
compress: true,
logo: {
src: "img/logo.png",
type: 'PNG', // Optional, when src = data:uri (nodejs case)
width: 40, // Aspect ratio = width/height
height: 40,
margin: {
top: -10, // Negative or positive num, from the current position
left: 0 // Negative or positive num, from the current position
}
},
stamp: {
inAllPages: true, // By default = false, just in the last page
src: "https://raw.githubusercontent.com/edisonneza/jspdf-invoice-template/demo/images/qr_code.jpg",
type: 'JPG', // Optional, when src = data:uri (nodejs case)
width: 20, // Aspect ratio = width/height
height: 20,
margin: {
top: 0, // Negative or positive num, from the current position
left: 0 // Negative or positive num, from the current position
}
},
business: {
name: "J&K Burgers",
address: "No 300,Main Street,Athurigiriya,Colombo",
phone: "(+94) 070 2786812",
email: "JKBurgers@gmail.com",
website: "www.J&KBurgers.com",
},
contact: {
label: "Report issued for:",
address: "Icet Panadura.",
phone: "(+94) 76 488 77322",
email: "BQBurgers@gmail.com",
otherInfo: "www.BQBurgers.com",
},
invoice: {
label: "Monthly Sales Report: ",
num:1,// Ensure this variable is defined elsewhere in your code
invDate: `From: 1/${currentMonthValue}/${currentYear}`, // Template literals for dynamic values
invGenDate: `To: ${currentdate}/${currentMonthValue}/${currentYear}`, // Template literals for dynamic values
headerBorder: true,
tableBodyBorder: true,
header: [
{ title: "Item Code" },
{ title: "Item Name" },
{ title: "Quantity" }
],
table: reportData.map((data) => ([
data.itemCode,
data.itemName,
String(data.quantity)
])),
additionalRows: [
{
col1: 'Total:',
col2: '145,250.50',
col3: 'ALL',
style: { fontSize: 14 } // Optional, default 12
},
{
col1: 'VAT:',
col2: '20',
col3: '%',
style: { fontSize: 10 } // Optional, default 12
},
{
col1: 'SubTotal:',
col2: '116,199.90',
col3: 'ALL',
style: { fontSize: 10 } // Optional, default 12
}
],
},
footer: {
text: "The invoice is created on a computer and is valid without the signature and stamp.",
},
pageEnable: true,
pageLabel: "Page ",
};
// Create the PDF
jsPDFInvoiceTemplate.default(Monthly);
// Log the object for debugging
console.log("PDF Object created");
}