-
Notifications
You must be signed in to change notification settings - Fork 0
/
invoicer.html
529 lines (512 loc) · 23.7 KB
/
invoicer.html
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/build/pure-min.css" integrity="sha384-X38yfunGUhNzHpBaEBsWLO+A0HDYOQi8ufWDkZ0k9e0eXz/tH3II7uKZ9msv++Ls" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/build/grids-responsive-min.css" />
<style>
@media screen, print {body{background:#E7E8E9;-webkit-print-color-adjust:exact !important;print-color-adjust:exact !important;background-image: linear-gradient(315deg, #B4D4FF 0%, #EEF5FF 74%);}.page-wrapper {margin-left: 50px;margin-right:50px;padding-top: 60px;position: relative;-webkit-transition: all 0.4s ease;-ms-transition: all 0.4s ease;transition: all 0.4s ease;}.card { background: #fff;-webkit-box-shadow: 0 0 13px 0 rgba(82, 63, 105, 0.05);box-shadow: 0 0 13px 0 rgba(82, 63, 105, 0.05);margin: 0 0 24px 0;width: 100%;border: 10px;border-radius: 8px;}.custom-bg{background:#fff; border-radius: 5px;}.custom-spacing{margin:0;padding:.35em 0 .75em .75em}table{width: 100%;}.centerText{text-align: center;}.rightText{text-align: right;}.pure-button-remove,.pure-button-selected,a.pure-button-remove,a.pure-button-selected{background-color:#ff3800;color:#fff}}
</style>
</head>
<body>
<div class="page-wrapper">
<div v-scope>
<!-- Start of form section -->
<div class="pure-g" v-show="!viewPrintable">
<div class="pure-u-1 centerText" ><h1> Invoice Generator</h1></div>
<!--<div class="">-->
<div class="pure-u-1 pure-u-md-1-2 custom-bg"
<legend><h3>Bill From</h3></legend>
<form class="pure-form pure-form-aligned">
<fieldset>
<div class="pure-control-group">
<label for="fromCompanyName">Company/Name:</label>
<input class="pure-input-1-2" type="text" id="fromCompanyName" v-model="formBasicData.fromCompanyName" />
</div>
<div class="pure-control-group">
<label for="fromAddress">Address:</label>
<input class="pure-input-1-2" type="text" id="fromAddress" v-model="formBasicData.fromCompanyAddress" />
</div>
<div class="pure-control-group">
<label for="fromCity">City:</label>
<input class="pure-input-1-2" type="text" id="fromCity" v-model="formBasicData.fromCompanyCity" />
</div>
<div class="pure-control-group">
<label for="fromState">State:</label>
<input class="pure-input-1-2" type="text" id="fromState" v-model="formBasicData.fromCompanyState" />
</div>
<div class="pure-control-group">
<label for="fromZipCode">Zip Code:</label>
<input class="pure-input-1-2" type="text" id="fromZipCode" v-model="formBasicData.fromCompanyZipCode" />
</div>
<div class="pure-control-group">
<label for="fromCountry">Country:</label>
<input class="pure-input-1-2" type="text" id="fromCountry" v-model="formBasicData.fromCompanyCountry" />
</div>
<div class="pure-control-group">
<label for="fromNotes">Notes:</label>
<textarea rows="4" cols="5" class="pure-input-1-2" id="fromNotes" v-model="formBasicData.fromCompanyNotes" placeholder="Enter message"></textarea>
</div>
</fieldset>
</form>
</div>
<div class="pure-u-1 pure-u-md-1-2 custom-bg">
<legend><h3>Bill to</h3></legend>
<form class="pure-form pure-form-aligned">
<fieldset>
<div class="pure-control-group">
<label for="toCompanyName">Company/Name:</label>
<input class="pure-input-1-2" type="text" id="toCompanyName" v-model="formBasicData.toCompanyName" />
</div>
<div class="pure-control-group">
<label for="toAddress">Address:</label>
<input class="pure-input-1-2" type="text" id="toAddress" v-model="formBasicData.toCompanyAddress" />
</div>
<div class="pure-control-group">
<label for="toCity">City:</label>
<input class="pure-input-1-2" type="text" id="toCity" v-model="formBasicData.toCompanyCity" />
</div>
<div class="pure-control-group">
<label for="toState">State:</label>
<input class="pure-input-1-2" type="text" id="toState" v-model="formBasicData.toCompanyState" />
</div>
<div class="pure-control-group">
<label for="toZipCode">Zip Code:</label>
<input class="pure-input-1-2" type="text" id="toZipCode" v-model="formBasicData.toCompanyZipCode" />
</div>
<div class="pure-control-group">
<label for="toCountry">Country:</label>
<input class="pure-input-1-2" type="text" id="toCountry" v-model="formBasicData.toCompanyCountry" />
</div>
<div class="pure-control-group">
<label for="toNotes">Notes:</label>
<textarea rows="4" cols="5" class="pure-input-1-2" id="toNotes" v-model="formBasicData.toCompanyNotes" placeholder="Enter message"></textarea>
</div>
</fieldset>
</form>
</div>
<!--</div> -->
<hr>
<div class="pure-u-1 card">
<form class="pure-form pure-form-aligned">
<fieldset>
<div class="pure-control-group">
<label for="invoiceNumber">Invoice Number:</label>
<input class="pure-input-1-4" type="text" id="invoiceNumber" v-model="formBasicData.invoiceNumber" />
</div>
<div class="pure-control-group">
<label for="issuedDate">Issued Date:</label>
<input type="text" id="issuedDate" v-model="formBasicData.invoiceIssuedDate" placeholder="yyyy-mm-dd"/>
</div>
<div class="pure-control-group">
<label for="dueDate">Due Date:</label>
<input type="text" id="dueDate" v-model="formBasicData.invoiceDueDate" placeholder="yyyy-mm-dd"/>
</div>
</fieldset>
</form>
</div>
<hr>
<div class="pure-u-1 card">
<form class="pure-form pure-form-aligned" @submit.prevent>
<fieldset>
<div class="pure-control-group">
<label for="formItemName">Item Name:</label>
<input type="text" id="formItemName" v-model="formItem.name" />
<label for="description">Description:</label>
<textarea rows="1" cols="20" id="description" v-model="formItem.description" placeholder="Enter message"></textarea>
</div>
<div class="pure-control-group">
<label for="formQuantity">Quantity:</label>
<input type="number" id="formQuantity" v-model="formItem.quantity" min=0 step=1 required/>
<label for="formCostPerItem">Cost Per Item:</label>
<input type="number" id="formCostPerItem" v-model="formItem.cost" min=0 step=0.01 required/>
</div>
<div class="pure-control-group">
<label><button type="submit" @click="addItem(formItem)" id="addItemButton" class="pure-button pure-button-primary" :disabled="!formItem.name || !formItem.quantity || !formItem.cost">Add</button> </label>
</div>
</fieldset>
</form>
</div>
<div class="pure-u-1 card" v-show="showForm">
<table class="custom-bg pure-table pure-table-bordered">
<thead>
<tr>
<th>Name</th>
<th>Description</th>
<th>Qty</th>
<th>Cost Per Item</th>
<th>Remove</th>
</tr>
</thead>
<tbody>
<tr v-for="(item, index) in getInvoiceItems" :key="item.name">
<td>{{item.name}}</td>
<td>{{item.description}}</td>
<td>{{item.quantity}}</td>
<td>{{item.cost}}</td>
<td><button class="pure-button pure-button-remove" type="submit" @click="removeItem(index)" id="removeItemButton" class="pure-button pure-button-error" >Remove</button></td>
</tr>
</tbody>
</table>
</div>
<div class="pure-u-1 pure-u-md-1-2 custom-bg">
<form class="pure-form pure-form-aligned">
<fieldset>
<div class="pure-control-group">
<label for="subtotal">Subtotal:</label>
<label id="subtotal">{{chosenCurrency}} : {{addSubtotal}}</label>
</div>
<div class="pure-control-group">
<label for="tax">Include Tax %:</label>
<input v-show="taxSelectchecked" type="number" id="tax" v-model="taxValue" min=0 max=100/>
<input type="checkbox" v-model="taxSelectchecked"></input>
</div>
<div class="pure-control-group">
<label for="discount">Discount %:</label>
<input type="number" id="discount" v-model="discountPercent" min=0 max=100/>
</div>
<div class="pure-control-group">
<label for="shipping">Shipping:</label>
<input type="number" id="shipping" v-model="shippingCost" min=0 max=100000/>
</div>
<div class="pure-control-group">
<label for="total">Total:</label>
<label for="total">{{chosenCurrency}} : {{addTotal}}</label>
</div>
</fieldset>
</form>
</div>
<div class="pure-u-1 pure-u-md-1-2 custom-bg">
<form class="pure-form pure-form-aligned">
<fieldset>
<div class="pure-control-group">
<label for="currency">Select Currency:</label>
<select id="currency" v-model="chosenCurrency" >
<option value="AED">AED - UAE Dirham</option>
<option value="AFN">AFN - Afghani</option>
<option value="ALL">ALL - Lek</option>
<option value="AMD">AMD - Armenian Dram</option>
<option value="ANG">ANG - Netherlands Antillean Guilder</option>
<option value="AOA">AOA - Kwanza</option>
<option value="ARS">ARS - Argentine Peso</option>
<option value="AUD">AUD - Australian Dollar</option>
<option value="AWG">AWG - Aruban Florin</option>
<option value="AZN">AZN - Azerbaijanian Manat</option>
<option value="BAM">BAM - Convertible Mark</option>
<option value="BBD">BBD - Barbados Dollar</option>
<option value="BDT">BDT - Taka</option>
<option value="BGN">BGN - Bulgarian Lev</option>
<option value="BHD">BHD - Bahraini Dinar</option>
<option value="BIF">BIF - Burundi Franc</option>
<option value="BMD">BMD - Bermudian Dollar</option>
<option value="BND">BND - Brunei Dollar</option>
<option value="BOB">BOB - Boliviano</option>
<option value="BRL">BRL - Brazilian Real</option>
<option value="BSD">BSD - Bahamian Dollar</option>
<option value="BWP">BWP - Pula</option>
<option value="BYR">BYR - Belarussian Ruble</option>
<option value="BZD">BZD - Belize Dollar</option>
<option value="CAD">CAD - Canadian Dollar</option>
<option value="CHF">CHF - Swiss Franc</option>
<option value="CLP">CLP - Chilean Peso</option>
<option value="CNY">CNY - Yuan Renminbi</option>
<option value="COP">COP - Colombian Peso</option>
<option value="CRC">CRC - Costa Rican Colon</option>
<option value="CUP">CUP - Cuban Peso</option>
<option value="CVE">CVE - Cabo Verde Escudo</option>
<option value="CZK">CZK - Czech Koruna</option>
<option value="DJF">DJF - Djibouti Franc</option>
<option value="DKK">DKK - Danish Krone</option>
<option value="DOP">DOP - Dominican Peso</option>
<option value="DZD">DZD - Algerian Dinar</option>
<option value="EGP">EGP - Egyptian Pound</option>
<option value="ERN">ERN - Nakfa</option>
<option value="ETB">ETB - Ethiopian Birr</option>
<option value="EUR">EUR - Euro</option>
<option value="FJD">FJD - Fiji Dollar</option>
<option value="FKP">FKP - Falkland Islands Pound</option>
<option value="GBP">GBP - Pound Sterling</option>
<option value="GEL">GEL - Lari</option>
<option value="GHS">GHS - Ghana Cedi</option>
<option value="GIP">GIP - Gibraltar Pound</option>
<option value="GMD">GMD - Dalasi</option>
<option value="GNF">GNF - Guinea Franc</option>
<option value="GTQ">GTQ - Quetzal</option>
<option value="GYD">GYD - Guyana Dollar</option>
<option value="HKD">HKD - Hong Kong Dollar</option>
<option value="HNL">HNL - Lempira</option>
<option value="HRK">HRK - Croatian Kuna</option>
<option value="HUF">HUF - Forint</option>
<option value="IDR">IDR - Rupiah</option>
<option value="ILS">ILS - New Israeli Sheqel</option>
<option value="INR">INR - Indian Rupee</option>
<option value="IQD">IQD - Iraqi Dinar</option>
<option value="IRR">IRR - Iranian Rial</option>
<option value="ISK">ISK - Iceland Krona</option>
<option value="JMD">JMD - Jamaican Dollar</option>
<option value="JOD">JOD - Jordanian Dinar</option>
<option value="JPY">JPY - Yen</option>
<option value="KES">KES - Kenyan Shilling</option>
<option value="KGS">KGS - Som</option>
<option value="KHR">KHR - Riel</option>
<option value="KMF">KMF - Comoro Franc</option>
<option value="KPW">KPW - North Korean Won</option>
<option value="KRW">KRW - Won</option>
<option value="KWD">KWD - Kuwaiti Dinar</option>
<option value="KYD">KYD - Cayman Islands Dollar</option>
<option value="KZT">KZT - Tenge</option>
<option value="LAK">LAK - Kip</option>
<option value="LBP">LBP - Lebanese Pound</option>
<option value="LKR">LKR - Sri Lanka Rupee</option>
<option value="LRD">LRD - Liberian Dollar</option>
<option value="LYD">LYD - Libyan Dinar</option>
<option value="MAD">MAD - Moroccan Dirham</option>
<option value="MDL">MDL - Moldovan Leu</option>
<option value="MGA">MGA - Malagasy Ariary</option>
<option value="MKD">MKD - Denar</option>
<option value="MMK">MMK - Kyat</option>
<option value="MNT">MNT - Tugrik</option>
<option value="MOP">MOP - Pataca</option>
<option value="MRO">MRO - Ouguiya</option>
<option value="MUR">MUR - Mauritius Rupee</option>
<option value="MVR">MVR - Rufiyaa</option>
<option value="MWK">MWK - Kwacha</option>
<option value="MXN">MXN - Mexican Peso</option>
<option value="MYR">MYR - Malaysian Ringgit</option>
<option value="MZN">MZN - Mozambique Metical</option>
<option value="NGN">NGN - Naira</option>
<option value="NIO">NIO - Cordoba Oro</option>
<option value="NOK">NOK - Norwegian Krone</option>
<option value="NPR">NPR - Nepalese Rupee</option>
<option value="NZD">NZD - New Zealand Dollar</option>
<option value="OMR">OMR - Rial Omani</option>
<option value="PEN">PEN - Nuevo Sol</option>
<option value="PGK">PGK - Kina</option>
<option value="PHP">PHP - Philippine Peso</option>
<option value="PKR">PKR - Pakistan Rupee</option>
<option value="PLN">PLN - Zloty</option>
<option value="PYG">PYG - Guarani</option>
<option value="QAR">QAR - Qatari Rial</option>
<option value="RON">RON - New Romanian Leu</option>
<option value="RSD">RSD - Serbian Dinar</option>
<option value="RUB">RUB - Russian Ruble</option>
<option value="RWF">RWF - Rwanda Franc</option>
<option value="SAR">SAR - Saudi Riyal</option>
<option value="SBD">SBD - Solomon Islands Dollar</option>
<option value="SCR">SCR - Seychelles Rupee</option>
<option value="SDG">SDG - Sudanese Pound</option>
<option value="SEK">SEK - Swedish Krona</option>
<option value="SGD">SGD - Singapore Dollar</option>
<option value="SHP">SHP - Saint Helena Pound</option>
<option value="SLL">SLL - Leone</option>
<option value="SOS">SOS - Somali Shilling</option>
<option value="SRD">SRD - Surinam Dollar</option>
<option value="SSP">SSP - South Sudanese Pound</option>
<option value="STD">STD - Dobra</option>
<option value="SYP">SYP - Syrian Pound</option>
<option value="SZL">SZL - Lilangeni</option>
<option value="THB">THB - Baht</option>
<option value="TJS">TJS - Somoni</option>
<option value="TMT">TMT - Turkmenistan New Manat</option>
<option value="TND">TND - Tunisian Dinar</option>
<option value="TOP">TOP - Pa’anga</option>
<option value="TRY">TRY - Turkish Lira</option>
<option value="TTD">TTD - Trinidad and Tobago Dollar</option>
<option value="TWD">TWD - New Taiwan Dollar</option>
<option value="TZS">TZS - Tanzanian Shilling</option>
<option value="UAH">UAH - Hryvnia</option>
<option value="UGX">UGX - Uganda Shilling</option>
<option value="USD">USD - US Dollar</option>
<option value="UYU">UYU - Peso Uruguayo</option>
<option value="UZS">UZS - Uzbekistan Sum</option>
<option value="VEF">VEF - Bolivar</option>
<option value="VND">VND - Dong</option>
<option value="VUV">VUV - Vatu</option>
<option value="WST">WST - Tala</option>
<option value="XAF">XAF - CFA Franc BEAC</option>
<option value="XCD">XCD - East Caribbean Dollar</option>
<option value="XOF">XOF - CFA Franc BCEAO</option>
<option value="XPF">XPF - CFP Franc</option>
<option value="YER">YER - Yemeni Rial</option>
<option value="ZAR">ZAR - Rand</option>
<option value="ZMW">ZMW - Zambian Kwacha</option>
<option value="ZWL">ZWL - Zimbabwe Dollar</option>
</select>
</div>
</fieldset>
</form>
</div>
<div class="pure-u-1 custom-bg">
<form class="pure-form pure-form-aligned" @submit.prevent>
<div class="pure-control-group">
<label><button type="submit" @click="showPrintableForm()" id="removeItemButton" class="pure-button pure-button-primary" >Print Invoice</button></label>
</div>
</form>
</div>
</div>
<!-- End form section -->
<!-- Start print view for form section -->
<div class="pure-g" v-show="viewPrintable">
<div class="pure-u-1 custom-bg"><h2> Invoice : {{formBasicData.invoiceNumber}}</h2><h3> Issued Date: {{formBasicData.invoiceIssuedDate}} </h3> <h3>Due Date: {{formBasicData.invoiceDueDate}}</h3></div>
<table class="custom-bg pure-table">
<thead>
<tr>
<th>Bill From</th>
<th>Bill To</th>
</tr>
</thead>
<tbody>
<tr>
<td>{{formBasicData.fromCompanyName}}</td>
<td>{{formBasicData.toCompanyName}}</td>
</tr>
<tr>
<td>{{formBasicData.fromCompanyAddress}}</td>
<td>{{formBasicData.toCompanyAddress}}</td>
</tr>
<tr>
<td>{{formBasicData.fromCompanyCity}}, {{formBasicData.fromCompanyState}}, {{formBasicData.fromCompanyZipCode}}, {{formBasicData.fromCompanyCountry}}</td>
<td>{{formBasicData.toCompanyCity}}, {{formBasicData.toCompanyState}}, {{formBasicData.toCompanyZipCode}}, {{formBasicData.toCompanyCountry}}</td>
</tr>
<tr>
<td>{{formBasicData.fromCompanyNotes}}</td>
<td>{{formBasicData.toCompanyNotes}}</td>
</tr>
</tbody>
</table>
</div>
<div v-show="viewPrintable">
<div class="pure-u-1 custom-bg"><h4> Items </h4></div>
<table class="custom-bg pure-table pure-table-bordered">
<thead>
<tr>
<th>Name</th>
<th>Description</th>
<th>Qty</th>
<th>Cost Per Item</th>
<th>Total</th>
</tr>
</thead>
<tbody>
<tr v-for="item in invoiceItems">
<td>{{item.name}}</td>
<td>{{item.description}}</td>
<td>{{item.quantity}}</td>
<td>{{item.cost}}</td>
<td>{{item.cost * item.quantity}}</td>
</tr>
<tr>
<td colspan="4"></td>
<td>
<b>Subtotal - {{chosenCurrency}}</b>: {{formTally.addSubtotal}} <br /><br />
<b>Tax </b>: {{formTally.percentTax}} %<br /><br />
<b>Discount </b>: {{formTally.discountPercent}} %<br /><br />
<b>Shipping - {{chosenCurrency}}</b>: {{formTally.shippingCost}}<br /><br />
<b>Total - {{chosenCurrency}}</b>: {{addTotal}}<br />
</td>
</tr>
</tbody>
</table>
</div>
<!-- End printable view for form section -->
</div>
</div>
<script src="https://unpkg.com/[email protected]/dist/petite-vue.iife.js"></script>
<script>
PetiteVue
.createApp({
viewPrintable: false,
calcSubtotal: 0,
chosenCurrency:"USD",
formItem:{
name: null,
description: null,
},
invoiceItems:[],
taxSelectchecked: false,
formBasicData:{
fromCompanyName: null,
fromCompanyAddress: null,
fromCompanyCity: null,
fromCompanyState: null,
fromCompanyZipCode: null,
fromCompanyCountry: null,
fromCompanyNotes: null,
toCompanyName: null,
toCompanyAddress: null,
toCompanyCity: null,
toCompanyState: null,
toCompanyZipCode: null,
toCompanyCountry: null,
toCompanyNotes: null,
invoiceNumber: null,
invoiceIssuedDate: null,
invoiceDueDate: null,
},
formTally: [],
taxValue: 0,
discountPercent: 0,
shippingCost:0,
get addSubtotal(){
this.formTally["addSubtotal"] = parseFloat(this.calcSubtotal).toFixed(2);
return parseFloat(this.calcSubtotal).toFixed(2);
},
get addTotal(){
let finalvalue = 0;
if(this.taxValue != 0 && this.taxSelectchecked){
if(this.discountPercent != 0){
this.formTally["discountPercent"] = this.discountPercent;
this.finalvalue = (this.calcSubtotal * (1 - (this.discountPercent/100)) ) * (1 + ( this.taxValue/100)) + this.shippingCost;
}
else{
this.finalvalue = this.calcSubtotal * (1 + ( this.taxValue/100)) + this.shippingCost;
}
this.formTally["percentTax"] = this.taxValue;
this.formTally["shippingCost"] = this.shippingCost;
this.formTally["addTotal"] = parseFloat(this.finalvalue).toFixed(2);
return parseFloat(this.finalvalue).toFixed(2);
}else{
this.formTally["percentTax"] = this.taxValue;
if(this.discountPercent != 0){
this.finalvalue = this.calcSubtotal * (1 - (this.discountPercent/100)) + this.shippingCost;
this.formTally["addTotal"] = parseFloat(this.finalvalue).toFixed(2);
this.formTally["discountPercent"] = this.discountPercent;
this.formTally["shippingCost"] = this.shippingCost;
return parseFloat(this.finalvalue).toFixed(2);
}else{
this.formTally["addTotal"] = parseFloat(this.finalvalue).toFixed(2);
this.formTally["discountPercent"] = 0
this.formTally["shippingCost"] = this.shippingCost;
return parseFloat(this.calcSubtotal + this.shippingCost).toFixed(2);
}
}
},
addItem(items){
const newItem = { ...items};
this.invoiceItems.push(newItem);
this.calcSubtotal = this.calcSubtotal + (newItem.quantity * newItem.cost);
this.formItem = {
name: null,
description: null,
};
},
removeItem(itemIndex){
this.calcSubtotal = this.calcSubtotal - (this.invoiceItems[itemIndex].quantity * this.invoiceItems[itemIndex].cost);
this.invoiceItems.splice(itemIndex, 1);
},
get showForm(){
if(this.invoiceItems.length != 0){
return true;
}
},
get getInvoiceItems(){
return this.invoiceItems;
},
showPrintableForm(){
this.viewPrintable = true;
}
}).mount()
</script>
</body>
</html>