Blame view

src/pages/Account/paymentTemplate.vue 17.6 KB
3e79b2f9f   Neeraj Sharma   implement functio...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
  <template>
    <v-app id="pages-dasboard">
      <!-- ****** Edit multiple INVOICE ****** -->
  
      <v-snackbar
        :timeout="timeout"
        :top="y === 'top'"
        :right="x === 'right'"
        :vertical="mode === 'vertical'"
        v-model="snackbar"
        color="success"
      >{{ text }}</v-snackbar>
      <v-flex xs12 sm12>
        <v-container fluid grid-list-md>
          <v-layout wrap>
            <v-flex xs12 sm12 md4>
              <v-card flat class="mb-4">
                <v-toolbar dark class="card-styles" flat>
                  <v-spacer></v-spacer>
                  <h3>Profile</h3>
                  <v-spacer></v-spacer>
                </v-toolbar>
a4fce59de   Neeraj Sharma   complete solve bu...
23
                <!-- Profile User-->
3e79b2f9f   Neeraj Sharma   implement functio...
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
                <v-card-text>
                  <v-container>
                    <v-layout wrap>
                      <v-flex xs12>
                        <v-layout>
                          <v-flex
                            xs12
                            class="text-xs-center text-sm-center text-md-center text-lg-center"
                          >
                            <v-avatar size="80px">
                              <img src="/static/icon/user.png" v-if="!editPayment.profilePicUrl" />
                              <img
                                :src="editPayment.profilePicUrl"
                                v-else-if="editPayment.profilePicUrl"
                              />
                            </v-avatar>
                          </v-flex>
                        </v-layout>
                        <v-layout>
                          <v-flex xs12 sm12>
                            <h3 class="text-xs-center">
                              <b>{{ editPayment.studentId.name }}</b>
                            </h3>
                            <p class="text-xs-center grey--text">Student</p>
                          </v-flex>
                        </v-layout>
                        <v-layout style="border: 1px solid lightgrey;">
                          <v-flex xs6 sm6 class="pa-0">
                            <h4 class="right">
                              <b>Roll No :</b>
                            </h4>
                          </v-flex>
                          <v-flex sm6 xs6 class="pa-0">
                            <h4>{{ editPayment.studentId.rollNo }}</h4>
                          </v-flex>
                        </v-layout>
                        <v-layout style="border: 1px solid lightgrey;">
                          <v-flex xs6 sm6 class="pa-0">
                            <h4 class="right">
                              <b>Class :</b>
                            </h4>
                          </v-flex>
                          <v-flex sm6 xs6 class="pa-0">
                            <h4>{{ editPayment.classId.classNum }}</h4>
                          </v-flex>
                        </v-layout>
                      </v-flex>
                    </v-layout>
                  </v-container>
                </v-card-text>
              </v-card>
a4fce59de   Neeraj Sharma   complete solve bu...
75
              <!-- Account Fee Type List User-->
3e79b2f9f   Neeraj Sharma   implement functio...
76
77
78
79
80
81
82
83
84
              <v-card flat>
                <v-toolbar dark class="card-styles" 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">
3e79b2f9f   Neeraj Sharma   implement functio...
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
                  <v-layout>
                    <v-flex xs4 class="pt-4 subheading">
                      <label class="right">Payment Method:</label>
                    </v-flex>
                    <v-flex xs7 class="ml-3">
                      <v-select
                        :items="paymentMethods"
                        v-model="editPayment.paymentMethod"
                        label="Select Payment Method"
                      ></v-select>
                    </v-flex>
                  </v-layout>
                  <v-card-actions>
                    <v-spacer class="hidden-xs-only"></v-spacer>
                    <v-btn
                      color="open-dialog-button"
                      dark
                      class="right mt-3"
                      @click="update(editPayment)"
                    >Add Payment</v-btn>
                  </v-card-actions>
                </v-form>
              </v-card>
            </v-flex>
            <v-flex xs12 sm12 md8>
              <v-card>
                <v-toolbar dark class="card-styles" flat>
                  <v-spacer></v-spacer>
                  <v-toolbar-title>
                    <h3>Fee Type List</h3>
                  </v-toolbar-title>
                  <v-spacer></v-spacer>
                </v-toolbar>
3e79b2f9f   Neeraj Sharma   implement functio...
118
119
120
121
122
                <table class="feeTypeTable tableRsponsive">
                  <tr class="info white--text">
                    <th>#</th>
                    <th>Fee Type</th>
                    <th>Amount</th>
ff30cbe86   Neeraj Sharma   remove discount p...
123
                    <th>Discount</th>
3e79b2f9f   Neeraj Sharma   implement functio...
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
                    <th>Subtotal</th>
                    <th>Paid Amount</th>
                    <th>Action</th>
                  </tr>
                  <tr
                    v-for="(feeType, index) in editPayment.feeType"
                    :key="index"
                    v-on:keyup="getAmmountDetails(feeType,editPayment.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>
a4fce59de   Neeraj Sharma   complete solve bu...
150
                    <td>
3e79b2f9f   Neeraj Sharma   implement functio...
151
152
153
154
155
156
                      <v-text-field
                        placeholder="fill your Paid Amount"
                        v-model="feeType.paidAmount"
                        type="number"
                      ></v-text-field>
                    </td>
c765369af   Neeraj Sharma   solve bugs
157
                    <td v-if="!editPayment.feeType">
3e79b2f9f   Neeraj Sharma   implement functio...
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
                      <v-icon
                        color="error"
                        @click="deleteSelectFee(feeType,editPayment.feeType,index)"
                      >delete</v-icon>
                    </td>
                  </tr>
                  <tfoot v-if="feeType.amount != 0.00">
                    <tr>
                      <td colspan="2">Total:</td>
                      <td>{{ feeType.amount }}</td>
                      <td>{{ feeType.discount }}</td>
                      <td>{{ feeType.subTotal }}</td>
                      <td>{{ feeType.paidAmount }}</td>
                    </tr>
                  </tfoot>
                  <tfoot v-else-if="feeType.amount == 0.00">
                    <tr>
                      <td colspan="2">Total:</td>
                      <td>{{ editPayment.totalAmount }}</td>
                      <td>{{ editPayment.totalDiscount }}</td>
                      <td>{{ editPayment.totalSubTotal }}</td>
                      <td>{{ editPayment.totalPaidAmount }}</td>
                    </tr>
                  </tfoot>
                </table>
              </v-card>
            </v-flex>
          </v-layout>
        </v-container>
      </v-flex>
      <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 moment from "moment";
  
  export default {
    props: ["editPayment"],
    data: () => ({
      snackbar: false,
      // showPayMethods: false,
      y: "top",
      x: "right",
      mode: "",
      timeout: 3000,
      text: "",
      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,
      // invoiceData: {},
      paymentMethods: ["Cash", "Cheque"],
      feeType: {
        amount: "0.00",
        discount: "0.00",
        paidAmount: "0.00",
        subTotal: "0.00",
        feeTypeName: ""
      },
      feeTypeData: [],
      pagination: {
        rowsPerPage: 15
      },
      token: "",
      editedItem: {},
      invoiceParticularData: {},
      addclass: [],
      studentList: [],
      paymentStatus: [
        {
          name: "Not Paid",
          value: "NOT_PAID"
        },
        {
          name: "Partially Paid",
          value: "PARTIALLY_PAID"
        },
        {
          name: "Fully Paid",
          value: "FULLY_PAID"
        }
      ]
    }),
    // watch: {
    //   menu1(val) {
    //     val && this.$nextTick(() => (this.$refs.picker.activePicker = "YEAR"));
    //   }
    // },
    methods: {
      save(date) {
        this.$refs.menu1.save(date);
      },
      dates: function(date) {
        return moment(date).format("MMMM DD, YYYY");
      },
      update(editPayment) {
        // console.log("editPayment-----------", editPayment);
        let feeTypeId = "";
        for (let i = 0; i < this.feeTypes.length; i++) {
          if (this.feeTypes[i].feeType === this.feeType.feeTypeName) {
            feeTypeId = this.feeTypes[i]._id;
          }
        }
        // console.log(editPayment);
        let editInvoiceData = {
          invoiceId: editPayment._id,
          classId: editPayment.classNum,
          studentId: editPayment.sectionId,
          date: editPayment.date,
          paymentStatus: editPayment.paymentStatus,
          paymentMethod: editPayment.paymentMethod,
          feeType: editPayment.feeType,
11f495070   Neeraj Sharma   all solve bugs ed...
285
286
287
          totalAmount: this.feeType.amount.toString(),
          totalDiscount: this.feeType.discount.toString(),
          totalSubTotal: this.feeType.subTotal.toString(),
3e79b2f9f   Neeraj Sharma   implement functio...
288
289
          totalPaidAmount: this.feeType.paidAmount
        };
3e79b2f9f   Neeraj Sharma   implement functio...
290
291
292
293
294
295
        if (feeTypeId == "") {
          delete editInvoiceData.feeType[0].feeTypeId;
        }
        if (editInvoiceData.paymentStatus == "NOT_PAID") {
          delete editInvoiceData.paymentMethod;
        }
c765369af   Neeraj Sharma   solve bugs
296
297
298
299
        if (editInvoiceData.totalPaidAmount == "0") {
          if (editInvoiceData.paymentStatus == "NOT_PAID") {
            delete editInvoiceData.totalPaidAmount;
          }
e03bf1f92   Neeraj Sharma   solved bugs add i...
300
        }
c765369af   Neeraj Sharma   solve bugs
301
302
303
304
        if (editInvoiceData.totalPaidAmount != "0.00") {
          if (this.feeType.subTotal == this.feeType.paidAmount) {
            editInvoiceData.paymentStatus = "FULLY_PAID";
          }
11f495070   Neeraj Sharma   all solve bugs ed...
305
306
307
308
309
310
311
          if (editInvoiceData.totalPaidAmount) {
            if (this.feeType.subTotal != this.feeType.paidAmount) {
              editInvoiceData.paymentStatus = "PARTIALLY_PAID";
              // console.log("PARTIALLY_PAID");
            }
          }
        }
c765369af   Neeraj Sharma   solve bugs
312

11f495070   Neeraj Sharma   all solve bugs ed...
313
314
315
316
317
        if (editInvoiceData.totalSubTotal == "0.00") {
          editInvoiceData.paymentStatus = "FULLY_PAID";
        } else if (editInvoiceData.totalSubTotal != "0.00") {
          if (this.feeType.paidAmount === "0.00") {
            editInvoiceData.paymentStatus = "NOT_PAID";
e03bf1f92   Neeraj Sharma   solved bugs add i...
318
319
          }
        }
3e79b2f9f   Neeraj Sharma   implement functio...
320
321
322
323
324
        http()
          .put("/updateInvoice", editInvoiceData)
          .then(response => {
            // this.getInvoiceList();
            this.snackbar = true;
e03bf1f92   Neeraj Sharma   solved bugs add i...
325
            this.text = "Payment added successfully";
3e79b2f9f   Neeraj Sharma   implement functio...
326
            this.loading = false;
e03bf1f92   Neeraj Sharma   solved bugs add i...
327
            this.$emit("update-Payment");
3e79b2f9f   Neeraj Sharma   implement functio...
328
329
330
331
332
333
334
335
336
337
338
          })
          .catch(error => {
            console.log(error);
            this.snackbar = true;
            this.text = error.response.data.message;
            this.loading = false;
          });
      },
      clear() {
        this.$refs.form.reset();
      },
3e79b2f9f   Neeraj Sharma   implement functio...
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
      deleteSelectFee: function(feeTyp, feeTypeList, index) {
        this.editPayment.feeType.splice(index, 1);
        this.getAmmountDetails(feeTyp, feeTypeList);
        if (this.feeTypeData.length == 0) {
          this.feeType = {
            amount: "0.00",
            discount: "0.00",
            paidAmount: "0.00",
            subTotal: "0.00",
            feeTypeList: ""
          };
        }
      },
      getAllClasses() {
        http()
          .get("/getClassesList", {
            headers: { Authorization: "Bearer " + this.token }
          })
          .then(response => {
            this.addclass = response.data.data;
            this.getAllStudents();
          })
          .catch(error => {
            // 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);
              this.$store.dispatch("Role", null);
            }
          });
      },
      getAllStudents() {
        http()
          .get("/getStudentsList", {
            params: { classId: this.editPayment.classNum },
            headers: { Authorization: "Bearer " + this.token }
          })
          .then(response => {
            this.studentList = response.data.data;
          })
          .catch(err => {
            // console.log("err====>", err);
          });
      },
      getfeeType() {
        http()
          .get("/getFeesList", {
            headers: { Authorization: "Bearer " + this.token }
          })
          .then(response => {
            this.feeTypes = response.data.data;
          })
          .catch(err => {
            // console.log("err====>", err);
          });
      },
      getAmmountDetails(feeTyp, feeTypeList) {
        this.feeTypeData = feeTypeList;
        let feeType = {
          amount: "",
          discount: "",
          subTotal: "",
          subParticularTotal: "",
          paidAmount: ""
        };
        for (let i = 0; i < this.feeTypeData.length; i++) {
          // *********** AMOUNT ***********
c765369af   Neeraj Sharma   solve bugs
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
          if (this.feeTypeData[i].amount) {
            feeType.amount =
              Number(feeType.amount) + Number(this.feeTypeData[i].amount);
            this.feeType.amount = feeType.amount;
            this.feeType.subTotal = feeType.amount;
            this.feeTypeData[i].subTotal = this.feeTypeData[i].amount;
          } else if (this.feeTypeData[0].amount == "") {
            this.feeType.amount = "0.00";
            this.feeTypeData[i].subTotal = "0.00";
            this.feeType.subTotal = "0.00";
          } else if (this.feeTypeData[i].amount == "") {
            this.feeType.amount =
              Number(feeType.amount) + Number(this.feeTypeData[i].amount);
            this.feeTypeData[i].subTotal =
              Number(feeType.amount) + Number(this.feeTypeData[i].amount);
            this.feeType.subTotal =
              Number(feeType.amount) + Number(this.feeTypeData[i].amount);
          }
3e79b2f9f   Neeraj Sharma   implement functio...
426
427
          // *********** DISCOUNT ***********
          if (this.feeTypeData[i].discount) {
ff30cbe86   Neeraj Sharma   remove discount p...
428
429
430
            if (
              Number(this.feeTypeData[i].discount) < this.feeTypeData[i].amount
            ) {
11f495070   Neeraj Sharma   all solve bugs ed...
431
432
433
434
              feeType.discount =
                Number(feeType.discount) + Number(this.feeTypeData[i].discount);
              this.feeType.discount = feeType.discount;
              feeType.subParticularTotal =
ff30cbe86   Neeraj Sharma   remove discount p...
435
                this.feeTypeData[i].amount - this.feeTypeData[i].discount;
11f495070   Neeraj Sharma   all solve bugs ed...
436
437
438
              this.feeTypeData[i].subTotal = feeType.subParticularTotal.toFixed(
                2
              );
ff30cbe86   Neeraj Sharma   remove discount p...
439
440
441
442
            } else if (
              Number(this.feeTypeData[i].discount) >= this.feeTypeData[i].amount
            ) {
              this.feeTypeData[i].discount = this.feeTypeData[i].amount;
11f495070   Neeraj Sharma   all solve bugs ed...
443
444
445
446
              feeType.discount =
                Number(feeType.discount) + Number(this.feeTypeData[i].discount);
              this.feeType.discount = feeType.discount.toString();
              feeType.subParticularTotal =
ff30cbe86   Neeraj Sharma   remove discount p...
447
                this.feeTypeData[i].amount - this.feeTypeData[i].discount;
11f495070   Neeraj Sharma   all solve bugs ed...
448
449
450
451
              this.feeTypeData[
                i
              ].subTotal = feeType.subParticularTotal.toString();
            }
c765369af   Neeraj Sharma   solve bugs
452
453
          } else if (this.feeTypeData[0].discount == "") {
            this.feeType.discount = "0.00";
3e79b2f9f   Neeraj Sharma   implement functio...
454
          }
c765369af   Neeraj Sharma   solve bugs
455

3e79b2f9f   Neeraj Sharma   implement functio...
456
          // *********** SUBTOTAL ***********
c765369af   Neeraj Sharma   solve bugs
457
458
459
460
461
          if (this.feeTypeData[i].subTotal) {
            feeType.subTotal =
              Number(feeType.subTotal) + Number(this.feeTypeData[i].subTotal);
            this.feeType.subTotal = feeType.subTotal.toFixed(2);
          }
3e79b2f9f   Neeraj Sharma   implement functio...
462
          // *********** PAID-AMOUNT ***********
c765369af   Neeraj Sharma   solve bugs
463
464
465
466
467
468
469
470
471
472
          if (this.feeTypeData[i].paidAmount) {
            feeType.paidAmount =
              Number(feeType.paidAmount) + Number(this.feeTypeData[i].paidAmount);
            this.feeType.paidAmount = feeType.paidAmount.toFixed(2);
          } else if (this.feeTypeData[0].paidAmount == "") {
            this.feeType.paidAmount = "0.00";
          } else if (this.feeTypeData[i].paidAmount == "") {
            this.feeType.paidAmount = feeType.paidAmount =
              Number(feeType.paidAmount) + Number(this.feeTypeData[i].paidAmount);
          }
3e79b2f9f   Neeraj Sharma   implement functio...
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
530
531
532
533
534
535
536
537
538
539
  
          // 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;
          }
        }
      }
      // getPayMethodList() {
      //   if (this.editPayment.paymentStatus == "PARTIALLY_PAID") {
      //     this.showPayMethods = true;
      //   } else if (this.editPayment.paymentStatus == "FULLY_PAID") {
      //     this.showPayMethods = true;
      //   } else {
      //     this.showPayMethods = false;
      //   }
      // }
    },
    mounted() {
      this.token = this.$store.state.token;
      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;
  }
  @media screen and (max-width: 380px) {
    .tableRsponsive {
      display: block;
      position: relative;
      overflow: scroll;
    }
  }
  </style>