Blame view

src/pages/Account/invoice.vue 29.1 KB
687e0b929   Neeraj Sharma   add user,attenden...
1
  <template>
68d742034   Neeraj Sharma   implement new des...
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
    <v-container fluid class="body-color">
      <!-- ****** PROFILE VIEW SECTION DATA ******  -->
      <!-- <v-dialog v-model="dialog1" max-width="600px">
        <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>
                    </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>-->
      <!-- ****** Invoice Table ****** -->
687e0b929   Neeraj Sharma   add user,attenden...
63

68d742034   Neeraj Sharma   implement new des...
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
      <v-toolbar color="transparent" flat>
        <v-btn
          fab
          dark
          class="open-dialog-button hidden-xl-only hidden-md-only hidden-lg-only"
          small
          @click="addInvoiceDialog = true"
        >
          <v-icon dark>add</v-icon>
        </v-btn>
        <v-btn
          round
          class="open-dialog-button hidden-sm-only hidden-xs-only"
          dark
          @click="addInvoiceDialog = true"
        >
          <v-icon class="white--text pr-1" size="20">add</v-icon>Add Invoice
        </v-btn>
        <v-spacer></v-spacer>
        <v-card-title class="body-1" v-show="show">
          <v-btn icon large flat @click="displaySearch">
            <v-avatar size="27">
aa310d61a   Shikha Mishra   added functionali...
86
              <img src="/static/icon/search.png" alt="icon" />
68d742034   Neeraj Sharma   implement new des...
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
            </v-avatar>
          </v-btn>
        </v-card-title>
        <v-flex xs8 sm8 md3 lg2 v-show="showSearch">
          <v-layout>
            <v-text-field v-model="search" label="Search" prepend-inner-icon="search" color="primary"></v-text-field>
            <v-icon @click="closeSearch" color="error">close</v-icon>
          </v-layout>
        </v-flex>
      </v-toolbar>
      <v-data-table
        :headers="headers"
        :items="invoiceList"
        :pagination.sync="pagination"
        :search="search"
      >
        <template slot="items" slot-scope="props">
          <tr class="tr">
            <td class="td td-row">{{ props.index + 1 }}</td>
            <td class="text-xs-center td td-row">{{ props.item.studentId.name }}</td>
            <td class="text-xs-center td td-row">{{ props.item.classId.classNum }}</td>
            <td class="text-xs-center td td-row">{{ props.item.totalAmount }}</td>
            <td
              class="text-xs-center td td-row"
            >{{ props.item.totalAmount - props.item.totalSubTotal }}</td>
            <td
              class="text-xs-center td td-row"
            >{{ props.item.totalPaidAmount ? props.item.totalPaidAmount : 0}}</td>
            <td
              class="text-xs-center td td-row"
25205ccca   Shikha Mishra   show school logo ...
117
            >{{ props.item.totalPaidAmount ? props.item.totalSubTotal  - props.item.totalPaidAmount  : props.item.totalSubTotal  }}</td>
68d742034   Neeraj Sharma   implement new des...
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
            <td class="text-xs-center td td-row" v-if="props.item.paymentStatus === 'NOT_PAID'">
              <span
                class="red lighten-1 py-1 px-2 white--text paymentStatus"
              >{{ props.item.paymentStatus }}</span>
            </td>
            <td class="text-xs-center td td-row" v-if="props.item.paymentStatus === 'FULLY_PAID'">
              <span
                class="green lighten-1 py-1 px-2 white--text paymentStatus"
              >{{ props.item.paymentStatus }}</span>
            </td>
            <td class="text-xs-center td td-row" v-if="props.item.paymentStatus === 'PARTIALLY_PAID'">
              <span
                class="yellow darken-3 py-1 px-2 white--text paymentStatus"
              >{{ props.item.paymentStatus }}</span>
            </td>
            <td class="text-xs-center td td-row">{{ dates(props.item.date) }}</td>
            <td class="text-xs-center td td-row">
aa310d61a   Shikha Mishra   added functionali...
135
              <router-link :to="{ name:'View Invoice',params: { viewInvoiceId:props.item._id } }">
68d742034   Neeraj Sharma   implement new des...
136
137
138
139
140
                <v-tooltip top>
                  <img
                    slot="activator"
                    style="cursor:pointer; width:25px; height:25px; "
                    class="mr-3"
aa310d61a   Shikha Mishra   added functionali...
141
                    src="/static/icon/view.png"
68d742034   Neeraj Sharma   implement new des...
142
143
144
145
146
147
148
149
150
151
152
                  />
                  <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-3"
aa310d61a   Shikha Mishra   added functionali...
153
                      src="/static/icon/edit.png"
68d742034   Neeraj Sharma   implement new des...
154
155
156
157
158
159
160
161
162
163
                    />
                    <span>Edit</span>
                  </v-tooltip>
                </router-link>
                <v-tooltip top>
                  <img
                    slot="activator"
                    style="cursor:pointer;width:20px; height:20px; "
                    class="mr-3"
                    @click="deleteItem(props.item)"
aa310d61a   Shikha Mishra   added functionali...
164
                    src="/static/icon/delete.png"
68d742034   Neeraj Sharma   implement new des...
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
                  />
                  <span>Delete</span>
                </v-tooltip>
              </span>
            </td>
          </tr>
        </template>
        <v-alert
          slot="no-results"
          :value="true"
          color="error"
          icon="warning"
        >Your search for "{{ search }}" found no results.</v-alert>
      </v-data-table>
      <!-- ****** ADD INVOICE ****** -->
      <v-dialog v-model="addInvoiceDialog" max-width>
        <v-card flat class="text-xs-center white--text">
          <v-layout>
            <v-flex xs12  class="card-styles pa-2">
              <label class="title text-xs-center ">Add Invoice</label>
              <v-icon size="24" class="right white--text" @click="addInvoiceDialog = false">cancel</v-icon>
            </v-flex>
          </v-layout>
          <v-flex xs12 sm12>
            <v-container fluid grid-list-md>
              <v-layout wrap>
                <v-flex xs12 sm12 md5>
                  <v-card flat>
                    <v-toolbar dark class="card-styles" flat>
                      <v-spacer></v-spacer>
                        <h3>Invoice</h3>
                      <v-spacer></v-spacer>
                    </v-toolbar>
                    <v-form ref="form" v-model="valid" lazy-validation class="py-4">
687e0b929   Neeraj Sharma   add user,attenden...
199
                      <v-layout>
68d742034   Neeraj Sharma   implement new des...
200
201
202
                        <v-flex xs4 class="pt-4 subheading">
                          <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
                        </v-flex>
68d742034   Neeraj Sharma   implement new des...
204
205
206
207
208
209
210
211
212
213
214
                        <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>
687e0b929   Neeraj Sharma   add user,attenden...
215
216
217
                        </v-flex>
                      </v-layout>
                      <v-layout>
68d742034   Neeraj Sharma   implement new des...
218
219
220
                        <v-flex xs4 class="pt-4 subheading">
                          <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
                        </v-flex>
68d742034   Neeraj Sharma   implement new des...
222
223
224
225
226
227
228
229
230
231
232
                        <v-flex xs6 class="ml-3">
                          <v-select
                            :items="studentList"
                            label="Select Student"
                            v-model="invoiceData.studentId"
                            item-text="name"
                            item-value="_id"
                            :rules="inchargeRules"
                            @change="selectAllStudent()"
                            required
                          ></v-select>
687e0b929   Neeraj Sharma   add user,attenden...
233
234
235
                        </v-flex>
                      </v-layout>
                      <v-layout>
68d742034   Neeraj Sharma   implement new des...
236
237
                        <v-flex xs4 class="pt-4 subheading">
                          <label class="right">Date:</label>
687e0b929   Neeraj Sharma   add user,attenden...
238
                        </v-flex>
68d742034   Neeraj Sharma   implement new des...
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
                        <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>
687e0b929   Neeraj Sharma   add user,attenden...
263
264
265
                        </v-flex>
                      </v-layout>
                      <v-layout>
68d742034   Neeraj Sharma   implement new des...
266
267
268
                        <v-flex xs4 class="pt-4 subheading">
                          <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
                        </v-flex>
68d742034   Neeraj Sharma   implement new des...
270
271
272
273
274
275
276
277
278
279
280
                        <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>
687e0b929   Neeraj Sharma   add user,attenden...
281
282
                        </v-flex>
                      </v-layout>
68d742034   Neeraj Sharma   implement new des...
283
284
285
                      <v-layout v-show="showPayMethods">
                        <v-flex xs4 class="pt-4 subheading">
                          <label class="right">Payment Method:</label>
687e0b929   Neeraj Sharma   add user,attenden...
286
                        </v-flex>
68d742034   Neeraj Sharma   implement new des...
287
                        <v-flex xs6 class="ml-3">
687e0b929   Neeraj Sharma   add user,attenden...
288
                          <v-select
68d742034   Neeraj Sharma   implement new des...
289
290
291
292
                            :items="paymentMethods"
                            v-model="invoiceData.paymentMethod"
                            label="Select Payment Method"
                            required
687e0b929   Neeraj Sharma   add user,attenden...
293
294
                          ></v-select>
                        </v-flex>
68d742034   Neeraj Sharma   implement new des...
295
296
297
298
299
300
301
302
                      </v-layout>
                      <v-layout>
                        <v-flex xs12 sm11>
                          <v-card-actions>
                            <v-spacer></v-spacer>
                            <v-btn @click="clear" round dark class="clear-button">clear</v-btn>
                            <v-btn @click="submit" round dark :loading="loading"  class="add-button">Add</v-btn>
                          </v-card-actions>
687e0b929   Neeraj Sharma   add user,attenden...
303
304
                        </v-flex>
                      </v-layout>
68d742034   Neeraj Sharma   implement new des...
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
                    </v-form>
                  </v-card>
                </v-flex>
                <v-flex xs12 sm12 md7>
                  <v-card>
                    <v-toolbar dark class="card-styles " flat>
                      <v-spacer></v-spacer>
                        <h3>Fee Type List</h3>
                      <v-spacer></v-spacer>
                    </v-toolbar>
                    <v-layout>
                      <v-flex xs4 sm2 class="mt-4 hidden-xs-only hidden-sm-only">
                        <label class="right title ">Fee Type:</label>
                      </v-flex>
                      <v-flex xs8 sm4>
                        <v-select
                          :items="feeTypes"
                          v-model="feeType.feeTypeName"
                          item-text="feeType"
                          item-value="feeType"
                          label="Select Fee Type"
                        ></v-select>
                      </v-flex>
                      <v-flex xs4 sm6>
                        <v-btn color="open-dialog-button" round dark class="right mt-3" @click="selectFeeType">ADD</v-btn>
                      </v-flex>
                    </v-layout>
                    <table class="feeTypeTable tableRsponsive">
                      <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" class="tdFeeType">{{ index + 1 }}</td>
                        <td style="width:120px" class="tdFeeType">{{ feeType.feeTypeName }}</td>
                        <td class="tdFeeType">
                          <v-text-field
                            placeholder="fill your Amount"
                            v-model="feeType.amount"
                            type="number"
                          ></v-text-field>
                        </td>
                        <td class="tdFeeType">
                          <v-text-field
                            placeholder="fill your Discount"
                            v-model="feeType.discount"
                            type="number"
                          ></v-text-field>
                        </td>
                        <td class="tdFeeType">{{ feeType.subTotal }}</td>
5f3a7efc0   Shikha Mishra   remove required v...
365
                        <!-- <td class="tdFeeType" v-if="invoiceData.paymentStatus === 'NOT_PAID'">
68d742034   Neeraj Sharma   implement new des...
366
367
368
369
370
371
                          <v-text-field
                            placeholder="fill your Paid Amount"
                            v-model="feeType.paidAmount"
                            type="number"
                            :disabled="disabled"
                          ></v-text-field>
5f3a7efc0   Shikha Mishra   remove required v...
372
                        </td> -->
68d742034   Neeraj Sharma   implement new des...
373
374
375
376
377
378
379
380
381
382
383
                        <td class="tdFeeType" 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
                          class="tdFeeType"
                          v-if="invoiceData.paymentStatus != 'NOT_PAID' && invoiceData.paymentStatus != ''"
687e0b929   Neeraj Sharma   add user,attenden...
384
                        >
68d742034   Neeraj Sharma   implement new des...
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
                          <v-text-field
                            placeholder="fill your Paid Amount"
                            v-model="feeType.paidAmount"
                            type="number"
                          ></v-text-field>
                        </td>
                        <td class="tdFeeType">
                          <v-icon color="error" @click="deleteSelectFee(index)">delete</v-icon>
                        </td>
                      </tr>
                      <tfoot>
                        <tr>
                          <td colspan="2" class="tdFeeType">Total:</td>
                          <td class="tdFeeType">{{ feeType.amount }}</td>
                          <td class="tdFeeType">{{ feeType.discount }}</td>
                          <td class="tdFeeType">{{ feeType.subTotal }}</td>
                          <td class="tdFeeType">{{ feeType.paidAmount }}</td>
687e0b929   Neeraj Sharma   add user,attenden...
402
                        </tr>
68d742034   Neeraj Sharma   implement new des...
403
404
405
406
407
408
409
410
411
                      </tfoot>
                    </table>
                  </v-card>
                </v-flex>
              </v-layout>
            </v-container>
          </v-flex>
        </v-card>
      </v-dialog>
687e0b929   Neeraj Sharma   add user,attenden...
412
413
414
      <div class="loader" v-if="showLoader">
        <v-progress-circular indeterminate color="white"></v-progress-circular>
      </div>
68d742034   Neeraj Sharma   implement new des...
415
    </v-container>
687e0b929   Neeraj Sharma   add user,attenden...
416
417
418
419
  </template>
  
  <script>
  import http from "@/Services/http.js";
687e0b929   Neeraj Sharma   add user,attenden...
420
421
422
423
424
425
426
427
428
  import moment from "moment";
  
  export default {
    data: () => ({
      snackbar: false,
      showPayMethods: false,
      y: "top",
      x: "right",
      mode: "",
d9bb52b5b   Neeraj Sharma   implement trello ...
429
      timeout: 5000,
687e0b929   Neeraj Sharma   add user,attenden...
430
      text: "",
d9bb52b5b   Neeraj Sharma   implement trello ...
431
      color: "",
68d742034   Neeraj Sharma   implement new des...
432
433
      show: true,
      showSearch: false,
687e0b929   Neeraj Sharma   add user,attenden...
434
435
436
437
438
439
440
441
442
443
444
      showLoader: false,
      loading: false,
      date: null,
      search: "",
      dialog: false,
      dialog1: false,
      valid: true,
      validEdit: true,
      isActive: true,
      newActive: false,
      showFeeType: false,
68d742034   Neeraj Sharma   implement new des...
445
      addInvoiceDialog: false,
687e0b929   Neeraj Sharma   add user,attenden...
446
447
448
449
450
451
452
453
454
455
456
457
458
459
      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: {
68d742034   Neeraj Sharma   implement new des...
460
        rowsPerPage: 10
687e0b929   Neeraj Sharma   add user,attenden...
461
462
463
464
465
      },
      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
      headers: [
        {
          text: "No",
68d742034   Neeraj Sharma   implement new des...
470
          align: "",
687e0b929   Neeraj Sharma   add user,attenden...
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
          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
            this.getInvoiceList();
          })
          .catch(error => {
            // console.log(error);
          });
      },
687e0b929   Neeraj Sharma   add user,attenden...
566
567
      close() {
        this.dialog = false;
687e0b929   Neeraj Sharma   add user,attenden...
568
      },
d9bb52b5b   Neeraj Sharma   implement trello ...
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
      // 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...
586
587
588
589
590
591
592
      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;
          }
        }
25205ccca   Shikha Mishra   show school logo ...
593
        // if (this.$refs.form.validate()) {
687e0b929   Neeraj Sharma   add user,attenden...
594
595
          let invoiceData = {
            classId: this.invoiceData.classNum,
d45ffc6fa   Neeraj Sharma   solve bugs and ad...
596
            students: this.invoiceData.students,
687e0b929   Neeraj Sharma   add user,attenden...
597
598
599
600
601
602
603
            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,
25205ccca   Shikha Mishra   show school logo ...
604
            totalPaidAmount: this.feeType.paidAmount
687e0b929   Neeraj Sharma   add user,attenden...
605
          };
25205ccca   Shikha Mishra   show school logo ...
606
607
608
609
          console.log("invoiceData",invoiceData)
          // if (invoiceData.paymentStatus == "NOT_PAID") {
          //   delete invoiceData.totalPaidAmount;
          // }
687e0b929   Neeraj Sharma   add user,attenden...
610
611
612
613
614
615
          http()
            .post("/createInvoice", invoiceData)
            .then(response => {
              this.getInvoiceList();
              this.snackbar = true;
              this.text = "New Invoice added successfully";
d9bb52b5b   Neeraj Sharma   implement trello ...
616
              this.color = "green";
687e0b929   Neeraj Sharma   add user,attenden...
617
618
619
620
621
622
623
624
625
626
627
628
              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;
68d742034   Neeraj Sharma   implement new des...
629
              this.addInvoiceDialog = false;
687e0b929   Neeraj Sharma   add user,attenden...
630
631
            })
            .catch(error => {
99cd79184   Neeraj Sharma   implement all tas...
632
              this.snackbar = true;
d9bb52b5b   Neeraj Sharma   implement trello ...
633
634
              this.text = error.response.data.errors[0].messages[0];
              this.color = "error";
687e0b929   Neeraj Sharma   add user,attenden...
635
636
              this.loading = false;
            });
25205ccca   Shikha Mishra   show school logo ...
637
        // }
687e0b929   Neeraj Sharma   add user,attenden...
638
639
640
641
642
      },
      clear() {
        this.$refs.form.reset();
      },
      getInvoiceList() {
6ae46ca27   Neeraj Sharma   implement upload ...
643
        this.showLoader = true;
687e0b929   Neeraj Sharma   add user,attenden...
644
645
        http()
          .get("/getInvoicesList", {
99cd79184   Neeraj Sharma   implement all tas...
646
            params: { schoolId: this.$store.state.schoolId },
687e0b929   Neeraj Sharma   add user,attenden...
647
648
649
650
651
652
            headers: { Authorization: "Bearer " + this.token }
          })
          .then(response => {
            this.invoiceList = response.data.data;
            this.showLoader = false;
          })
ab54b5656   Neeraj Sharma   implement library...
653
          .catch(error => {
687e0b929   Neeraj Sharma   add user,attenden...
654
655
656
657
658
659
660
661
662
663
664
665
            // 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...
666
667
668
      },
      deleteSelectFee: function(index) {
        this.feeTypeData.splice(index, 1);
687e0b929   Neeraj Sharma   add user,attenden...
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
        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...
685
            params: { schoolId: this.$store.state.schoolId },
687e0b929   Neeraj Sharma   add user,attenden...
686
687
688
689
690
691
692
693
694
695
696
            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 ...
697
        this.showLoader = true;
687e0b929   Neeraj Sharma   add user,attenden...
698
699
        http()
          .get("/getStudentsList", {
99cd79184   Neeraj Sharma   implement all tas...
700
701
702
703
            params: {
              classId: this.invoiceData.classNum,
              schoolId: this.$store.state.schoolId
            },
687e0b929   Neeraj Sharma   add user,attenden...
704
705
706
            headers: { Authorization: "Bearer " + this.token }
          })
          .then(response => {
d45ffc6fa   Neeraj Sharma   solve bugs and ad...
707
708
709
710
            response.data.data.unshift({
              name: "Select All",
              _id: "Select All"
            });
687e0b929   Neeraj Sharma   add user,attenden...
711
            this.studentList = response.data.data;
d9bb52b5b   Neeraj Sharma   implement trello ...
712
            this.showLoader = false;
687e0b929   Neeraj Sharma   add user,attenden...
713
714
          })
          .catch(err => {
d9bb52b5b   Neeraj Sharma   implement trello ...
715
            this.showLoader = false;
687e0b929   Neeraj Sharma   add user,attenden...
716
717
718
719
720
721
722
            // console.log("err====>", err);
            // this.$router.replace({ path: "/" });
          });
      },
      getfeeType() {
        http()
          .get("/getFeesList", {
99cd79184   Neeraj Sharma   implement all tas...
723
724
725
            params: {
              schoolId: this.$store.state.schoolId
            },
687e0b929   Neeraj Sharma   add user,attenden...
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
            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...
749
          // console.log("feeType.amount ", feeType.amount);
687e0b929   Neeraj Sharma   add user,attenden...
750
751
752
753
754
755
756
757
758
          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...
759
            // console.log("feeType.discount", feeType.discount);
687e0b929   Neeraj Sharma   add user,attenden...
760
761
762
763
            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...
764
765
766
767
768
769
770
771
772
773
774
775
776
777
            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 ...
778
779
780
781
782
783
  
          // 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...
784
785
786
787
788
789
790
791
792
793
        }
      },
      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...
794
795
796
797
798
799
800
801
802
803
804
805
806
807
      },
      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);
        }
68d742034   Neeraj Sharma   implement new des...
808
809
810
811
812
813
814
815
      },
      displaySearch() {
        (this.show = false), (this.showSearch = true);
      },
      closeSearch() {
        this.showSearch = false;
        this.show = true;
        this.search = "";
687e0b929   Neeraj Sharma   add user,attenden...
816
817
818
819
820
821
822
      }
    },
    mounted() {
      this.token = this.$store.state.token;
      this.getInvoiceList();
      this.getAllClasses();
      this.getfeeType();
687e0b929   Neeraj Sharma   add user,attenden...
823
824
825
826
827
828
    }
  };
  </script>
  
  
  <style scoped>
687e0b929   Neeraj Sharma   add user,attenden...
829
830
831
832
833
834
  table {
    border-collapse: collapse;
    border: 1px solid #e2e7eb;
  }
  
  th,
68d742034   Neeraj Sharma   implement new des...
835
  .tdFeeType {
687e0b929   Neeraj Sharma   add user,attenden...
836
837
838
839
840
841
842
843
844
    border: 1px solid #e2e7eb;
    padding: 10px;
    text-align: center;
  }
  table.feeTypeTable {
    table-layout: auto !important;
    width: 100% !important;
  }
  </style>