fix: Mode of payment for returns in POS Sales Invoice
This commit is contained in:
parent
92f2d9f99f
commit
06e8e28531
@ -889,24 +889,33 @@ class calculate_taxes_and_totals(object):
|
|||||||
self.doc.other_charges_calculation = get_itemised_tax_breakup_html(self.doc)
|
self.doc.other_charges_calculation = get_itemised_tax_breakup_html(self.doc)
|
||||||
|
|
||||||
def set_total_amount_to_default_mop(self, total_amount_to_pay):
|
def set_total_amount_to_default_mop(self, total_amount_to_pay):
|
||||||
default_mode_of_payment = frappe.db.get_value(
|
total_paid_amount = 0
|
||||||
"POS Payment Method",
|
for payment in self.doc.get("payments"):
|
||||||
{"parent": self.doc.pos_profile, "default": 1},
|
total_paid_amount += (
|
||||||
["mode_of_payment"],
|
payment.amount if self.doc.party_account_currency == self.doc.currency else payment.base_amount
|
||||||
as_dict=1,
|
|
||||||
)
|
|
||||||
|
|
||||||
if default_mode_of_payment:
|
|
||||||
self.doc.payments = []
|
|
||||||
self.doc.append(
|
|
||||||
"payments",
|
|
||||||
{
|
|
||||||
"mode_of_payment": default_mode_of_payment.mode_of_payment,
|
|
||||||
"amount": total_amount_to_pay,
|
|
||||||
"default": 1,
|
|
||||||
},
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
pending_amount = total_amount_to_pay - total_paid_amount
|
||||||
|
|
||||||
|
if pending_amount > 0:
|
||||||
|
default_mode_of_payment = frappe.db.get_value(
|
||||||
|
"POS Payment Method",
|
||||||
|
{"parent": self.doc.pos_profile, "default": 1},
|
||||||
|
["mode_of_payment"],
|
||||||
|
as_dict=1,
|
||||||
|
)
|
||||||
|
|
||||||
|
if default_mode_of_payment:
|
||||||
|
self.doc.payments = []
|
||||||
|
self.doc.append(
|
||||||
|
"payments",
|
||||||
|
{
|
||||||
|
"mode_of_payment": default_mode_of_payment.mode_of_payment,
|
||||||
|
"amount": pending_amount,
|
||||||
|
"default": 1,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def get_itemised_tax_breakup_html(doc):
|
def get_itemised_tax_breakup_html(doc):
|
||||||
if not doc.taxes:
|
if not doc.taxes:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user