refactor(test): make use of utility methods
This commit is contained in:
parent
946228d783
commit
547993f801
@ -86,26 +86,44 @@ class TestPaymentReconciliation(FrappeTestCase):
|
|||||||
self.customer5 = make_customer("_Test PR Customer 5", "EUR")
|
self.customer5 = make_customer("_Test PR Customer 5", "EUR")
|
||||||
|
|
||||||
def create_account(self):
|
def create_account(self):
|
||||||
account_name = "Debtors EUR"
|
accounts = [
|
||||||
|
{
|
||||||
|
"attribute": "debtors_eur",
|
||||||
|
"account_name": "Debtors EUR",
|
||||||
|
"parent_account": "Accounts Receivable - _PR",
|
||||||
|
"account_currency": "EUR",
|
||||||
|
"account_type": "Receivable",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"attribute": "creditors_usd",
|
||||||
|
"account_name": "Payable USD",
|
||||||
|
"parent_account": "Accounts Payable - _PR",
|
||||||
|
"account_currency": "USD",
|
||||||
|
"account_type": "Payable",
|
||||||
|
},
|
||||||
|
]
|
||||||
|
|
||||||
|
for x in accounts:
|
||||||
|
x = frappe._dict(x)
|
||||||
if not frappe.db.get_value(
|
if not frappe.db.get_value(
|
||||||
"Account", filters={"account_name": account_name, "company": self.company}
|
"Account", filters={"account_name": x.account_name, "company": self.company}
|
||||||
):
|
):
|
||||||
acc = frappe.new_doc("Account")
|
acc = frappe.new_doc("Account")
|
||||||
acc.account_name = account_name
|
acc.account_name = x.account_name
|
||||||
acc.parent_account = "Accounts Receivable - _PR"
|
acc.parent_account = x.parent_account
|
||||||
acc.company = self.company
|
acc.company = self.company
|
||||||
acc.account_currency = "EUR"
|
acc.account_currency = x.account_currency
|
||||||
acc.account_type = "Receivable"
|
acc.account_type = x.account_type
|
||||||
acc.insert()
|
acc.insert()
|
||||||
else:
|
else:
|
||||||
name = frappe.db.get_value(
|
name = frappe.db.get_value(
|
||||||
"Account",
|
"Account",
|
||||||
filters={"account_name": account_name, "company": self.company},
|
filters={"account_name": x.account_name, "company": self.company},
|
||||||
fieldname="name",
|
fieldname="name",
|
||||||
pluck=True,
|
pluck=True,
|
||||||
)
|
)
|
||||||
acc = frappe.get_doc("Account", name)
|
acc = frappe.get_doc("Account", name)
|
||||||
self.debtors_eur = acc.name
|
setattr(self, x.attribute, acc.name)
|
||||||
|
|
||||||
def create_sales_invoice(
|
def create_sales_invoice(
|
||||||
self, qty=1, rate=100, posting_date=nowdate(), do_not_save=False, do_not_submit=False
|
self, qty=1, rate=100, posting_date=nowdate(), do_not_save=False, do_not_submit=False
|
||||||
@ -963,9 +981,13 @@ class TestPaymentReconciliation(FrappeTestCase):
|
|||||||
self.assertEqual(pr.allocation[0].difference_amount, 0)
|
self.assertEqual(pr.allocation[0].difference_amount, 0)
|
||||||
|
|
||||||
def test_reconciliation_purchase_invoice_against_return(self):
|
def test_reconciliation_purchase_invoice_against_return(self):
|
||||||
pi = make_purchase_invoice(
|
self.supplier = "_Test Supplier USD"
|
||||||
supplier="_Test Supplier USD", currency="USD", conversion_rate=50
|
pi = self.create_purchase_invoice(qty=5, rate=50, do_not_submit=True)
|
||||||
).submit()
|
pi.supplier = self.supplier
|
||||||
|
pi.currency = "USD"
|
||||||
|
pi.conversion_rate = 50
|
||||||
|
pi.credit_to = self.creditors_usd
|
||||||
|
pi.save().submit()
|
||||||
|
|
||||||
pi_return = frappe.get_doc(pi.as_dict())
|
pi_return = frappe.get_doc(pi.as_dict())
|
||||||
pi_return.name = None
|
pi_return.name = None
|
||||||
@ -975,11 +997,12 @@ class TestPaymentReconciliation(FrappeTestCase):
|
|||||||
pi_return.items[0].qty = -pi_return.items[0].qty
|
pi_return.items[0].qty = -pi_return.items[0].qty
|
||||||
pi_return.submit()
|
pi_return.submit()
|
||||||
|
|
||||||
self.company = "_Test Company"
|
pr = frappe.get_doc("Payment Reconciliation")
|
||||||
self.party_type = "Supplier"
|
pr.company = self.company
|
||||||
self.customer = "_Test Supplier USD"
|
pr.party_type = "Supplier"
|
||||||
|
pr.party = self.supplier
|
||||||
pr = self.create_payment_reconciliation()
|
pr.receivable_payable_account = self.creditors_usd
|
||||||
|
pr.from_invoice_date = pr.to_invoice_date = pr.from_payment_date = pr.to_payment_date = nowdate()
|
||||||
pr.get_unreconciled_entries()
|
pr.get_unreconciled_entries()
|
||||||
|
|
||||||
invoices = []
|
invoices = []
|
||||||
|
Loading…
x
Reference in New Issue
Block a user