diff --git a/src/pages/Account/editInvoice.vue b/src/pages/Account/editInvoice.vue index 814e538..49c90f7 100644 --- a/src/pages/Account/editInvoice.vue +++ b/src/pages/Account/editInvoice.vue @@ -35,7 +35,7 @@ v-model="editData.classId" item-text="classNum" item-value="_id" - @change="getAllStudents()" + @change="getAllStudents(editData.classId)" > @@ -47,10 +47,11 @@ @@ -317,7 +318,8 @@ export default { name: "Fully Paid", value: "FULLY_PAID" } - ] + ], + editDataObj: {} }), // watch: { // menu1(val) { @@ -332,18 +334,23 @@ export default { return moment(date).format("MMMM DD, YYYY"); }, update(editData) { - // console.log("editData-----------", editData); + console.log("editData-----------", editData); + if (editData.classId._id) { + this.editDataObj.classNum = editData.classId._id; + } + if (editData.studentId._id) { + this.editDataObj.studentId = editData.studentId._id; + } 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(editData); let editInvoiceData = { invoiceId: editData._id, - classId: editData.classNum, - studentId: editData.sectionId, + classId: this.editDataObj.classNum, + studentId: this.editDataObj.studentId, date: editData.date, paymentStatus: editData.paymentStatus, paymentMethod: editData.paymentMethod, @@ -353,39 +360,41 @@ export default { totalSubTotal: this.feeType.subTotal, totalPaidAmount: this.feeType.paidAmount }; - if (editInvoiceData.paymentStatus == "NOT_PAID") { - delete editInvoiceData.totalPaidAmount; - } + // console.log(editInvoiceData, editInvoiceData); if (feeTypeId == "") { delete editInvoiceData.feeType[0].feeTypeId; } - if (editInvoiceData.paymentStatus == "NOT_PAID") { - delete editInvoiceData.paymentMethod; - } - if (this.feeType.subTotal == this.feeType.paidAmount) { - editInvoiceData.paymentStatus = "FULLY_PAID"; - // console.log("FULLY_PAID"); - } - if (editInvoiceData.totalPaidAmount) { - if (this.feeType.subTotal != this.feeType.paidAmount) { - editInvoiceData.paymentStatus = "PARTIALLY_PAID"; - // console.log("PARTIALLY_PAID"); + if (this.feeType.paidAmount != "0.00") { + if (this.feeType.subTotal == this.feeType.paidAmount) { + editInvoiceData.paymentStatus = "FULLY_PAID"; + console.log("FULLY_PAID"); } + if (editInvoiceData.totalPaidAmount) { + if (this.feeType.subTotal != this.feeType.paidAmount) { + editInvoiceData.paymentStatus = "PARTIALLY_PAID"; + console.log("PARTIALLY_PAID"); + } + } + } else if (this.feeType.paidAmount === "0.00") { + editInvoiceData.paymentStatus = "NOT_PAID"; } + console.log("editInvoiceData", editInvoiceData); + http() .put("/updateInvoice", editInvoiceData) .then(response => { // this.getInvoiceList(); this.snackbar = true; - this.text = "New Invoice added successfully"; + this.text = "Edit Invoice successfully"; this.loading = false; + color: "red"; this.$emit("update-editInvoice"); }) .catch(error => { console.log(error); - if ((this.snackbar = true)) { - this.text = error.response.data.message; - } + this.snackbar = true; + this.text = error.response.data.message; + color: "red"; this.loading = false; }); }, @@ -393,7 +402,6 @@ export default { this.$refs.form.reset(); }, selectFeeType() { - // console.log("clckkkkkkkkkkkkkkkkkk", this.feeType.feeTypeName); this.showFeeType = true; this.editData.feeType.push({ feeTypeName: this.feeType.feeTypeName }); }, @@ -417,7 +425,6 @@ export default { }) .then(response => { this.addclass = response.data.data; - this.getAllStudents(); }) .catch(error => { // console.log("err====>", err); @@ -430,19 +437,35 @@ export default { } }); }, - getAllStudents() { + getAllStudents(classId) { + // console.log("classId", classId); + this.editDataObj.classNum = classId; + this.editDataObj.studentId = ""; + this.studentList = []; + this.showLoader = true; http() .get("/getStudentsList", { - params: { classId: this.editData.classNum }, + params: { classId: classId }, headers: { Authorization: "Bearer " + this.token } }) .then(response => { - this.studentList = response.data.data; + for (let i = 0; i < response.data.data.length; i++) { + this.studentList.push({ + name: response.data.data[i].name, + _id: response.data.data[i]._id + }); + } + this.showLoader = false; }) .catch(err => { // console.log("err====>", err); + this.showLoader = false; }); }, + getStudentId(studentId) { + // console.log("studentId", studentId); + this.editDataObj.studentId = studentId; + }, getfeeType() { http() .get("/getFeesList", { @@ -466,32 +489,58 @@ export default { }; for (let i = 0; i < this.feeTypeData.length; i++) { // *********** AMOUNT *********** - feeType.amount = - Number(feeType.amount) + Number(this.feeTypeData[i].amount); - console.log("feeType.amount ", feeType.amount); - this.feeType.amount = feeType.amount; - this.feeType.subTotal = feeType.amount; - this.feeTypeData[i].subTotal = this.feeTypeData[i].amount; + 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); + } // *********** DISCOUNT *********** if (this.feeTypeData[i].discount) { feeType.discount = Number(feeType.discount) + Number(this.feeTypeData[i].discount); - console.log("feeType.discount", feeType.discount); this.feeType.discount = feeType.discount; feeType.subParticularTotal = this.feeTypeData[i].amount - (this.feeTypeData[i].amount * this.feeTypeData[i].discount) / 100; - console.log("feeType.subTotal", feeType.subTotal); this.feeTypeData[i].subTotal = feeType.subParticularTotal.toFixed(2); + } else if (this.feeTypeData[0].discount == "") { + this.feeType.discount = "0.00"; + } else if (this.feeTypeData[i].discount == "") { + this.feeType.discount = + Number(feeType.discount) + Number(this.feeTypeData[i].discount); } + // *********** SUBTOTAL *********** - feeType.subTotal = - Number(feeType.subTotal) + Number(this.feeTypeData[i].subTotal); - this.feeType.subTotal = feeType.subTotal.toFixed(2); + if (this.feeTypeData[i].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); + 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); + } // if paid Amount fill large of subtotal value so this condition are fixed filled subtotal value. if (feeType.paidAmount > feeType.subTotal) { @@ -505,6 +554,11 @@ export default { this.showPayMethods = true; } else if (this.editData.paymentStatus == "FULLY_PAID") { this.showPayMethods = true; + } else if (this.editData.paymentStatus == "NOT_PAID") { + for (let i = 0; i < this.feeTypeData.length; i++) { + this.feeTypeData[i].paidAmount = "0.00"; + this.feeType.paidAmount = "0.00"; + } } else { this.showPayMethods = false; } diff --git a/src/pages/Account/invoice.vue b/src/pages/Account/invoice.vue index 355704f..57748f1 100644 --- a/src/pages/Account/invoice.vue +++ b/src/pages/Account/invoice.vue @@ -22,191 +22,12 @@ cancel - + @@ -215,7 +36,6 @@ cancel - @@ -870,6 +690,12 @@ export default { this.editedIndex = this.invoiceList.indexOf(item); this.editPayment = Object.assign({}, item); this.editPayment.date = this.editPayment.date.slice(0, 10); + if (this.editPayment.paymentStatus == "NOT_PAID") { + for (let i = 0; i < this.editPayment.feeType.length; i++) { + this.editPayment.feeType[i].paidAmount = "0.00"; + } + } + // console.log("this.editPayment", this.editPayment); this.paymentFeeTypeData = this.editPayment.feeType; this.paymentInvoiceDialog = true; }, @@ -955,24 +781,25 @@ export default { paymentStatus: this.invoiceData.paymentStatus, paymentMethod: this.invoiceData.paymentMethod, feeType: this.feeTypeData, - totalAmount: this.feeType.amount, - totalDiscount: this.feeType.discount, + totalAmount: this.feeType.amount.toString(), + totalDiscount: this.feeType.discount.toString(), totalSubTotal: this.feeType.subTotal, totalPaidAmount: this.feeType.paidAmount }; - console.log("invoiceData", invoiceData); - if (invoiceData.paymentStatus == "NOT_PAID") { - delete invoiceData.totalPaidAmount; - } - if (this.feeType.subTotal == this.feeType.paidAmount) { - invoiceData.paymentStatus = "FULLY_PAID"; - // console.log("FULLY_PAID"); - } - if (invoiceData.totalPaidAmount) { - if (this.feeType.subTotal != this.feeType.paidAmount) { - invoiceData.paymentStatus = "PARTIALLY_PAID"; - // console.log("PARTIALLY_PAID"); + // console.log("invoiceData", invoiceData); + if (this.feeType.paidAmount != "0.00") { + if (this.feeType.subTotal == this.feeType.paidAmount) { + invoiceData.paymentStatus = "FULLY_PAID"; + console.log("FULLY_PAID"); + } + if (invoiceData.totalPaidAmount) { + if (this.feeType.subTotal != this.feeType.paidAmount) { + invoiceData.paymentStatus = "PARTIALLY_PAID"; + console.log("PARTIALLY_PAID"); + } } + } else if (this.feeType.paidAmount === "0.00") { + invoiceData.paymentStatus = "NOT_PAID"; } http() .post("/createInvoice", invoiceData) @@ -1003,40 +830,6 @@ export default { }); } }, - // add() { - // var updatePayment = { - // invoiceId: this.editPayment._id, - // // totalPaidAmount: this.editPayment.paidAmount - // classId: this.editPayment.classNum, - // students: this.editPayment.students, - // date: this.editPayment.date, - // paymentStatus: this.editPayment.paymentStatus, - // paymentMethod: this.editPayment.paymentMethod, - // feeType: this.feeTypeData, - // totalAmount: this.feeType.amount, - // totalDiscount: this.feeType.discount, - // totalSubTotal: this.feeType.subTotal, - // totalPaidAmount: this.feeType.paidAmount - // }; - // http() - // .put("/updateInvoice", updatePayment, { - // headers: { - // Authorization: "Bearer " + this.token - // } - // }) - // .then(response => { - // this.getInvoiceList(); - // this.snackbar = true; - // this.text = response.data.message; - // this.color = "green"; - // this.paymentInvoiceDialog = false; - // }) - // .catch(error => { - // console.log("error", error); - // this.snackbar = true; - // this.color = "red"; - // }); - // }, clear() { this.$refs.form.reset(); }, @@ -1066,9 +859,25 @@ export default { this.feeTypeData.push({ feeTypeName: this.feeType.feeTypeName }); }, deleteSelectFee: function(index) { + console.log("---index----", index); this.feeTypeData.splice(index, 1); for (let i = 0; i < this.feeTypeData.length; i++) { - this.feeType = this.feeTypeData[i]; + console.log("this.feeTypeData[i]", this.feeTypeData[i]); + if (this.feeTypeData[i].paidAmount) { + this.feeType = { + amount: this.feeTypeData[i].amount, + discount: this.feeTypeData[i].discount, + subTotal: this.feeTypeData[i].subTotal, + paidAmount: this.feeTypeData[i].paidAmount + }; + } else { + this.feeType = { + amount: this.feeTypeData[i].amount, + discount: this.feeTypeData[i].discount, + subTotal: this.feeTypeData[i].subTotal, + paidAmount: "0.00" + }; + } } if (this.feeTypeData.length == 0) { this.feeType = { @@ -1145,16 +954,25 @@ export default { }; for (let i = 0; i < this.feeTypeData.length; i++) { // *********** AMOUNT *********** - - feeType.amount = - Number(feeType.amount) + Number(this.feeTypeData[i].amount); - // console.log("feeType.amount ", feeType.amount); - this.feeType.amount = feeType.amount; - this.feeType.subTotal = feeType.amount; - this.feeTypeData[i].subTotal = this.feeTypeData[i].amount; - + 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); + } // *********** DISCOUNT *********** - if (this.feeTypeData[i].discount) { feeType.discount = Number(feeType.discount) + Number(this.feeTypeData[i].discount); @@ -1163,20 +981,32 @@ export default { this.feeTypeData[i].amount - (this.feeTypeData[i].amount * this.feeTypeData[i].discount) / 100; this.feeTypeData[i].subTotal = feeType.subParticularTotal.toFixed(2); + } else if (this.feeTypeData[0].discount == "") { + this.feeType.discount = "0.00"; + } else if (this.feeTypeData[i].discount == "") { + this.feeType.discount = + Number(feeType.discount) + Number(this.feeTypeData[i].discount); } // *********** SUBTOTAL *********** - - feeType.subTotal = - Number(feeType.subTotal) + Number(this.feeTypeData[i].subTotal); - this.feeType.subTotal = feeType.subTotal.toFixed(2); + if (this.feeTypeData[i].subTotal) { + feeType.subTotal = + Number(feeType.subTotal) + Number(this.feeTypeData[i].subTotal); + this.feeType.subTotal = feeType.subTotal.toFixed(2); + } // *********** PAID-AMOUNT *********** 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); } + // 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; @@ -1189,21 +1019,16 @@ export default { this.showPayMethods = true; } else if (this.invoiceData.paymentStatus == "FULLY_PAID") { this.showPayMethods = true; - } else { - this.showPayMethods = false; - } - }, - getPaymentMethod() { - if (this.editData.paymentStatus == "PARTIALLY_PAID") { - this.showPayMethods = true; - } else if (this.editData.paymentStatus == "FULLY_PAID") { - this.showPayMethods = true; + } else if (this.invoiceData.paymentStatus == "NOT_PAID") { + for (let i = 0; i < this.feeTypeData.length; i++) { + this.feeTypeData[i].paidAmount = "0.00"; + this.feeType.paidAmount = "0.00"; + } } else { this.showPayMethods = false; } }, 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++) { @@ -1217,7 +1042,8 @@ export default { } }, displaySearch() { - (this.show = false), (this.showSearch = true); + this.show = false; + this.showSearch = true; }, closeSearch() { this.showSearch = false; diff --git a/src/pages/Account/paymentTemplate.vue b/src/pages/Account/paymentTemplate.vue index 2eb2743..287b140 100644 --- a/src/pages/Account/paymentTemplate.vue +++ b/src/pages/Account/paymentTemplate.vue @@ -154,7 +154,7 @@ type="number" > -
# + feeType.subTotal) { diff --git a/src/pages/Report/progressCardReport.vue b/src/pages/Report/progressCardReport.vue index 86396d4..8320d27 100644 --- a/src/pages/Report/progressCardReport.vue +++ b/src/pages/Report/progressCardReport.vue @@ -58,7 +58,6 @@ item-text="name" item-value="_id" :rules="studentRules" - @change="selectAllStudent()" required > @@ -90,6 +89,7 @@ --> + @@ -344,7 +344,7 @@
- Average Mark + Average Mark
- GPA + GPA { @@ -571,15 +579,12 @@ export default { i < this.filterData[data][item].studentsMarks.length; i++ ) { - // console.log("this.filterData[data][item].studentsMarks[i]",this.filterData[data][item].studentsMarks[i] - // .marksScored) totalMarks += this.filterData[data][item].studentsMarks[i] .marksScored; } this.filterData[data][item].totalMarks = totalMarks; console.log("totalMarks", totalMarks); this.totalMarks = totalMarks; - // console.log("this.filterData[data][item].grade", this.filterData[data][item].grade); if (totalMarks > 90) { this.filterData[data][item].grade = this.gradeAPlus; } else if (totalMarks > 80 && totalMarks < 90) {