Rohit Waghchaure | 6087fe1 | 2016-04-09 14:31:09 +0530 | [diff] [blame] | 1 | // Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors |
| 2 | // License: GNU General Public License v3. See license.txt |
| 3 | |
Faris Ansari | 1fe891b | 2021-04-23 08:04:00 +0530 | [diff] [blame] | 4 | erpnext.payments = class payments extends erpnext.stock.StockController { |
| 5 | make_payment() { |
Rohit Waghchaure | 6087fe1 | 2016-04-09 14:31:09 +0530 | [diff] [blame] | 6 | var me = this; |
| 7 | |
| 8 | this.dialog = new frappe.ui.Dialog({ |
Ankush Menat | ec74a5e | 2024-03-10 19:45:40 +0530 | [diff] [blame] | 9 | title: "Payment", |
Rohit Waghchaure | 6087fe1 | 2016-04-09 14:31:09 +0530 | [diff] [blame] | 10 | }); |
Faris Ansari | 1fe891b | 2021-04-23 08:04:00 +0530 | [diff] [blame] | 11 | |
Rohit Waghchaure | 6087fe1 | 2016-04-09 14:31:09 +0530 | [diff] [blame] | 12 | this.dialog.show(); |
| 13 | this.$body = this.dialog.body; |
Rohit Waghchaure | 6087fe1 | 2016-04-09 14:31:09 +0530 | [diff] [blame] | 14 | this.set_payment_primary_action(); |
| 15 | this.make_keyboard(); |
Deepesh Garg | e2f83ff | 2021-05-16 17:46:07 +0530 | [diff] [blame] | 16 | this.select_text(); |
Faris Ansari | 1fe891b | 2021-04-23 08:04:00 +0530 | [diff] [blame] | 17 | } |
Rohit Waghchaure | baef262 | 2016-08-05 15:41:36 +0530 | [diff] [blame] | 18 | |
Deepesh Garg | b07f7d1 | 2021-05-20 17:08:57 +0530 | [diff] [blame] | 19 | select_text() { |
Ankush Menat | ec74a5e | 2024-03-10 19:45:40 +0530 | [diff] [blame] | 20 | $(this.$body) |
| 21 | .find(".form-control") |
| 22 | .click(function () { |
| 23 | $(this).select(); |
| 24 | }); |
Faris Ansari | 1fe891b | 2021-04-23 08:04:00 +0530 | [diff] [blame] | 25 | } |
Rohit Waghchaure | 6087fe1 | 2016-04-09 14:31:09 +0530 | [diff] [blame] | 26 | |
Ankush | fd84847 | 2021-06-16 11:14:40 +0530 | [diff] [blame] | 27 | set_payment_primary_action() { |
Rohit Waghchaure | 6087fe1 | 2016-04-09 14:31:09 +0530 | [diff] [blame] | 28 | var me = this; |
Faris Ansari | 1fe891b | 2021-04-23 08:04:00 +0530 | [diff] [blame] | 29 | |
Ankush Menat | ec74a5e | 2024-03-10 19:45:40 +0530 | [diff] [blame] | 30 | this.dialog.set_primary_action(__("Submit"), function () { |
Cesar | d8b1927 | 2018-01-29 15:39:52 +0100 | [diff] [blame] | 31 | // Allow no ZERO payment |
Helkyd | 3264c13 | 2017-11-22 16:06:22 +0100 | [diff] [blame] | 32 | $.each(me.frm.doc.payments, function (index, data) { |
| 33 | if (data.amount != 0) { |
| 34 | me.dialog.hide(); |
| 35 | me.submit_invoice(); |
| 36 | return; |
| 37 | } |
Cesar | d8b1927 | 2018-01-29 15:39:52 +0100 | [diff] [blame] | 38 | }); |
Ankush Menat | ec74a5e | 2024-03-10 19:45:40 +0530 | [diff] [blame] | 39 | }); |
Faris Ansari | 1fe891b | 2021-04-23 08:04:00 +0530 | [diff] [blame] | 40 | } |
Rohit Waghchaure | 6087fe1 | 2016-04-09 14:31:09 +0530 | [diff] [blame] | 41 | |
Ankush Menat | ec74a5e | 2024-03-10 19:45:40 +0530 | [diff] [blame] | 42 | make_keyboard() { |
Rohit Waghchaure | 6087fe1 | 2016-04-09 14:31:09 +0530 | [diff] [blame] | 43 | var me = this; |
| 44 | $(this.$body).empty(); |
Ankush Menat | ec74a5e | 2024-03-10 19:45:40 +0530 | [diff] [blame] | 45 | $(this.$body).html(frappe.render_template("pos_payment", this.frm.doc)); |
Rohit Waghchaure | 6087fe1 | 2016-04-09 14:31:09 +0530 | [diff] [blame] | 46 | this.show_payment_details(); |
Ankush Menat | ec74a5e | 2024-03-10 19:45:40 +0530 | [diff] [blame] | 47 | this.bind_keyboard_event(); |
| 48 | this.clear_amount(); |
Faris Ansari | 1fe891b | 2021-04-23 08:04:00 +0530 | [diff] [blame] | 49 | } |
Rohit Waghchaure | 6087fe1 | 2016-04-09 14:31:09 +0530 | [diff] [blame] | 50 | |
Ankush Menat | ec74a5e | 2024-03-10 19:45:40 +0530 | [diff] [blame] | 51 | make_multimode_payment() { |
Rohit Waghchaure | 6087fe1 | 2016-04-09 14:31:09 +0530 | [diff] [blame] | 52 | var me = this; |
| 53 | |
Deepesh Garg | e2f83ff | 2021-05-16 17:46:07 +0530 | [diff] [blame] | 54 | if (this.frm.doc.change_amount > 0) { |
| 55 | me.payment_val = me.doc.outstanding_amount; |
Rohit Waghchaure | 6087fe1 | 2016-04-09 14:31:09 +0530 | [diff] [blame] | 56 | } |
| 57 | |
Ankush Menat | ec74a5e | 2024-03-10 19:45:40 +0530 | [diff] [blame] | 58 | this.payments = frappe.model.add_child(this.frm.doc, "Multi Mode Payment", "payments"); |
Rohit Waghchaure | 6087fe1 | 2016-04-09 14:31:09 +0530 | [diff] [blame] | 59 | this.payments.mode_of_payment = this.dialog.fields_dict.mode_of_payment.get_value(); |
| 60 | this.payments.amount = flt(this.payment_val); |
Faris Ansari | 1fe891b | 2021-04-23 08:04:00 +0530 | [diff] [blame] | 61 | } |
Rohit Waghchaure | 6087fe1 | 2016-04-09 14:31:09 +0530 | [diff] [blame] | 62 | |
Ankush Menat | ec74a5e | 2024-03-10 19:45:40 +0530 | [diff] [blame] | 63 | show_payment_details() { |
Rohit Waghchaure | 6087fe1 | 2016-04-09 14:31:09 +0530 | [diff] [blame] | 64 | var me = this; |
Ankush Menat | ec74a5e | 2024-03-10 19:45:40 +0530 | [diff] [blame] | 65 | var multimode_payments = $(this.$body).find(".multimode-payments").empty(); |
Deepesh Garg | b07f7d1 | 2021-05-20 17:08:57 +0530 | [diff] [blame] | 66 | if (this.frm.doc.payments.length) { |
Ankush Menat | ec74a5e | 2024-03-10 19:45:40 +0530 | [diff] [blame] | 67 | $.each(this.frm.doc.payments, function (index, data) { |
| 68 | $( |
| 69 | frappe.render_template("payment_details", { |
| 70 | mode_of_payment: data.mode_of_payment, |
| 71 | amount: data.amount, |
| 72 | idx: data.idx, |
| 73 | currency: me.frm.doc.currency, |
| 74 | type: data.type, |
| 75 | }) |
| 76 | ).appendTo(multimode_payments); |
Rohit Waghchaure | a88dec8 | 2016-07-30 16:49:48 +0530 | [diff] [blame] | 77 | |
Ankush Menat | ec74a5e | 2024-03-10 19:45:40 +0530 | [diff] [blame] | 78 | if (data.type == "Cash" && data.amount == me.frm.doc.paid_amount) { |
Rohit Waghchaure | a88dec8 | 2016-07-30 16:49:48 +0530 | [diff] [blame] | 79 | me.idx = data.idx; |
Ankush Menat | ec74a5e | 2024-03-10 19:45:40 +0530 | [diff] [blame] | 80 | me.selected_mode = $(me.$body).find(repl("input[idx='%(idx)s']", { idx: me.idx })); |
Rohit Waghchaure | a88dec8 | 2016-07-30 16:49:48 +0530 | [diff] [blame] | 81 | me.highlight_selected_row(); |
| 82 | me.bind_amount_change_event(); |
| 83 | } |
Ankush Menat | ec74a5e | 2024-03-10 19:45:40 +0530 | [diff] [blame] | 84 | }); |
| 85 | } else { |
| 86 | $("<p>No payment mode selected in pos profile</p>").appendTo(multimode_payments); |
Rohit Waghchaure | 6087fe1 | 2016-04-09 14:31:09 +0530 | [diff] [blame] | 87 | } |
Faris Ansari | 1fe891b | 2021-04-23 08:04:00 +0530 | [diff] [blame] | 88 | } |
Rohit Waghchaure | 9fe40d5 | 2016-06-13 21:37:10 +0530 | [diff] [blame] | 89 | |
Ankush Menat | ec74a5e | 2024-03-10 19:45:40 +0530 | [diff] [blame] | 90 | set_outstanding_amount() { |
| 91 | this.selected_mode = $(this.$body).find(repl("input[idx='%(idx)s']", { idx: this.idx })); |
Deepesh Garg | 36d47f9 | 2021-05-21 11:16:26 +0530 | [diff] [blame] | 92 | this.highlight_selected_row(); |
| 93 | this.payment_val = 0.0; |
Deepesh Garg | b07f7d1 | 2021-05-20 17:08:57 +0530 | [diff] [blame] | 94 | if (this.frm.doc.outstanding_amount > 0 && flt(this.selected_mode.val()) == 0.0) { |
Rohit Waghchaure | 88514a2 | 2016-07-19 20:04:44 +0530 | [diff] [blame] | 95 | //When user first time click on row |
Ankush Menat | ec74a5e | 2024-03-10 19:45:40 +0530 | [diff] [blame] | 96 | this.payment_val = flt( |
| 97 | this.frm.doc.outstanding_amount / this.frm.doc.conversion_rate, |
| 98 | precision("outstanding_amount") |
| 99 | ); |
Rohit Waghchaure | 609e2b4 | 2016-08-31 02:04:37 +0530 | [diff] [blame] | 100 | this.selected_mode.val(format_currency(this.payment_val, this.frm.doc.currency)); |
Deepesh Garg | b07f7d1 | 2021-05-20 17:08:57 +0530 | [diff] [blame] | 101 | this.update_payment_amount(); |
| 102 | } else if (flt(this.selected_mode.val()) > 0) { |
Rohit Waghchaure | 9fe40d5 | 2016-06-13 21:37:10 +0530 | [diff] [blame] | 103 | //If user click on existing row which has value |
| 104 | this.payment_val = flt(this.selected_mode.val()); |
| 105 | } |
Ankush Menat | ec74a5e | 2024-03-10 19:45:40 +0530 | [diff] [blame] | 106 | this.selected_mode.select(); |
Rohit Waghchaure | 9fe40d5 | 2016-06-13 21:37:10 +0530 | [diff] [blame] | 107 | this.bind_amount_change_event(); |
Faris Ansari | 1fe891b | 2021-04-23 08:04:00 +0530 | [diff] [blame] | 108 | } |
| 109 | |
Ankush Menat | ec74a5e | 2024-03-10 19:45:40 +0530 | [diff] [blame] | 110 | bind_keyboard_event() { |
Rohit Waghchaure | 6087fe1 | 2016-04-09 14:31:09 +0530 | [diff] [blame] | 111 | var me = this; |
Ankush Menat | ec74a5e | 2024-03-10 19:45:40 +0530 | [diff] [blame] | 112 | this.payment_val = ""; |
Rohit Waghchaure | baef262 | 2016-08-05 15:41:36 +0530 | [diff] [blame] | 113 | this.bind_form_control_event(); |
| 114 | this.bind_numeric_keys_event(); |
Faris Ansari | 1fe891b | 2021-04-23 08:04:00 +0530 | [diff] [blame] | 115 | } |
Rohit Waghchaure | 9fe40d5 | 2016-06-13 21:37:10 +0530 | [diff] [blame] | 116 | |
Ankush | fd84847 | 2021-06-16 11:14:40 +0530 | [diff] [blame] | 117 | bind_form_control_event() { |
Rohit Waghchaure | 6087fe1 | 2016-04-09 14:31:09 +0530 | [diff] [blame] | 118 | var me = this; |
Ankush Menat | ec74a5e | 2024-03-10 19:45:40 +0530 | [diff] [blame] | 119 | $(this.$body) |
| 120 | .find(".pos-payment-row") |
| 121 | .click(function () { |
| 122 | me.idx = $(this).attr("idx"); |
| 123 | me.set_outstanding_amount(); |
| 124 | }); |
Faris Ansari | 1fe891b | 2021-04-23 08:04:00 +0530 | [diff] [blame] | 125 | |
Ankush Menat | ec74a5e | 2024-03-10 19:45:40 +0530 | [diff] [blame] | 126 | $(this.$body) |
| 127 | .find(".form-control") |
| 128 | .click(function () { |
| 129 | me.idx = $(this).attr("idx"); |
| 130 | me.set_outstanding_amount(); |
| 131 | me.update_paid_amount(true); |
| 132 | }); |
Faris Ansari | 1fe891b | 2021-04-23 08:04:00 +0530 | [diff] [blame] | 133 | |
Ankush Menat | ec74a5e | 2024-03-10 19:45:40 +0530 | [diff] [blame] | 134 | $(this.$body) |
| 135 | .find(".write_off_amount") |
| 136 | .change(function () { |
| 137 | me.write_off_amount(flt($(this).val()), precision("write_off_amount")); |
| 138 | }); |
Faris Ansari | 1fe891b | 2021-04-23 08:04:00 +0530 | [diff] [blame] | 139 | |
Ankush Menat | ec74a5e | 2024-03-10 19:45:40 +0530 | [diff] [blame] | 140 | $(this.$body) |
| 141 | .find(".change_amount") |
| 142 | .change(function () { |
| 143 | me.change_amount(flt($(this).val()), precision("change_amount")); |
| 144 | }); |
Ankush | fd84847 | 2021-06-16 11:14:40 +0530 | [diff] [blame] | 145 | } |
Rohit Waghchaure | 9fe40d5 | 2016-06-13 21:37:10 +0530 | [diff] [blame] | 146 | |
Deepesh Garg | b07f7d1 | 2021-05-20 17:08:57 +0530 | [diff] [blame] | 147 | highlight_selected_row() { |
Ankush Menat | ec74a5e | 2024-03-10 19:45:40 +0530 | [diff] [blame] | 148 | var selected_row = $(this.$body).find(repl(".pos-payment-row[idx='%(idx)s']", { idx: this.idx })); |
| 149 | $(this.$body).find(".pos-payment-row").removeClass("selected-payment-mode"); |
| 150 | selected_row.addClass("selected-payment-mode"); |
| 151 | $(this.$body).find(".amount").attr("disabled", true); |
| 152 | this.selected_mode.attr("disabled", false); |
Ankush | fd84847 | 2021-06-16 11:14:40 +0530 | [diff] [blame] | 153 | } |
Faris Ansari | 1fe891b | 2021-04-23 08:04:00 +0530 | [diff] [blame] | 154 | |
Ankush | fd84847 | 2021-06-16 11:14:40 +0530 | [diff] [blame] | 155 | bind_numeric_keys_event() { |
Rohit Waghchaure | 6087fe1 | 2016-04-09 14:31:09 +0530 | [diff] [blame] | 156 | var me = this; |
Ankush Menat | ec74a5e | 2024-03-10 19:45:40 +0530 | [diff] [blame] | 157 | $(this.$body) |
| 158 | .find(".pos-keyboard-key") |
| 159 | .click(function () { |
| 160 | me.payment_val += $(this).text(); |
| 161 | me.selected_mode.val(format_currency(me.payment_val, me.frm.doc.currency)); |
| 162 | me.idx = me.selected_mode.attr("idx"); |
| 163 | me.update_paid_amount(); |
| 164 | }); |
Faris Ansari | 1fe891b | 2021-04-23 08:04:00 +0530 | [diff] [blame] | 165 | |
Ankush Menat | ec74a5e | 2024-03-10 19:45:40 +0530 | [diff] [blame] | 166 | $(this.$body) |
| 167 | .find(".delete-btn") |
| 168 | .click(function () { |
| 169 | me.payment_val = cstr(flt(me.selected_mode.val())).slice(0, -1); |
| 170 | me.selected_mode.val(format_currency(me.payment_val, me.frm.doc.currency)); |
| 171 | me.idx = me.selected_mode.attr("idx"); |
| 172 | me.update_paid_amount(); |
| 173 | }); |
Faris Ansari | 1fe891b | 2021-04-23 08:04:00 +0530 | [diff] [blame] | 174 | } |
| 175 | |
Deepesh Garg | b07f7d1 | 2021-05-20 17:08:57 +0530 | [diff] [blame] | 176 | bind_amount_change_event() { |
Rohit Waghchaure | 6087fe1 | 2016-04-09 14:31:09 +0530 | [diff] [blame] | 177 | var me = this; |
Ankush Menat | ec74a5e | 2024-03-10 19:45:40 +0530 | [diff] [blame] | 178 | this.selected_mode.change(function () { |
| 179 | me.payment_val = flt($(this).val()) || 0.0; |
Deepesh Garg | e2f83ff | 2021-05-16 17:46:07 +0530 | [diff] [blame] | 180 | me.selected_mode.val(format_currency(me.payment_val, me.frm.doc.currency)); |
| 181 | me.idx = me.selected_mode.attr("idx"); |
| 182 | me.update_payment_amount(); |
| 183 | }); |
Faris Ansari | 1fe891b | 2021-04-23 08:04:00 +0530 | [diff] [blame] | 184 | } |
Rohit Waghchaure | 9fe40d5 | 2016-06-13 21:37:10 +0530 | [diff] [blame] | 185 | |
Faris Ansari | 1fe891b | 2021-04-23 08:04:00 +0530 | [diff] [blame] | 186 | clear_amount() { |
Rohit Waghchaure | 9fe40d5 | 2016-06-13 21:37:10 +0530 | [diff] [blame] | 187 | var me = this; |
Ankush Menat | ec74a5e | 2024-03-10 19:45:40 +0530 | [diff] [blame] | 188 | $(this.$body) |
| 189 | .find(".clr") |
| 190 | .click(function (e) { |
| 191 | e.stopPropagation(); |
| 192 | me.idx = $(this).attr("idx"); |
| 193 | me.selected_mode = $(me.$body).find(repl("input[idx='%(idx)s']", { idx: me.idx })); |
| 194 | me.payment_val = 0.0; |
| 195 | me.selected_mode.val(0.0); |
| 196 | me.highlight_selected_row(); |
| 197 | me.update_payment_amount(); |
| 198 | }); |
Faris Ansari | 1fe891b | 2021-04-23 08:04:00 +0530 | [diff] [blame] | 199 | } |
Rohit Waghchaure | 9fe40d5 | 2016-06-13 21:37:10 +0530 | [diff] [blame] | 200 | |
Faris Ansari | 1fe891b | 2021-04-23 08:04:00 +0530 | [diff] [blame] | 201 | write_off_amount(write_off_amount) { |
Rohit Waghchaure | 713e2b7 | 2016-08-19 15:11:36 +0530 | [diff] [blame] | 202 | this.frm.doc.write_off_amount = flt(write_off_amount, precision("write_off_amount")); |
Ankush Menat | ec74a5e | 2024-03-10 19:45:40 +0530 | [diff] [blame] | 203 | this.frm.doc.base_write_off_amount = flt( |
| 204 | this.frm.doc.write_off_amount * this.frm.doc.conversion_rate, |
| 205 | precision("base_write_off_amount") |
| 206 | ); |
Deepesh Garg | e2f83ff | 2021-05-16 17:46:07 +0530 | [diff] [blame] | 207 | this.calculate_outstanding_amount(false); |
| 208 | this.show_amounts(); |
Faris Ansari | 1fe891b | 2021-04-23 08:04:00 +0530 | [diff] [blame] | 209 | } |
Rohit Waghchaure | baef262 | 2016-08-05 15:41:36 +0530 | [diff] [blame] | 210 | |
Faris Ansari | 1fe891b | 2021-04-23 08:04:00 +0530 | [diff] [blame] | 211 | change_amount(change_amount) { |
Rohit Waghchaure | baef262 | 2016-08-05 15:41:36 +0530 | [diff] [blame] | 212 | var me = this; |
| 213 | |
Rohit Waghchaure | 713e2b7 | 2016-08-19 15:11:36 +0530 | [diff] [blame] | 214 | this.frm.doc.change_amount = flt(change_amount, precision("change_amount")); |
Deepesh Garg | e2f83ff | 2021-05-16 17:46:07 +0530 | [diff] [blame] | 215 | this.calculate_write_off_amount(); |
| 216 | this.show_amounts(); |
Ankush | fd84847 | 2021-06-16 11:14:40 +0530 | [diff] [blame] | 217 | } |
Rohit Waghchaure | baef262 | 2016-08-05 15:41:36 +0530 | [diff] [blame] | 218 | |
Faris Ansari | 1fe891b | 2021-04-23 08:04:00 +0530 | [diff] [blame] | 219 | update_paid_amount(update_write_off) { |
Rohit Waghchaure | baef262 | 2016-08-05 15:41:36 +0530 | [diff] [blame] | 220 | var me = this; |
barredterra | d238751 | 2024-03-19 12:03:36 +0100 | [diff] [blame] | 221 | if (["change_amount", "write_off_amount"].includes(this.idx)) { |
Faris Ansari | ab74ca7 | 2017-05-30 12:54:42 +0530 | [diff] [blame] | 222 | var value = me.selected_mode.val(); |
Ankush Menat | ec74a5e | 2024-03-10 19:45:40 +0530 | [diff] [blame] | 223 | if (me.idx == "change_amount") { |
Deepesh Garg | e2f83ff | 2021-05-16 17:46:07 +0530 | [diff] [blame] | 224 | me.change_amount(value); |
Deepesh Garg | b07f7d1 | 2021-05-20 17:08:57 +0530 | [diff] [blame] | 225 | } else { |
Ankush Menat | ec74a5e | 2024-03-10 19:45:40 +0530 | [diff] [blame] | 226 | if (flt(value) == 0 && update_write_off && me.frm.doc.outstanding_amount > 0) { |
| 227 | value = flt( |
| 228 | me.frm.doc.outstanding_amount / me.frm.doc.conversion_rate, |
| 229 | precision(me.idx) |
| 230 | ); |
Rohit Waghchaure | baef262 | 2016-08-05 15:41:36 +0530 | [diff] [blame] | 231 | } |
Deepesh Garg | e2f83ff | 2021-05-16 17:46:07 +0530 | [diff] [blame] | 232 | me.write_off_amount(value); |
Rohit Waghchaure | baef262 | 2016-08-05 15:41:36 +0530 | [diff] [blame] | 233 | } |
Deepesh Garg | e2f83ff | 2021-05-16 17:46:07 +0530 | [diff] [blame] | 234 | } else { |
| 235 | this.update_payment_amount(); |
Rohit Waghchaure | baef262 | 2016-08-05 15:41:36 +0530 | [diff] [blame] | 236 | } |
Faris Ansari | 1fe891b | 2021-04-23 08:04:00 +0530 | [diff] [blame] | 237 | } |
Rohit Waghchaure | baef262 | 2016-08-05 15:41:36 +0530 | [diff] [blame] | 238 | |
Ankush Menat | ec74a5e | 2024-03-10 19:45:40 +0530 | [diff] [blame] | 239 | update_payment_amount() { |
Rohit Waghchaure | baef262 | 2016-08-05 15:41:36 +0530 | [diff] [blame] | 240 | var me = this; |
| 241 | |
Ankush Menat | ec74a5e | 2024-03-10 19:45:40 +0530 | [diff] [blame] | 242 | $.each(this.frm.doc.payments, function (index, data) { |
Deepesh Garg | b07f7d1 | 2021-05-20 17:08:57 +0530 | [diff] [blame] | 243 | if (cint(me.idx) == cint(data.idx)) { |
Deepesh Garg | e2f83ff | 2021-05-16 17:46:07 +0530 | [diff] [blame] | 244 | data.amount = flt(me.selected_mode.val(), 2); |
Rohit Waghchaure | 6087fe1 | 2016-04-09 14:31:09 +0530 | [diff] [blame] | 245 | } |
Ankush Menat | ec74a5e | 2024-03-10 19:45:40 +0530 | [diff] [blame] | 246 | }); |
Rohit Waghchaure | baef262 | 2016-08-05 15:41:36 +0530 | [diff] [blame] | 247 | |
Rohit Waghchaure | 61b4a43 | 2016-07-20 11:21:51 +0530 | [diff] [blame] | 248 | this.calculate_outstanding_amount(false); |
Rohit Waghchaure | 6087fe1 | 2016-04-09 14:31:09 +0530 | [diff] [blame] | 249 | this.show_amounts(); |
Faris Ansari | 1fe891b | 2021-04-23 08:04:00 +0530 | [diff] [blame] | 250 | } |
Rohit Waghchaure | baef262 | 2016-08-05 15:41:36 +0530 | [diff] [blame] | 251 | |
Ankush Menat | ec74a5e | 2024-03-10 19:45:40 +0530 | [diff] [blame] | 252 | show_amounts() { |
Rohit Waghchaure | 6087fe1 | 2016-04-09 14:31:09 +0530 | [diff] [blame] | 253 | var me = this; |
Ankush Menat | ec74a5e | 2024-03-10 19:45:40 +0530 | [diff] [blame] | 254 | $(this.$body) |
| 255 | .find(".write_off_amount") |
| 256 | .val(format_currency(this.frm.doc.write_off_amount, this.frm.doc.currency)); |
| 257 | $(this.$body) |
| 258 | .find(".paid_amount") |
| 259 | .text(format_currency(this.frm.doc.paid_amount, this.frm.doc.currency)); |
| 260 | $(this.$body) |
| 261 | .find(".change_amount") |
| 262 | .val(format_currency(this.frm.doc.change_amount, this.frm.doc.currency)); |
| 263 | $(this.$body) |
| 264 | .find(".outstanding_amount") |
| 265 | .text( |
| 266 | format_currency( |
| 267 | this.frm.doc.outstanding_amount, |
| 268 | frappe.get_doc(":Company", this.frm.doc.company).default_currency |
| 269 | ) |
| 270 | ); |
Rohit Waghchaure | 6087fe1 | 2016-04-09 14:31:09 +0530 | [diff] [blame] | 271 | this.update_invoice(); |
| 272 | } |
Ankush Menat | ec74a5e | 2024-03-10 19:45:40 +0530 | [diff] [blame] | 273 | }; |