Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: paid amount in Sales Invoice POS return resets to 0 #24057

Merged
merged 2 commits into from
Dec 7, 2020

Conversation

ruchamahabal
Copy link
Member

@ruchamahabal ruchamahabal commented Dec 4, 2020

Steps to replicate:

  1. Create a Sales Invoice for POS
  2. Create a Return / Credit Note against it and Save.
  3. On submit, the amount in the payments table gets reset to 0 because of this code.

this.frm.doc.payments.find(pay => {
if (pay.default) {
pay.amount = total_amount_to_pay;
} else {
pay.amount = 0.0

The default flag in the record gets reset here and is not set in this function:

self.doc.payments = []

si-pos-invoice-before

Fix: Set default flag for payment method during return

si-pos-invoice-after

@marination
Copy link
Collaborator

@ruchamahabal one small test for POS Invoice Credit Note ?

@marination marination added the needs-tests This PR needs automated unit-tests. label Dec 7, 2020
@marination marination self-assigned this Dec 7, 2020
@ruchamahabal
Copy link
Member Author

@marination There is already a test for pos returns

def test_pos_returns_with_repayment(self):
pos_profile = make_pos_profile()
pos_profile.append('payments', {
'default': 1,
'mode_of_payment': 'Cash',
'amount': 0.0
})
pos_profile.save()
pos = create_sales_invoice(qty = 10, do_not_save=True)
pos.is_pos = 1
pos.pos_profile = pos_profile.name
pos.append("payments", {'mode_of_payment': 'Bank Draft', 'account': '_Test Bank - _TC', 'amount': 500})
pos.append("payments", {'mode_of_payment': 'Cash', 'account': 'Cash - _TC', 'amount': 500})
pos.insert()
pos.submit()
pos_return = create_sales_invoice(is_return=1,
return_against=pos.name, qty=-5, do_not_save=True)
pos_return.is_pos = 1
pos_return.pos_profile = pos_profile.name
pos_return.insert()
pos_return.submit()
self.assertEqual(pos_return.get('payments')[0].amount, -500)
pos_profile.payments = []
pos_profile.save()

Looks like the test was not failing because this gets reset on the client side:

this.frm.doc.payments.find(pay => {
if (pay.default) {
pay.amount = total_amount_to_pay;
} else {
pay.amount = 0.0

@marination
Copy link
Collaborator

@ruchamahabal okay cool we can skip tests here

@marination marination removed the needs-tests This PR needs automated unit-tests. label Dec 7, 2020
@marination marination merged commit 34e142e into frappe:develop Dec 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants