Merge pull request #32779 from deepeshgarg007/sales_invoice_default_mop
fix: Mode of payment for returns in POS Sales Invoice
This commit is contained in:
commit
e0a705afe7
@ -965,7 +965,8 @@ class TestSalesInvoice(unittest.TestCase):
|
|||||||
pos_return.insert()
|
pos_return.insert()
|
||||||
pos_return.submit()
|
pos_return.submit()
|
||||||
|
|
||||||
self.assertEqual(pos_return.get("payments")[0].amount, -1000)
|
self.assertEqual(pos_return.get("payments")[0].amount, -500)
|
||||||
|
self.assertEqual(pos_return.get("payments")[1].amount, -500)
|
||||||
|
|
||||||
def test_pos_change_amount(self):
|
def test_pos_change_amount(self):
|
||||||
make_pos_profile(
|
make_pos_profile(
|
||||||
|
|||||||
@ -889,6 +889,15 @@ 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):
|
||||||
|
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 pending_amount > 0:
|
||||||
default_mode_of_payment = frappe.db.get_value(
|
default_mode_of_payment = frappe.db.get_value(
|
||||||
"POS Payment Method",
|
"POS Payment Method",
|
||||||
{"parent": self.doc.pos_profile, "default": 1},
|
{"parent": self.doc.pos_profile, "default": 1},
|
||||||
@ -902,7 +911,7 @@ class calculate_taxes_and_totals(object):
|
|||||||
"payments",
|
"payments",
|
||||||
{
|
{
|
||||||
"mode_of_payment": default_mode_of_payment.mode_of_payment,
|
"mode_of_payment": default_mode_of_payment.mode_of_payment,
|
||||||
"amount": total_amount_to_pay,
|
"amount": pending_amount,
|
||||||
"default": 1,
|
"default": 1,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user