Skip to content

Commit

Permalink
fix: Mode of payment for returns in POS Sales Invoice
Browse files Browse the repository at this point in the history
(cherry picked from commit 06e8e28)
  • Loading branch information
deepeshgarg007 authored and mergify[bot] committed Nov 1, 2022
1 parent a9660bf commit 9b63a1a
Showing 1 changed file with 24 additions and 15 deletions.
39 changes: 24 additions & 15 deletions erpnext/controllers/taxes_and_totals.py
Original file line number Diff line number Diff line change
Expand Up @@ -890,24 +890,33 @@ def set_item_wise_tax_breakup(self):
self.doc.other_charges_calculation = get_itemised_tax_breakup_html(self.doc)

def set_total_amount_to_default_mop(self, total_amount_to_pay):
default_mode_of_payment = frappe.db.get_value(
"POS Payment Method",
{"parent": self.doc.pos_profile, "default": 1},
["mode_of_payment"],
as_dict=1,
)
total_paid_amount = 0
for payment in self.doc.get("payments"):
total_paid_amount += (
payment.amount if self.doc.party_account_currency == self.doc.currency else payment.base_amount
)

pending_amount = total_amount_to_pay - total_paid_amount

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,
},
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):
if not doc.taxes:
Expand Down

0 comments on commit 9b63a1a

Please sign in to comment.