-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCustomerBill.js
More file actions
114 lines (110 loc) · 3.75 KB
/
CustomerBill.js
File metadata and controls
114 lines (110 loc) · 3.75 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
function generateBill() {
const orderId = document.getElementById("OIDText").value;
const customerName = document.getElementById("name").value;
const telephoneNumber = document.getElementById("TeleNum").value;
const itemCode = document.getElementById("ItemCodeText").value;
const price = parseFloat(document.getElementById("PriceText").value);
const discount = parseFloat(document.getElementById("DiscountText").value);
const quantity = parseInt(document.getElementById("QTYText").value);
const total = parseFloat(document.getElementById("TotalFeild").value);
const dataArray = [
{
itemCode: itemCode,
customerName:customerName,
quantity: quantity,
price: price.toFixed(2),
discount: discount.toFixed(2),
total: total.toFixed(2)
}
];
var Monthly = {
outputType: jsPDFInvoiceTemplate.OutputType.Save,
returnJsPDFDocObject: true,
fileName: "Bill_" + orderId + ".pdf",
orientationLandscape: false,
compress: true,
logo: {
src: "img/logo.png",
type: 'PNG',
width: 40,
height: 40,
margin: {
top: -10,
left: 0
}
},
stamp: {
inAllPages: true,
src: "https://raw.githubusercontent.com/edisonneza/jspdf-invoice-template/demo/images/qr_code.jpg",
type: 'JPG',
width: 20,
height: 20,
margin: {
top: 0,
left: 0
}
},
business: {
name: "j&k Burgers",
address: "No 300, Main Street, Athurugiriya, Colombo",
phone: "(+94) 0740726297",
email: "JKBurgers@gmail.com",
website: "www.J&KBurgers.com"
},
invoice: {
headerBorder: false,
tableBodyBorder: false,
header: [
{ title: "Item Code" },
{ title: "Customer Name" },
{ title: "Quantity" },
{ title: "Price" },
{ title: "Discount" },
{ title: "Total" }
],
table: dataArray.map((rowData) => ([
rowData.itemCode,
rowData.customerName,
rowData.quantity,
rowData.price,
rowData.discount,
rowData.total
])),
additionalRows: [
{
col1: 'Customer Name:',
col2: customerName || 'N/A', // Default to 'N/A' if empty
col3: '',
style: { fontSize: 12 }
},
{
col1: 'Telephone Number:',
col2: telephoneNumber || 'N/A', // Default to 'N/A' if empty
col3: '',
style: { fontSize: 12 }
},
{
col1: 'Order ID:',
col2: orderId || 'N/A', // Default to 'N/A' if empty
col3: '',
style: { fontSize: 12 }
},
{
col1: 'Total Amount:',
col2: total.toFixed(2),
col3: 'ALL',
style: { fontSize: 14, fontWeight: 'bold' }
}
],
},
footer: {
text: "Thank you for your purchase. The bill is created on a computer and is valid without a signature and stamp."
},
pageEnable: true,
pageLabel: "Page "
};
// Create the PDF
jsPDFInvoiceTemplate.default(Monthly);
// Log the object for debugging
console.log("PDF Object created");
}