Blame view

src/pages/Account/invoice.vue 30 KB
687e0b929   Neeraj Sharma   add user,attenden...
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
  <template>
    <v-app id="pages-dasboard">
      <v-tabs grow slider-color="gray">
        <v-tab
          ripple
          @click="activeTab('existing')"
          v-bind:class="{ active: isActive }"
          id="tab"
          class="subheading"
        >Existing Invoice</v-tab>
        <v-tab
          ripple
          @click="activeTab('new')"
          v-bind:class="{ active: newActive }"
          id="tab1"
          User
          class="subheading"
        >Add New Invoice</v-tab>
  
        <!-- ****** EDIT  SECTION  ****** -->
        <v-tab-item>
          <!-- ****** PROFILE VIEW SECTION DATA ******  -->
          <v-dialog v-model="dialog1" max-width="600px">
            <v-toolbar color="grey lighten-2">
              <v-spacer></v-spacer>
              <v-toolbar-title>
                <h3>Invoice</h3>
              </v-toolbar-title>
              <v-spacer></v-spacer>
              <v-icon @click="close1">close</v-icon>
            </v-toolbar>
            <v-card>
              <v-flex align-center justify-center layout text-xs-center>
                <v-avatar size="50px" style="position:absolute; top:20px;">
                  <img src="/static/icon/user.png" />
                </v-avatar>
              </v-flex>
              <v-card-text>
                <v-container grid-list-md>
                  <v-layout wrap>
                    <v-flex>
                      <br />
                      <br />
                      <v-layout>
                        <v-flex xs5 sm6>
                          <h5 class="right my-1">
                            <b>Class Name:</b>
                          </h5>
                        </v-flex>
                        <v-flex sm6 xs8>
                          <!-- <h5 class="my-1">{{ editedItem.classData.classNum }}</h5> -->
                        </v-flex>
                      </v-layout>
                      <v-layout>
                        <v-flex xs5 sm6>
                          <h5 class="right my-1">
                            <b>Name:</b>
                          </h5>
                        </v-flex>
                        <v-flex sm6 xs8>
                          <h5 class="my-1">{{ editedItem.name }}</h5>
                        </v-flex>
                      </v-layout>
                      <v-layout>
                        <v-flex xs5 sm6>
                          <h5 class="right my-1">
                            <b>Class Incharge:</b>
                          </h5>
                        </v-flex>
                        <v-flex sm6 xs8>
                          <h5 class="my-1">{{ editedItem.name }}</h5>
                        </v-flex>
                      </v-layout>
                      <v-layout>
                        <v-flex xs5 sm6>
                          <h5 class="right my-1">
                            <b>Session:</b>
                          </h5>
                        </v-flex>
                        <v-flex sm6 xs8>
                          <h5 class="my-1">{{ editedItem.paymentStatus }}</h5>
                        </v-flex>
                      </v-layout>
                    </v-flex>
                  </v-layout>
                </v-container>
              </v-card-text>
            </v-card>
          </v-dialog>
          <!-- ****** EXISTING-USERS StudentS Table ****** -->
          <v-data-table
            :headers="headers"
            :items="invoiceList"
            :pagination.sync="pagination"
            :search="search"
          >
            <template slot="items" slot-scope="props">
              <td id="td" class="text-xs-center">{{ props.index + 1 }}</td>
              <td id="td" class="text-xs-center">{{ props.item.studentId.name }}</td>
              <td id="td" class="text-xs-center">{{ props.item.classId.classNum }}</td>
              <td id="td" class="text-xs-center">{{ props.item.totalAmount }}</td>
              <td
                id="td"
                class="text-xs-center"
              >{{ props.item.totalAmount - props.item.totalSubTotal }}</td>
              <td
                id="td"
                class="text-xs-center"
              >{{ props.item.totalPaidAmount ? props.item.totalPaidAmount : 0}}</td>
              <td
                id="td"
                class="text-xs-center"
              >{{ props.item.totalPaidAmount ? props.item.totalSubTotal - props.item.totalPaidAmount : props.item.totalSubTotal }}</td>
              <td id="td" class="text-xs-center" v-if="props.item.paymentStatus === 'NOT_PAID'">
                <span
                  class="red lighten-1 pa-2 white--text paymentStatus"
                >{{ props.item.paymentStatus }}</span>
              </td>
d9bb52b5b   Neeraj Sharma   implement trello ...
119
              <td id="td" class="text-xs-center" v-if="props.item.paymentStatus === 'FULLY_PAID'">
687e0b929   Neeraj Sharma   add user,attenden...
120
121
122
123
                <span
                  class="green lighten-1 pa-2 white--text paymentStatus"
                >{{ props.item.paymentStatus }}</span>
              </td>
d9bb52b5b   Neeraj Sharma   implement trello ...
124
125
126
127
128
              <td id="td" class="text-xs-center" v-if="props.item.paymentStatus === 'PARTIALLY_PAID'">
                <span
                  class="yellow darken-3 pa-2 white--text paymentStatus"
                >{{ props.item.paymentStatus }}</span>
              </td>
687e0b929   Neeraj Sharma   add user,attenden...
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
              <td id="td" class="text-xs-center">{{ dates(props.item.date) }}</td>
              <td>
                <router-link :to="{ name:'ViewInvoice',params: { viewInvoiceId:props.item._id } }">
                  <v-tooltip top>
                    <img
                      slot="activator"
                      style="cursor:pointer; width:25px; height:18px; "
                      class="mr-5"
                      src="/static/icon/eye1.png"
                    />
                    <span>View</span>
                  </v-tooltip>
                </router-link>
                <span v-if="props.item.paymentStatus === 'NOT_PAID'">
                  <router-link :to="{ name:'EditInvoice',params: { invoiceid:props.item._id }}" exact>
                    <v-tooltip top>
                      <img
                        slot="activator"
                        style="cursor:pointer; width:20px; height:18px; "
                        class="mr-5"
                        src="/static/icon/edit1.png"
                      />
                      <span>Edit</span>
                    </v-tooltip>
                  </router-link>
                  <v-tooltip top>
                    <img
                      slot="activator"
                      style="cursor:pointer;width:20px; height:20px; "
                      class="mr-5"
                      @click="deleteItem(props.item)"
                      src="/static/icon/delete1.png"
                    />
                    <span>Delete</span>
                  </v-tooltip>
                </span>
              </td>
            </template>
            <v-alert
              slot="no-results"
              :value="true"
              color="error"
              icon="warning"
            >Your search for "{{ search }}" found no results.</v-alert>
          </v-data-table>
        </v-tab-item>
        <!-- ****** ADD multiple INVOICE ****** -->
        <v-tab-item>
          <v-container fluid grid-list-md>
            <v-snackbar
              :timeout="timeout"
              :top="y === 'top'"
              :right="x === 'right'"
              :vertical="mode === 'vertical'"
              v-model="snackbar"
d9bb52b5b   Neeraj Sharma   implement trello ...
184
              :color="color"
687e0b929   Neeraj Sharma   add user,attenden...
185
186
187
            >{{ text }}</v-snackbar>
            <v-flex xs12 sm12>
              <v-container fluid>
f4df757fe   Neeraj Sharma   responsive vie in...
188
                <v-layout wrap>
687e0b929   Neeraj Sharma   add user,attenden...
189
190
191
192
193
194
195
196
197
198
199
200
                  <v-flex xs12 sm12 md5 class="mt-4">
                    <v-card flat>
                      <v-toolbar dark class="fixcolors" flat>
                        <v-spacer></v-spacer>
                        <v-toolbar-title>
                          <h3>Invoice</h3>
                        </v-toolbar-title>
                        <v-spacer></v-spacer>
                      </v-toolbar>
                      <v-form ref="form" v-model="valid" lazy-validation class="py-4">
                        <v-layout>
                          <v-flex xs4 class="pt-4 subheading">
f4df757fe   Neeraj Sharma   responsive vie in...
201
202
                            <label class="right hidden-xs-only hidden-sm-only">Select Class:</label>
                            <label class="right hidden-lg-only hidden-md-only hidden-xl-only">Class:</label>
687e0b929   Neeraj Sharma   add user,attenden...
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
                          </v-flex>
                          <v-flex xs6 class="ml-3">
                            <v-select
                              :items="addclass"
                              label="Select Class"
                              v-model="invoiceData.classNum"
                              item-text="classNum"
                              item-value="_id"
                              @change="getAllStudents()"
                              :rules="classRules"
                              required
                            ></v-select>
                          </v-flex>
                        </v-layout>
                        <v-layout>
                          <v-flex xs4 class="pt-4 subheading">
f4df757fe   Neeraj Sharma   responsive vie in...
219
220
                            <label class="right hidden-xs-only hidden-sm-only">Select Student:</label>
                            <label class="right hidden-lg-only hidden-md-only hidden-xl-only">Student:</label>
687e0b929   Neeraj Sharma   add user,attenden...
221
222
223
224
                          </v-flex>
                          <v-flex xs6 class="ml-3">
                            <v-select
                              :items="studentList"
d45ffc6fa   Neeraj Sharma   solve bugs and ad...
225
226
                              label="Select Student"
                              v-model="invoiceData.studentId"
687e0b929   Neeraj Sharma   add user,attenden...
227
228
229
                              item-text="name"
                              item-value="_id"
                              :rules="inchargeRules"
d45ffc6fa   Neeraj Sharma   solve bugs and ad...
230
                              @change="selectAllStudent()"
687e0b929   Neeraj Sharma   add user,attenden...
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
                              required
                            ></v-select>
                          </v-flex>
                        </v-layout>
                        <v-layout>
                          <v-flex xs4 class="pt-4 subheading">
                            <label class="right">Date:</label>
                          </v-flex>
                          <v-flex xs6 class="ml-3">
                            <v-menu
                              ref="menu1"
                              :close-on-content-click="false"
                              v-model="menu1"
                              :nudge-right="40"
                              lazy
                              :return-value.sync="invoiceData.date"
                              transition="scale-transition"
                              offset-y
                              full-width
                              min-width="290px"
                            >
                              <v-text-field
                                slot="activator"
                                :rules="dateRules"
                                v-model="invoiceData.date"
                                placeholder="Select date"
                              ></v-text-field>
                              <v-date-picker
                                v-model="invoiceData.date"
                                @input="$refs.menu1.save(invoiceData.date)"
                              ></v-date-picker>
                            </v-menu>
                          </v-flex>
                        </v-layout>
                        <v-layout>
                          <v-flex xs4 class="pt-4 subheading">
f4df757fe   Neeraj Sharma   responsive vie in...
267
268
                            <label class="right hidden-xs-only hidden-sm-only">Payment Status:</label>
                            <label class="right hidden-lg-only hidden-md-only hidden-xl-only">Payment:</label>
687e0b929   Neeraj Sharma   add user,attenden...
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
                          </v-flex>
                          <v-flex xs6 class="ml-3">
                            <v-select
                              :items="paymentStatus"
                              v-model="invoiceData.paymentStatus"
                              item-text="name"
                              item-value="value"
                              label="Select Payment Status"
                              @change="getPayMethodList"
                              :rules="paymentStatusRules"
                              required
                            ></v-select>
                          </v-flex>
                        </v-layout>
                        <v-layout v-show="showPayMethods">
                          <v-flex xs4 class="pt-4 subheading">
                            <label class="right">Payment Method:</label>
                          </v-flex>
                          <v-flex xs6 class="ml-3">
                            <v-select
                              :items="paymentMethods"
                              v-model="invoiceData.paymentMethod"
                              label="Select Payment Method"
                              required
                            ></v-select>
                          </v-flex>
                        </v-layout>
                        <v-layout>
                          <v-flex xs12 sm10 offset-sm1>
                            <v-card-actions>
                              <v-btn @click="clear" round dark>clear</v-btn>
                              <v-spacer></v-spacer>
                              <v-btn @click="submit" round dark :loading="loading">Add</v-btn>
                            </v-card-actions>
                          </v-flex>
                        </v-layout>
                      </v-form>
                    </v-card>
                  </v-flex>
                  <v-flex xs12 sm12 md7 class="mt-4">
                    <v-card>
                      <v-toolbar dark class="fixcolors" flat>
                        <v-spacer></v-spacer>
                        <v-toolbar-title>
                          <h3>Fee Type List</h3>
                        </v-toolbar-title>
                        <v-spacer></v-spacer>
                      </v-toolbar>
                      <v-layout>
f4df757fe   Neeraj Sharma   responsive vie in...
318
                        <v-flex xs4 sm2 class="mt-4">
687e0b929   Neeraj Sharma   add user,attenden...
319
320
                          <label class="right title">Fee Type:</label>
                        </v-flex>
f4df757fe   Neeraj Sharma   responsive vie in...
321
                        <v-flex xs4 sm4>
687e0b929   Neeraj Sharma   add user,attenden...
322
323
324
325
326
327
328
329
                          <v-select
                            :items="feeTypes"
                            v-model="feeType.feeTypeName"
                            item-text="feeType"
                            item-value="feeType"
                            label="Select Fee Type"
                          ></v-select>
                        </v-flex>
f4df757fe   Neeraj Sharma   responsive vie in...
330
                        <v-flex xs4 sm6>
687e0b929   Neeraj Sharma   add user,attenden...
331
332
333
                          <v-btn color="black" dark class="right mt-3" @click="selectFeeType">ADD</v-btn>
                        </v-flex>
                      </v-layout>
f4df757fe   Neeraj Sharma   responsive vie in...
334
                      <table class="feeTypeTable tableRsponsive">
687e0b929   Neeraj Sharma   add user,attenden...
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
                        <tr class="info white--text">
                          <th>#</th>
                          <th>Fee Type</th>
                          <th>Amount</th>
                          <th>Discount(%)</th>
                          <th>Subtotal</th>
                          <th>Paid Amount</th>
                          <th>Action</th>
                        </tr>
                        <tr
                          v-show="showFeeType"
                          v-for="(feeType, index) in feeTypeData"
                          :key="index"
                          v-on:keyup="getAmmountDetails(feeType)"
                        >
                          <td style="width:40px">{{ index + 1 }}</td>
                          <td style="width:120px">{{ feeType.feeTypeName }}</td>
                          <td>
                            <v-text-field
                              placeholder="fill your Amount"
                              v-model="feeType.amount"
                              type="number"
                            ></v-text-field>
                          </td>
                          <td>
                            <v-text-field
                              placeholder="fill your Discount"
                              v-model="feeType.discount"
                              type="number"
                            ></v-text-field>
                          </td>
                          <td>{{ feeType.subTotal }}</td>
                          <td v-if="invoiceData.paymentStatus === 'NOT_PAID'">
                            <v-text-field
                              placeholder="fill your Paid Amount"
                              v-model="feeType.paidAmount"
                              type="number"
                              :disabled="disabled"
                            ></v-text-field>
                          </td>
                          <td v-if="invoiceData.paymentStatus == ''">
                            <v-text-field
                              placeholder="fill your Paid Amount"
                              v-model="feeType.paidAmount"
                              type="number"
                              :disabled="disabled"
                            ></v-text-field>
                          </td>
                          <td
                            v-if="invoiceData.paymentStatus != 'NOT_PAID' && invoiceData.paymentStatus != ''"
                          >
                            <v-text-field
                              placeholder="fill your Paid Amount"
                              v-model="feeType.paidAmount"
                              type="number"
                            ></v-text-field>
                          </td>
                          <td>
                            <v-icon color="error" @click="deleteSelectFee(index)">delete</v-icon>
                          </td>
                        </tr>
                        <tfoot>
                          <tr>
                            <td colspan="2">Total:</td>
                            <td>{{ feeType.amount }}</td>
                            <td>{{ feeType.discount }}</td>
                            <td>{{ feeType.subTotal }}</td>
                            <td>{{ feeType.paidAmount }}</td>
                          </tr>
                        </tfoot>
                      </table>
                    </v-card>
                  </v-flex>
                </v-layout>
              </v-container>
            </v-flex>
          </v-container>
        </v-tab-item>
      </v-tabs>
      <div class="loader" v-if="showLoader">
        <v-progress-circular indeterminate color="white"></v-progress-circular>
      </div>
    </v-app>
  </template>
  
  <script>
  import http from "@/Services/http.js";
  import Util from "@/util";
  import moment from "moment";
  
  export default {
    data: () => ({
      snackbar: false,
      showPayMethods: false,
      y: "top",
      x: "right",
      mode: "",
d9bb52b5b   Neeraj Sharma   implement trello ...
432
      timeout: 5000,
687e0b929   Neeraj Sharma   add user,attenden...
433
      text: "",
d9bb52b5b   Neeraj Sharma   implement trello ...
434
      color: "",
687e0b929   Neeraj Sharma   add user,attenden...
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
      showLoader: false,
      loading: false,
      date: null,
      search: "",
      dialog: false,
      dialog1: false,
      valid: true,
      validEdit: true,
      isActive: true,
      newActive: false,
      showFeeType: false,
      disabled: true,
      details: [],
      feeTypes: [],
      menu1: false,
      paymentMethods: ["Cash", "Cheque"],
      feeType: {
        amount: "0.00",
        discount: "0.00",
        paidAmount: 0.0,
        subTotal: "0.00",
        feeTypeName: ""
      },
      feeTypeData: [],
      pagination: {
        rowsPerPage: 15
      },
      classRules: [v => !!v || " Class Name is required"],
      inchargeRules: [v => !!v || "Student Name is required"],
      dateRules: [v => !!v || " Date is required"],
      paymentStatusRules: [v => !!v || "Payment Status is required"],
6ae46ca27   Neeraj Sharma   implement upload ...
466
      paymentMethodsRules: [v => !!v || "payment Method is required"],
687e0b929   Neeraj Sharma   add user,attenden...
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
      headers: [
        {
          text: "No",
          align: "center",
          sortable: false,
          value: "No"
        },
        {
          text: "Student",
          value: "student",
          sortable: false,
          align: "center"
        },
        { text: "Class", value: "class", sortable: false, align: "center" },
        { text: "Total", value: "subtotal", sortable: false, align: "center" },
        { text: "Discount", value: "discount", sortable: false, align: "center" },
        {
          text: "Paid Amount",
          value: "paidAmount",
          sortable: false,
          align: "center"
        },
        {
          text: "Balance",
          value: "Balance",
          sortable: false,
          align: "center"
        },
        {
          text: "Status",
          value: "paymentStatus",
          sortable: false,
          align: "center"
        },
        {
          text: "Date",
          value: "date",
          sortable: false,
          align: "center"
        },
        { text: "Action", value: "", sortable: false, align: "center" }
      ],
      invoiceList: [],
      token: "",
      editedItem: {},
      invoiceData: {
d45ffc6fa   Neeraj Sharma   solve bugs and ad...
513
514
        paymentStatus: "",
        students: []
687e0b929   Neeraj Sharma   add user,attenden...
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
      },
      addclass: [],
      studentList: [],
      paymentStatus: [
        {
          name: "Not Paid",
          value: "NOT_PAID"
        },
        {
          name: "Partially Paid",
          value: "PARTIALLY_PAID"
        },
        {
          name: "Fully Paid",
          value: "FULLY_PAID"
        }
      ]
    }),
    methods: {
      save(date) {
        this.$refs.menu1.save(date);
      },
      dates: function(date) {
        return moment(date).format("MMMM DD, YYYY");
      },
      // profile(item) {
      //   this.editedIndex = this.InvoiceList.indexOf(item);
      //   this.editedItem = Object.assign({}, item);
      //   this.dialog1 = true;
      // },
      deleteItem(item) {
        let deleteInvoice = {
          invoiceId: item._id
        };
        http()
          .delete(
            "/deleteInvoice",
            confirm("Are you sure you want to delete this?") && {
              params: deleteInvoice
            }
          )
          .then(response => {
d9bb52b5b   Neeraj Sharma   implement trello ...
557
558
559
            this.snackbar = true;
            this.text = "Successfully delete Existing Invoice";
            this.color = "green";
687e0b929   Neeraj Sharma   add user,attenden...
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
            this.getInvoiceList();
          })
          .catch(error => {
            // console.log(error);
          });
      },
      activeTab(type) {
        switch (type) {
          case "existing":
            this.newActive = false;
            this.isActive = true;
            break;
  
          default:
            this.newActive = true;
            this.isActive = false;
            break;
        }
      },
      close() {
        this.dialog = false;
        setTimeout(() => {
          this.editedItem = Object.assign({}, this.defaultItem);
          this.editedIndex = -1;
        }, 300);
      },
      close1() {
        this.dialog1 = false;
      },
d9bb52b5b   Neeraj Sharma   implement trello ...
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
      // totalAmount() {
      //   // console.log("this.feeType.paidAmount ", this.feeType.paidAmount);
      //   // console.log(
      //   //   "this.feeType.subTotalAAAAAAAAAAAAAAA ",
      //   //   this.feeType.subTotal
      //   // );
  
      //   if (this.feeType.paidAmount < this.feeType.subTotal) {
      //     console.log("this.feeType.subTotalBBBBBBBBBBB ", this.feeType.subTotal);
  
      //     this.feeType.paidAmount = this.feeType.subTotal;
      //     console.log(
      //       "this.feeType.paidAmount BBBBBBBBBBB",
      //       this.feeType.paidAmount
      //     );
      //   }
      // },
687e0b929   Neeraj Sharma   add user,attenden...
606
607
608
609
610
611
612
613
      submit() {
        let feeTypeId = "";
        for (let i = 0; i < this.feeTypes.length; i++) {
          if (this.feeTypes[i].feeType === this.feeType.feeTypeName) {
            feeTypeId = this.feeTypes[i]._id;
          }
        }
        if (this.$refs.form.validate()) {
d45ffc6fa   Neeraj Sharma   solve bugs and ad...
614
          console.log("this.invoiceData.students", this.invoiceData.students);
687e0b929   Neeraj Sharma   add user,attenden...
615
616
          let invoiceData = {
            classId: this.invoiceData.classNum,
d45ffc6fa   Neeraj Sharma   solve bugs and ad...
617
            students: this.invoiceData.students,
687e0b929   Neeraj Sharma   add user,attenden...
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
            date: this.invoiceData.date,
            paymentStatus: this.invoiceData.paymentStatus,
            paymentMethod: this.invoiceData.paymentMethod,
            feeType: this.feeTypeData,
            totalAmount: this.feeType.amount,
            totalDiscount: this.feeType.discount,
            totalSubTotal: this.feeType.subTotal,
            totalPaidAmount: this.feeType.paidAmount
          };
          if (invoiceData.paymentStatus == "NOT_PAID") {
            delete invoiceData.totalPaidAmount;
          }
          http()
            .post("/createInvoice", invoiceData)
            .then(response => {
              this.getInvoiceList();
              this.snackbar = true;
              this.text = "New Invoice added successfully";
d9bb52b5b   Neeraj Sharma   implement trello ...
636
              this.color = "green";
687e0b929   Neeraj Sharma   add user,attenden...
637
638
639
640
641
642
643
644
645
646
647
648
649
650
              this.clear();
              this.feeTypeData = [];
              if (this.feeTypeData.length == 0) {
                this.feeType = {
                  amount: "0.00",
                  discount: "0.00",
                  paidAmount: "0.00",
                  subTotal: "0.00",
                  feeTypeList: ""
                };
              }
              this.loading = false;
            })
            .catch(error => {
d9bb52b5b   Neeraj Sharma   implement trello ...
651
              console.log(error.response.data.errors[0].messages[0]);
99cd79184   Neeraj Sharma   implement all tas...
652
              this.snackbar = true;
d9bb52b5b   Neeraj Sharma   implement trello ...
653
654
              this.text = error.response.data.errors[0].messages[0];
              this.color = "error";
687e0b929   Neeraj Sharma   add user,attenden...
655
656
657
658
659
660
661
662
              this.loading = false;
            });
        }
      },
      clear() {
        this.$refs.form.reset();
      },
      getInvoiceList() {
6ae46ca27   Neeraj Sharma   implement upload ...
663
        this.showLoader = true;
687e0b929   Neeraj Sharma   add user,attenden...
664
665
        http()
          .get("/getInvoicesList", {
99cd79184   Neeraj Sharma   implement all tas...
666
            params: { schoolId: this.$store.state.schoolId },
687e0b929   Neeraj Sharma   add user,attenden...
667
668
669
670
671
672
            headers: { Authorization: "Bearer " + this.token }
          })
          .then(response => {
            this.invoiceList = response.data.data;
            this.showLoader = false;
          })
ab54b5656   Neeraj Sharma   implement library...
673
          .catch(error => {
687e0b929   Neeraj Sharma   add user,attenden...
674
675
676
677
678
679
680
681
682
683
684
685
            // console.log("err====>", err);
            this.showLoader = false;
            if (error.response.status === 401) {
              this.$router.replace({ path: "/" });
              this.$store.dispatch("setToken", null);
              this.$store.dispatch("Id", null);
            }
          });
      },
      selectFeeType() {
        this.showFeeType = true;
        this.feeTypeData.push({ feeTypeName: this.feeType.feeTypeName });
687e0b929   Neeraj Sharma   add user,attenden...
686
687
688
      },
      deleteSelectFee: function(index) {
        this.feeTypeData.splice(index, 1);
687e0b929   Neeraj Sharma   add user,attenden...
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
        for (let i = 0; i < this.feeTypeData.length; i++) {
          this.feeType = this.feeTypeData[i];
        }
        if (this.feeTypeData.length == 0) {
          this.feeType = {
            amount: "0.00",
            discount: "0.00",
            paidAmount: "0.00",
            subTotal: "0.00",
            feeTypeName: ""
          };
        }
      },
      getAllClasses() {
        http()
          .get("/getClassesList", {
99cd79184   Neeraj Sharma   implement all tas...
705
            params: { schoolId: this.$store.state.schoolId },
687e0b929   Neeraj Sharma   add user,attenden...
706
707
708
709
710
711
712
713
714
715
716
            headers: { Authorization: "Bearer " + this.token }
          })
          .then(response => {
            this.addclass = response.data.data;
          })
          .catch(err => {
            // console.log("err====>", err);
            // this.$router.replace({ path: "/" });
          });
      },
      getAllStudents() {
d9bb52b5b   Neeraj Sharma   implement trello ...
717
        this.showLoader = true;
687e0b929   Neeraj Sharma   add user,attenden...
718
719
        http()
          .get("/getStudentsList", {
99cd79184   Neeraj Sharma   implement all tas...
720
721
722
723
            params: {
              classId: this.invoiceData.classNum,
              schoolId: this.$store.state.schoolId
            },
687e0b929   Neeraj Sharma   add user,attenden...
724
725
726
            headers: { Authorization: "Bearer " + this.token }
          })
          .then(response => {
d45ffc6fa   Neeraj Sharma   solve bugs and ad...
727
728
729
730
            response.data.data.unshift({
              name: "Select All",
              _id: "Select All"
            });
687e0b929   Neeraj Sharma   add user,attenden...
731
            this.studentList = response.data.data;
d9bb52b5b   Neeraj Sharma   implement trello ...
732
            this.showLoader = false;
687e0b929   Neeraj Sharma   add user,attenden...
733
734
          })
          .catch(err => {
d9bb52b5b   Neeraj Sharma   implement trello ...
735
            this.showLoader = false;
687e0b929   Neeraj Sharma   add user,attenden...
736
737
738
739
740
741
742
            // console.log("err====>", err);
            // this.$router.replace({ path: "/" });
          });
      },
      getfeeType() {
        http()
          .get("/getFeesList", {
99cd79184   Neeraj Sharma   implement all tas...
743
744
745
            params: {
              schoolId: this.$store.state.schoolId
            },
687e0b929   Neeraj Sharma   add user,attenden...
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
            headers: { Authorization: "Bearer " + this.token }
          })
          .then(response => {
            this.feeTypes = response.data.data;
          })
          .catch(err => {
            // console.log("err====>", err);
            // this.$router.replace({ path: "/" });
          });
      },
      getAmmountDetails(feeTyp) {
        let feeType = {
          amount: "",
          discount: "",
          subTotal: "",
          subParticularTotal: "",
          paidAmount: ""
        };
        for (let i = 0; i < this.feeTypeData.length; i++) {
          // *********** AMOUNT ***********
  
          feeType.amount =
            Number(feeType.amount) + Number(this.feeTypeData[i].amount);
ab54b5656   Neeraj Sharma   implement library...
769
          // console.log("feeType.amount ", feeType.amount);
687e0b929   Neeraj Sharma   add user,attenden...
770
771
772
773
774
775
776
777
778
          this.feeType.amount = feeType.amount;
          this.feeType.subTotal = feeType.amount;
          this.feeTypeData[i].subTotal = this.feeTypeData[i].amount;
  
          // *********** DISCOUNT ***********
  
          if (this.feeTypeData[i].discount) {
            feeType.discount =
              Number(feeType.discount) + Number(this.feeTypeData[i].discount);
ab54b5656   Neeraj Sharma   implement library...
779
            // console.log("feeType.discount", feeType.discount);
687e0b929   Neeraj Sharma   add user,attenden...
780
781
782
783
            this.feeType.discount = feeType.discount;
            feeType.subParticularTotal =
              this.feeTypeData[i].amount -
              (this.feeTypeData[i].amount * this.feeTypeData[i].discount) / 100;
687e0b929   Neeraj Sharma   add user,attenden...
784
785
786
787
788
789
790
791
792
793
794
795
796
797
            this.feeTypeData[i].subTotal = feeType.subParticularTotal.toFixed(2);
          }
  
          // *********** SUBTOTAL ***********
  
          feeType.subTotal =
            Number(feeType.subTotal) + Number(this.feeTypeData[i].subTotal);
          this.feeType.subTotal = feeType.subTotal.toFixed(2);
  
          // *********** PAID-AMOUNT ***********
  
          feeType.paidAmount =
            Number(feeType.paidAmount) + Number(this.feeTypeData[i].paidAmount);
          this.feeType.paidAmount = feeType.paidAmount.toFixed(2);
d9bb52b5b   Neeraj Sharma   implement trello ...
798
799
800
801
802
803
  
          // if paid Amount fill large of subtotal value so this condition are fixed filled subtotal value.
          if (feeType.paidAmount > feeType.subTotal) {
            this.feeTypeData[i].paidAmount = this.feeTypeData[i].subTotal;
            this.feeType.paidAmount = feeType.subTotal;
          }
687e0b929   Neeraj Sharma   add user,attenden...
804
805
806
807
808
809
810
811
812
813
        }
      },
      getPayMethodList() {
        if (this.invoiceData.paymentStatus == "PARTIALLY_PAID") {
          this.showPayMethods = true;
        } else if (this.invoiceData.paymentStatus == "FULLY_PAID") {
          this.showPayMethods = true;
        } else {
          this.showPayMethods = false;
        }
d45ffc6fa   Neeraj Sharma   solve bugs and ad...
814
815
816
817
818
819
820
821
822
823
824
825
826
827
      },
      selectAllStudent() {
        console.log("this.studentId", this.invoiceData.studentId);
        this.invoiceData.students = [];
        if (this.invoiceData.studentId === "Select All") {
          for (let i = 1; i < this.studentList.length; i++) {
            this.invoiceData.students.push(this.studentList[i]._id);
            console.log("data", this.invoiceData.students);
            // data.push(this.studentList[i]._id);
            // console.log("data", data);
          }
        } else {
          this.invoiceData.students.push(this.invoiceData.studentId);
        }
687e0b929   Neeraj Sharma   add user,attenden...
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
      }
    },
    mounted() {
      this.token = this.$store.state.token;
      this.getInvoiceList();
      this.getAllClasses();
      this.getfeeType();
    },
    created() {
      this.$root.$on("app:search", search => {
        this.search = search;
      });
    },
    beforeDestroy() {
      // dont forget to remove the listener
      this.$root.$off("app:search");
    }
  };
  </script>
  
  
  <style scoped>
  .active {
    background-color: gray;
    color: white !important;
  }
  .activebtn {
    color: black !important;
  }
  table {
    border-collapse: collapse;
    border: 1px solid #e2e7eb;
  }
  
  th,
  td {
    border: 1px solid #e2e7eb;
    padding: 10px;
    text-align: center;
  }
  table.feeTypeTable {
    table-layout: auto !important;
    width: 100% !important;
  }
  </style>