Skip to content

Commit 4787650

Browse files
authored
Merge pull request #8 from datmemerboi/rebuild
Coordinate & invoice date changes in PDF
2 parents a45222d + 7b4b6c2 commit 4787650

File tree

2 files changed

+30
-19
lines changed

2 files changed

+30
-19
lines changed

api/coordinates.json

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,29 +45,29 @@
4545
},
4646
"date": {
4747
"x": 0,
48-
"y": 250
48+
"y": 705
4949
}
5050
},
5151
"table": {
5252
"head": {
5353
"banner_up": {
5454
"x": 0,
55-
"y": 290
55+
"y": 260
5656
},
5757
"banner_down": {
5858
"x": 612,
59-
"y": 320
59+
"y": 290
6060
},
6161
"proc_x": 120,
6262
"cost_x": 310,
6363
"qty_x": 400,
6464
"total_x": 490,
65-
"y": 298
65+
"y": 268
6666
},
6767
"body": {
6868
"base_proc": {
6969
"x": 80,
70-
"y": 340,
70+
"y": 310,
7171
"max_width": 200,
7272
"max_height": 20
7373
},
@@ -87,24 +87,24 @@
8787
"foot": {
8888
"left_x": 60,
8989
"right_x": 550,
90-
"y": 610
90+
"y": 550
9191
}
9292
},
9393
"total_foot": {
9494
"x": 380,
95-
"sub_y": 620,
96-
"grand_y": 650
95+
"sub_y": 560,
96+
"grand_y": 590
9797
},
9898
"payment": {
9999
"method": {
100100
"name_x": 60,
101101
"x": 160,
102-
"y": 670
102+
"y": 590
103103
},
104104
"id": {
105105
"name_x": 60,
106106
"x": 130,
107-
"y": 690
107+
"y": 610
108108
}
109109
}
110110
}

api/utils/invoice-utils.js

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ function generatePdf(invoiceObj) {
121121
.text(invoiceObj.payment_id ?? null, posx.payment.id.x, posx.payment.id.y);
122122

123123
invoiceObj.treatments.forEach((trt, ind) => {
124-
let currentHeight = posx.table.body.base_proc.y + 64 * ind;
124+
let currentHeight = posx.table.body.base_proc.y + 60 * ind;
125125
doc
126126
.text(trt.procedure_done, posx.table.body.base_proc.x, currentHeight, {
127127
width: posx.table.body.base_proc.max_width,
@@ -147,12 +147,23 @@ function generatePdf(invoiceObj) {
147147
.text(`${invoiceObj.patient.age} / ${invoiceObj.patient.gender}`)
148148
.text(invoiceObj.patient.contact)
149149
.text("Doctor:", posx.data.doctor.x, posx.data.doctor.y)
150-
.text(invoiceObj.created_at, posx.data.date.x, posx.data.date.y, { align: 'right' })
151150
.text("Sub Total: Rs.", posx.total_foot.x, posx.total_foot.sub_y)
152-
.text("Grand Total: Rs.", posx.total_foot.x, posx.total_foot.grand_y);
151+
.text("Grand Total: Rs.", posx.total_foot.x, posx.total_foot.grand_y)
152+
.fontSize(10) // 10 REGULAR BLACK (SUB TEXT)
153+
.text(
154+
`Generated on ${invoiceObj.created_at.toLocaleString("default", {
155+
day: "numeric",
156+
month: "numeric",
157+
year: "numeric",
158+
hour: "numeric",
159+
minute: "numeric",
160+
hour12: true
161+
})}`,
162+
posx.data.date.x, posx.data.date.y, { align: "center" }
163+
);
153164

154165
// 14 SEMIBOLD BLACK
155-
doc.font(path.join(miscPath, 'ProximaNova-Semibold.ttf'))
166+
doc.fontSize(14).font(path.join(miscPath, 'ProximaNova-Semibold.ttf'))
156167
.text(invoiceObj.doctor.join(', '), posx.data.doctor.name_x, posx.data.doctor.y)
157168
.text(invoiceObj.patient.p_id, posx.data.patient.pid.x, posx.data.patient.pid.y, { align: 'right' })
158169
.text(!_.isNil(invoiceObj.sub_total)
@@ -214,11 +225,11 @@ async function NewInvoiceHandler(pid, body) {
214225
p_id: pid,
215226
doctor: _.chain(body.treatments).map('doctor').uniq().value(),
216227
treatments: body.treatments.map(JSON.stringify),
217-
payment_method: _.has(body,"payment_method") ? body.payment_method : null,
218-
payment_id: _.has(body,"payment_id") ? body.payment_id : null,
219-
sub_total: _.has(body,"sub_total") ? body.sub_total : null,
220-
discount: _.has(body,"discount") ? body.discount : null,
221-
grand_total: _.has(body,"grand_total") ? body.grand_total : null
228+
payment_method: _.has(body, "payment_method") ? body.payment_method : null,
229+
payment_id: _.has(body, "payment_id") ? body.payment_id : null,
230+
sub_total: _.has(body, "sub_total") ? body.sub_total : null,
231+
discount: _.has(body, "discount") ? body.discount : null,
232+
grand_total: _.has(body, "grand_total") ? body.grand_total : null
222233
};
223234
invoiceObj = sanitize(invoiceObj);
224235
invoiceObj.inv_id = await makeNextInvid(db);

0 commit comments

Comments
 (0)