Merge pull request #40196 from ruthra-kumar/use_debit_or_credit_to_account_while_fetching_advance
fix: include debit_to or credit_to account while fetching advance on Sales/Purchase Invoice
This commit is contained in:
commit
9d3614597c
@ -3615,6 +3615,33 @@ class TestSalesInvoice(FrappeTestCase):
|
|||||||
check_gl_entries(self, pe.name, expected_gle, nowdate(), voucher_type="Payment Entry")
|
check_gl_entries(self, pe.name, expected_gle, nowdate(), voucher_type="Payment Entry")
|
||||||
set_advance_flag(company="_Test Company", flag=0, default_account="")
|
set_advance_flag(company="_Test Company", flag=0, default_account="")
|
||||||
|
|
||||||
|
def test_pulling_advance_based_on_debit_to(self):
|
||||||
|
from erpnext.accounts.doctype.payment_entry.test_payment_entry import create_payment_entry
|
||||||
|
|
||||||
|
debtors2 = create_account(
|
||||||
|
parent_account="Accounts Receivable - _TC",
|
||||||
|
account_name="Debtors 2",
|
||||||
|
company="_Test Company",
|
||||||
|
account_type="Receivable",
|
||||||
|
)
|
||||||
|
si = create_sales_invoice(do_not_submit=True)
|
||||||
|
si.debit_to = debtors2
|
||||||
|
si.save()
|
||||||
|
|
||||||
|
pe = create_payment_entry(
|
||||||
|
company=si.company,
|
||||||
|
payment_type="Receive",
|
||||||
|
party_type="Customer",
|
||||||
|
party=si.customer,
|
||||||
|
paid_from=debtors2,
|
||||||
|
paid_to="Cash - _TC",
|
||||||
|
paid_amount=1000,
|
||||||
|
)
|
||||||
|
pe.submit()
|
||||||
|
advances = si.get_advance_entries()
|
||||||
|
self.assertEqual(1, len(advances))
|
||||||
|
self.assertEqual(advances[0].reference_name, pe.name)
|
||||||
|
|
||||||
|
|
||||||
def set_advance_flag(company, flag, default_account):
|
def set_advance_flag(company, flag, default_account):
|
||||||
frappe.db.set_value(
|
frappe.db.set_value(
|
||||||
|
@ -1135,21 +1135,24 @@ class AccountsController(TransactionBase):
|
|||||||
self.append("advances", advance_row)
|
self.append("advances", advance_row)
|
||||||
|
|
||||||
def get_advance_entries(self, include_unallocated=True):
|
def get_advance_entries(self, include_unallocated=True):
|
||||||
|
party_account = []
|
||||||
if self.doctype == "Sales Invoice":
|
if self.doctype == "Sales Invoice":
|
||||||
party_type = "Customer"
|
party_type = "Customer"
|
||||||
party = self.customer
|
party = self.customer
|
||||||
amount_field = "credit_in_account_currency"
|
amount_field = "credit_in_account_currency"
|
||||||
order_field = "sales_order"
|
order_field = "sales_order"
|
||||||
order_doctype = "Sales Order"
|
order_doctype = "Sales Order"
|
||||||
|
party_account.append(self.debit_to)
|
||||||
else:
|
else:
|
||||||
party_type = "Supplier"
|
party_type = "Supplier"
|
||||||
party = self.supplier
|
party = self.supplier
|
||||||
amount_field = "debit_in_account_currency"
|
amount_field = "debit_in_account_currency"
|
||||||
order_field = "purchase_order"
|
order_field = "purchase_order"
|
||||||
order_doctype = "Purchase Order"
|
order_doctype = "Purchase Order"
|
||||||
|
party_account.append(self.credit_to)
|
||||||
|
|
||||||
party_account = get_party_account(
|
party_account.extend(
|
||||||
party_type, party=party, company=self.company, include_advance=True
|
get_party_account(party_type, party=party, company=self.company, include_advance=True)
|
||||||
)
|
)
|
||||||
|
|
||||||
order_list = list(set(d.get(order_field) for d in self.get("items") if d.get(order_field)))
|
order_list = list(set(d.get(order_field) for d in self.get("items") if d.get(order_field)))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user