Commit d650dbf7d2e3e109d97b348d5e2de6980482a8b9

Authored by Neeraj Sharma
1 parent 728b5d417a

edit invoice issue solve payment method

src/pages/Account/editInvoice.vue
... ... @@ -108,6 +108,7 @@
108 108 <v-select
109 109 :items="paymentMethods"
110 110 v-model="editData.paymentMethod"
  111 + :rules="paymentMethodRules"
111 112 label="Select Payment Method"
112 113 ></v-select>
113 114 </v-flex>
... ... @@ -305,6 +306,7 @@ export default {
305 306 invoiceParticularData: {},
306 307 addclass: [],
307 308 studentList: [],
  309 + paymentMethodRules: [],
308 310 paymentStatus: [
309 311 {
310 312 name: "Not Paid",
... ... @@ -334,7 +336,7 @@ export default {
334 336 return moment(date).format("MMMM DD, YYYY");
335 337 },
336 338 update(editData) {
337   - console.log("editData-----------", editData);
  339 + // console.log("editData-----------", editData);
338 340 if (editData.classId._id) {
339 341 this.editDataObj.classNum = editData.classId._id;
340 342 }
... ... @@ -347,56 +349,61 @@ export default {
347 349 feeTypeId = this.feeTypes[i]._id;
348 350 }
349 351 }
350   - let editInvoiceData = {
351   - invoiceId: editData._id,
352   - classId: this.editDataObj.classNum,
353   - studentId: this.editDataObj.studentId,
354   - date: editData.date,
355   - paymentStatus: editData.paymentStatus,
356   - paymentMethod: editData.paymentMethod,
357   - feeType: editData.feeType,
358   - totalAmount: this.feeType.amount,
359   - totalDiscount: this.feeType.discount,
360   - totalSubTotal: this.feeType.subTotal,
361   - totalPaidAmount: this.feeType.paidAmount
362   - };
363   - // console.log(editInvoiceData, editInvoiceData);
364   - if (feeTypeId == "") {
365   - delete editInvoiceData.feeType[0].feeTypeId;
366   - }
367   - if (this.feeType.paidAmount != "0.00") {
368   - if (this.feeType.subTotal == this.feeType.paidAmount) {
369   - editInvoiceData.paymentStatus = "FULLY_PAID";
370   - console.log("FULLY_PAID");
  352 + if (this.$refs.form.validate()) {
  353 + let editInvoiceData = {
  354 + invoiceId: editData._id,
  355 + classId: this.editDataObj.classNum,
  356 + studentId: this.editDataObj.studentId,
  357 + date: editData.date,
  358 + paymentStatus: editData.paymentStatus,
  359 + paymentMethod: editData.paymentMethod,
  360 + feeType: editData.feeType,
  361 + totalAmount: this.feeType.amount,
  362 + totalDiscount: this.feeType.discount,
  363 + totalSubTotal: this.feeType.subTotal,
  364 + totalPaidAmount: this.feeType.paidAmount
  365 + };
  366 + // console.log(editInvoiceData, editInvoiceData);
  367 + if (feeTypeId == "") {
  368 + delete editInvoiceData.feeType[0].feeTypeId;
  369 + }
  370 + if (editInvoiceData.paymentStatus == "NOT_PAID") {
  371 + delete editInvoiceData.paymentMethod;
371 372 }
372   - if (editInvoiceData.totalPaidAmount) {
373   - if (this.feeType.subTotal != this.feeType.paidAmount) {
374   - editInvoiceData.paymentStatus = "PARTIALLY_PAID";
375   - console.log("PARTIALLY_PAID");
  373 + if (this.feeType.paidAmount != "0.00") {
  374 + if (this.feeType.subTotal == this.feeType.paidAmount) {
  375 + editInvoiceData.paymentStatus = "FULLY_PAID";
  376 + // console.log("FULLY_PAID");
376 377 }
  378 + if (editInvoiceData.totalPaidAmount) {
  379 + if (this.feeType.subTotal != this.feeType.paidAmount) {
  380 + editInvoiceData.paymentStatus = "PARTIALLY_PAID";
  381 + // console.log("PARTIALLY_PAID");
  382 + }
  383 + }
  384 + } else if (this.feeType.paidAmount === "0.00") {
  385 + editInvoiceData.paymentStatus = "NOT_PAID";
377 386 }
378   - } else if (this.feeType.paidAmount === "0.00") {
379   - editInvoiceData.paymentStatus = "NOT_PAID";
380   - }
381   - console.log("editInvoiceData", editInvoiceData);
  387 + // console.log("editInvoiceData", editInvoiceData);
382 388  
383   - http()
384   - .put("/updateInvoice", editInvoiceData)
385   - .then(response => {
386   - // this.getInvoiceList();
387   - this.snackbar = true;
388   - this.text = "Edit Invoice successfully";
389   - this.loading = false;
390   - color: "red";
391   - this.$emit("update-editInvoice");
392   - })
393   - .catch(error => {
394   - console.log(error);
395   - this.snackbar = true;
396   - this.text = error.response.data.message;
397   - color: "red";
398   - this.loading = false;
399   - });
  389 + http()
  390 + .put("/updateInvoice", editInvoiceData)
  391 + .then(response => {
  392 + // this.getInvoiceList();
  393 + this.snackbar = true;
  394 + this.text = "Edit Invoice successfully";
  395 + this.loading = false;
  396 + color: "red";
  397 + this.$emit("update-editInvoice");
  398 + })
  399 + .catch(error => {
  400 + console.log(error);
  401 + this.snackbar = true;
  402 + this.text = error.response.data.message;
  403 + color: "red";
  404 + this.loading = false;
  405 + });
  406 + }
400 407 },
401 408 clear() {
402 409 this.$refs.form.reset();
... ... @@ -552,13 +559,17 @@ export default {
552 559 getPayMethodList() {
553 560 if (this.editData.paymentStatus == "PARTIALLY_PAID") {
554 561 this.showPayMethods = true;
  562 + this.paymentMethodRules = [v => !!v || "Payment Method is required"];
555 563 } else if (this.editData.paymentStatus == "FULLY_PAID") {
556 564 this.showPayMethods = true;
  565 + this.paymentMethodRules = [v => !!v || "Payment Method is required"];
557 566 } else if (this.editData.paymentStatus == "NOT_PAID") {
558 567 for (let i = 0; i < this.feeTypeData.length; i++) {
559 568 this.feeTypeData[i].paidAmount = "0.00";
560 569 this.feeType.paidAmount = "0.00";
561 570 }
  571 + this.paymentMethodRules = "";
  572 + this.showPayMethods = false;
562 573 } else {
563 574 this.showPayMethods = false;
564 575 }
... ...
src/pages/Account/invoice.vue
... ... @@ -792,12 +792,12 @@ export default {
792 792 if (this.feeType.paidAmount != "0.00") {
793 793 if (this.feeType.subTotal == this.feeType.paidAmount) {
794 794 invoiceData.paymentStatus = "FULLY_PAID";
795   - console.log("FULLY_PAID");
  795 + // console.log("FULLY_PAID");
796 796 }
797 797 if (invoiceData.totalPaidAmount) {
798 798 if (this.feeType.subTotal != this.feeType.paidAmount) {
799 799 invoiceData.paymentStatus = "PARTIALLY_PAID";
800   - console.log("PARTIALLY_PAID");
  800 + // console.log("PARTIALLY_PAID");
801 801 }
802 802 }
803 803 } else if (this.feeType.paidAmount === "0.00") {
... ... @@ -861,10 +861,10 @@ export default {
861 861 this.feeTypeData.push({ feeTypeName: this.feeType.feeTypeName });
862 862 },
863 863 deleteSelectFee: function(index) {
864   - console.log("---index----", index);
  864 + // console.log("---index----", index);
865 865 this.feeTypeData.splice(index, 1);
866 866 for (let i = 0; i < this.feeTypeData.length; i++) {
867   - console.log("this.feeTypeData[i]", this.feeTypeData[i]);
  867 + // console.log("this.feeTypeData[i]", this.feeTypeData[i]);
868 868 if (this.feeTypeData[i].paidAmount) {
869 869 this.feeType = {
870 870 amount: this.feeTypeData[i].amount,
... ...