Merge pull request #40058 from frappe/mergify/bp/version-15-hotfix/pr-40011
fix: Ledger entries for Cr/Dr notes with POS Payments (backport #40011)
This commit is contained in:
commit
c752bec2d9
@ -1472,9 +1472,7 @@ class SalesInvoice(SellingController):
|
|||||||
"credit_in_account_currency": payment_mode.base_amount
|
"credit_in_account_currency": payment_mode.base_amount
|
||||||
if self.party_account_currency == self.company_currency
|
if self.party_account_currency == self.company_currency
|
||||||
else payment_mode.amount,
|
else payment_mode.amount,
|
||||||
"against_voucher": self.return_against
|
"against_voucher": self.name,
|
||||||
if cint(self.is_return) and self.return_against
|
|
||||||
else self.name,
|
|
||||||
"against_voucher_type": self.doctype,
|
"against_voucher_type": self.doctype,
|
||||||
"cost_center": self.cost_center,
|
"cost_center": self.cost_center,
|
||||||
},
|
},
|
||||||
|
|||||||
@ -1088,6 +1088,44 @@ class TestSalesInvoice(FrappeTestCase):
|
|||||||
self.assertEqual(pos.grand_total, 100.0)
|
self.assertEqual(pos.grand_total, 100.0)
|
||||||
self.assertEqual(pos.write_off_amount, 10)
|
self.assertEqual(pos.write_off_amount, 10)
|
||||||
|
|
||||||
|
def test_ledger_entries_of_return_pos_invoice(self):
|
||||||
|
make_pos_profile()
|
||||||
|
|
||||||
|
pos = create_sales_invoice(do_not_save=True)
|
||||||
|
pos.is_pos = 1
|
||||||
|
pos.append("payments", {"mode_of_payment": "Cash", "account": "Cash - _TC", "amount": 100})
|
||||||
|
pos.save().submit()
|
||||||
|
self.assertEqual(pos.outstanding_amount, 0.0)
|
||||||
|
self.assertEqual(pos.status, "Paid")
|
||||||
|
|
||||||
|
from erpnext.accounts.doctype.sales_invoice.sales_invoice import make_sales_return
|
||||||
|
|
||||||
|
pos_return = make_sales_return(pos.name)
|
||||||
|
pos_return.save().submit()
|
||||||
|
pos_return.reload()
|
||||||
|
pos.reload()
|
||||||
|
self.assertEqual(pos_return.is_return, 1)
|
||||||
|
self.assertEqual(pos_return.return_against, pos.name)
|
||||||
|
self.assertEqual(pos_return.outstanding_amount, 0.0)
|
||||||
|
self.assertEqual(pos_return.status, "Return")
|
||||||
|
self.assertEqual(pos.outstanding_amount, 0.0)
|
||||||
|
self.assertEqual(pos.status, "Credit Note Issued")
|
||||||
|
|
||||||
|
expected = (
|
||||||
|
("Cash - _TC", 0.0, 100.0, pos_return.name, None),
|
||||||
|
("Debtors - _TC", 0.0, 100.0, pos_return.name, pos_return.name),
|
||||||
|
("Debtors - _TC", 100.0, 0.0, pos_return.name, pos_return.name),
|
||||||
|
("Sales - _TC", 100.0, 0.0, pos_return.name, None),
|
||||||
|
)
|
||||||
|
res = frappe.db.get_all(
|
||||||
|
"GL Entry",
|
||||||
|
filters={"voucher_no": pos_return.name, "is_cancelled": 0},
|
||||||
|
fields=["account", "debit", "credit", "voucher_no", "against_voucher"],
|
||||||
|
order_by="account, debit, credit",
|
||||||
|
as_list=1,
|
||||||
|
)
|
||||||
|
self.assertEqual(expected, res)
|
||||||
|
|
||||||
def test_pos_with_no_gl_entry_for_change_amount(self):
|
def test_pos_with_no_gl_entry_for_change_amount(self):
|
||||||
frappe.db.set_single_value("Accounts Settings", "post_change_gl_entries", 0)
|
frappe.db.set_single_value("Accounts Settings", "post_change_gl_entries", 0)
|
||||||
|
|
||||||
|
|||||||
@ -216,7 +216,8 @@ class AccountsController(TransactionBase):
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
if self.get("is_return") and self.get("return_against"):
|
if self.get("is_return") and self.get("return_against") and not self.get("is_pos"):
|
||||||
|
# if self.get("is_return") and self.get("return_against"):
|
||||||
document_type = "Credit Note" if self.doctype == "Sales Invoice" else "Debit Note"
|
document_type = "Credit Note" if self.doctype == "Sales Invoice" else "Debit Note"
|
||||||
frappe.msgprint(
|
frappe.msgprint(
|
||||||
_(
|
_(
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user