-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathscript.js
More file actions
67 lines (59 loc) · 1.87 KB
/
script.js
File metadata and controls
67 lines (59 loc) · 1.87 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
var app = Vue.createApp({
data(){
return {
brandColor: "#6366F1",
rowCount: 1,
letter: true,
currency: '$',
rows: [{ amount: '', unit: '', total: 0 }],
subTotal: 0,
taxPercentage: '',
tax: 0,
total: 0,
message: `Dear Arman Rahman,
I've provided a breakdown of the costs for the recent work completed below. Kindly make the payment at your earliest convenience. Feel free to reach out if you have any questions.
Thank you,
Your Name`
}
},
computed: {
year() {
const currentDate = new Date();
return currentDate.getFullYear();
},
},
methods:{
addRow() {
this.rowCount++;
this.rows.push({ amount: '', unit: '', total: 0 });
},
removeRow(){
this.rowCount--;
this.rows.pop();
this.calculatePercentage();
},
calculateSubTotal(index) {
this.rows[index].total = this.rows[index].amount * this.rows[index].unit;
this.calculatePercentage();
},
calculatePercentage(){
this.subTotal = this.rows.reduce((acc, obj) => acc + obj.total, 0);
this.tax = (this.subTotal * (this.taxPercentage/100)).toFixed(3);
this.calculateTotal();
},
calculateTotal(){
this.total = parseInt(this.tax) + parseInt(this.subTotal);
},
download(){
window.scrollTo({
top: 0,
behavior: "smooth",
})
setTimeout(function(){
const element = document.getElementById("invoice");
html2pdf().from(element).save("vueInvoice.pdf");
}, 2000);
}
}
});
app.mount('#app')