fix: Test related errors

This commit is contained in:
Deepesh Garg 2023-06-22 11:41:43 +05:30
parent b64ebc6fcc
commit 3aead05f42
4 changed files with 22 additions and 18 deletions

View File

@ -949,10 +949,8 @@ class PaymentEntry(AccountsController):
if self.party_account:
if self.payment_type == "Receive":
against_account = self.paid_to
dr_or_cr = "credit"
else:
against_account = self.paid_from
dr_or_cr = "debit"
party_dict = self.get_gl_dict(
{
@ -965,6 +963,11 @@ class PaymentEntry(AccountsController):
},
item=self,
)
dr_or_cr = (
"credit" if erpnext.get_party_account_type(self.party_type) == "Receivable" else "debit"
)
is_advance = self.is_advance_entry()
for d in self.get("references"):

View File

@ -59,7 +59,10 @@ class PaymentReconciliation(Document):
self.add_payment_entries(non_reconciled_payments)
def get_payment_entries(self):
party_account = [self.receivable_payable_account, self.default_advance_account]
if self.default_advance_account:
party_account = [self.receivable_payable_account, self.default_advance_account]
else:
party_account = [self.receivable_payable_account]
order_doctype = "Sales Order" if self.party_type == "Customer" else "Purchase Order"
condition = frappe._dict(
@ -352,7 +355,10 @@ class PaymentReconciliation(Document):
for row in self.get("allocation"):
reconciled_entry = []
if row.invoice_number and row.allocated_amount:
if row.invoice_type in ["Sales Invoice", "Purchase Invoice"]:
if (
row.invoice_type in ["Sales Invoice", "Purchase Invoice"]
and row.reference_type == "Payment Entry"
):
gl_entries = []
make_advance_liability_entry(
gl_entries, row.reference_name, row.allocated_amount, row.invoice_number, self.party_type

View File

@ -500,7 +500,7 @@ def check_if_advance_entry_modified(args):
q = (
frappe.qb.from_(journal_entry)
.innerjoin(journal_acc)
.inner_join(journal_acc)
.on(journal_entry.name == journal_acc.parent)
)

View File

@ -2156,11 +2156,7 @@ def get_advance_journal_entries(
ConstantColumn("Journal Entry").as_("reference_type"),
(journal_entry.name).as_("reference_name"),
(journal_entry.remark).as_("remarks"),
(
journal_acc.debit_in_account_currency
if party_type == "Supplier"
else journal_acc.credit_in_account_currency
).as_("amount"),
(journal_acc[amount_field]).as_("amount"),
(journal_acc.name).as_("reference_row"),
(journal_acc.reference_name).as_("against_order"),
(journal_acc.exchange_rate),
@ -2179,12 +2175,13 @@ def get_advance_journal_entries(
else:
q = q.where(journal_acc.debit_in_account_currency > 0)
if include_unallocated:
q = q.where((journal_acc.reference_name.isnull()) | (journal_acc.reference_name == ""))
if order_list:
q = q.where(journal_acc.reference_type == order_doctype)
if include_unallocated:
q = q.where(journal_acc.reference_name.isin(order_list) | (journal_acc.reference_name == ""))
else:
q = q.where(journal_acc.reference_name.isin(order_list))
q = q.where(
(journal_acc.reference_type == order_doctype) & ((journal_acc.reference).isin(order_list))
)
q = q.orderby(journal_entry.posting_date)
@ -2222,15 +2219,14 @@ def get_advance_payment_entries(
(payment_ref.allocated_amount).as_("amount"),
(payment_ref.name).as_("reference_row"),
(payment_ref.reference_name).as_("against_order"),
payment_ref.reference_doctype == order_doctype,
)
q = q.where(payment_ref.reference_doctype == order_doctype)
if order_list:
q = q.where(payment_ref.reference_name.isin(order_list))
allocated = list(q.run(as_dict=True))
payment_entries += allocated
if include_unallocated:
q = get_common_query(
party_type,
@ -2244,7 +2240,6 @@ def get_advance_payment_entries(
unallocated = list(q.run(as_dict=True))
payment_entries += unallocated
return payment_entries