chore: resolve conflicts
This commit is contained in:
@@ -250,16 +250,8 @@ class AccountsController(TransactionBase):
|
||||
apply_pricing_rule_on_transaction(self)
|
||||
|
||||
self.set_total_in_words()
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
self.set_default_letter_head()
|
||||
self.validate_company_in_accounting_dimension()
|
||||
|
||||
def set_default_letter_head(self):
|
||||
if hasattr(self, "letter_head") and not self.letter_head:
|
||||
self.letter_head = frappe.db.get_value("Company", self.company, "default_letter_head")
|
||||
>>>>>>> 60efd3e219 (feat: add company level validation for accounting dimension)
|
||||
|
||||
def init_internal_values(self):
|
||||
# init all the internal values as 0 on sa
|
||||
if self.docstatus.is_draft():
|
||||
@@ -364,23 +356,6 @@ class AccountsController(TransactionBase):
|
||||
(sle.voucher_type == self.doctype) & (sle.voucher_no == self.name)
|
||||
).run()
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
def remove_serial_and_batch_bundle(self):
|
||||
bundles = frappe.get_all(
|
||||
"Serial and Batch Bundle",
|
||||
filters={"voucher_type": self.doctype, "voucher_no": self.name, "docstatus": ("!=", 1)},
|
||||
)
|
||||
|
||||
for bundle in bundles:
|
||||
frappe.delete_doc("Serial and Batch Bundle", bundle.name)
|
||||
|
||||
batches = frappe.get_all(
|
||||
"Batch", filters={"reference_doctype": self.doctype, "reference_name": self.name}
|
||||
)
|
||||
for row in batches:
|
||||
frappe.delete_doc("Batch", row.name)
|
||||
|
||||
def validate_company_in_accounting_dimension(self):
|
||||
doc_field = DocType("DocField")
|
||||
accounting_dimension = DocType("Accounting Dimension")
|
||||
@@ -414,7 +389,6 @@ class AccountsController(TransactionBase):
|
||||
)
|
||||
)
|
||||
|
||||
>>>>>>> 60efd3e219 (feat: add company level validation for accounting dimension)
|
||||
def validate_return_against_account(self):
|
||||
if self.doctype in ["Sales Invoice", "Purchase Invoice"] and self.is_return and self.return_against:
|
||||
cr_dr_account_field = "debit_to" if self.doctype == "Sales Invoice" else "credit_to"
|
||||
|
||||
@@ -14,11 +14,6 @@ from erpnext.accounts.doctype.payment_entry.payment_entry import get_payment_ent
|
||||
from erpnext.accounts.doctype.payment_entry.test_payment_entry import create_payment_entry
|
||||
from erpnext.accounts.doctype.sales_invoice.test_sales_invoice import create_sales_invoice
|
||||
from erpnext.accounts.party import get_party_account
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
from erpnext.buying.doctype.purchase_order.test_purchase_order import prepare_data_for_internal_transfer
|
||||
from erpnext.projects.doctype.project.test_project import make_project
|
||||
>>>>>>> c94091d68f (test: add new unit test for company validation in accounting dimension)
|
||||
from erpnext.stock.doctype.item.test_item import create_item
|
||||
|
||||
|
||||
@@ -1744,228 +1739,3 @@ class TestAccountsController(FrappeTestCase):
|
||||
# Exchange Gain/Loss Journal should've been cancelled
|
||||
exc_je_for_je1 = self.get_journals_for(je1.doctype, je1.name)
|
||||
self.assertEqual(exc_je_for_je1, [])
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
|
||||
def test_70_advance_payment_against_sales_invoice_in_foreign_currency(self):
|
||||
"""
|
||||
Customer advance booked under Liability
|
||||
"""
|
||||
self.setup_advance_accounts_in_party_master()
|
||||
|
||||
adv = self.create_payment_entry(amount=1, source_exc_rate=83)
|
||||
adv.save() # explicit 'save' is needed to trigger set_liability_account()
|
||||
self.assertEqual(adv.paid_from, self.advance_received_usd)
|
||||
adv.submit()
|
||||
|
||||
si = self.create_sales_invoice(qty=1, conversion_rate=80, rate=1, do_not_submit=True)
|
||||
si.debit_to = self.debtors_usd
|
||||
si.save().submit()
|
||||
self.assert_ledger_outstanding(si.doctype, si.name, 80.0, 1.0)
|
||||
|
||||
pr = self.create_payment_reconciliation()
|
||||
pr.receivable_payable_account = self.debtors_usd
|
||||
pr.default_advance_account = self.advance_received_usd
|
||||
pr.get_unreconciled_entries()
|
||||
self.assertEqual(pr.invoices[0].invoice_number, si.name)
|
||||
self.assertEqual(pr.payments[0].reference_name, adv.name)
|
||||
|
||||
# Allocate and Reconcile
|
||||
invoices = [x.as_dict() for x in pr.invoices]
|
||||
payments = [x.as_dict() for x in pr.payments]
|
||||
pr.allocate_entries(frappe._dict({"invoices": invoices, "payments": payments}))
|
||||
pr.reconcile()
|
||||
self.assertEqual(len(pr.invoices), 0)
|
||||
self.assertEqual(len(pr.payments), 0)
|
||||
self.assert_ledger_outstanding(si.doctype, si.name, 0.0, 0.0)
|
||||
|
||||
# Exc Gain/Loss journal should've been creatad
|
||||
exc_je_for_si = self.get_journals_for(si.doctype, si.name)
|
||||
exc_je_for_adv = self.get_journals_for(adv.doctype, adv.name)
|
||||
self.assertEqual(len(exc_je_for_si), 1)
|
||||
self.assertEqual(len(exc_je_for_adv), 1)
|
||||
self.assertEqual(exc_je_for_si, exc_je_for_adv)
|
||||
|
||||
adv.reload()
|
||||
adv.cancel()
|
||||
si.reload()
|
||||
self.assert_ledger_outstanding(si.doctype, si.name, 80.0, 1.0)
|
||||
# Exc Gain/Loss journal should've been cancelled
|
||||
exc_je_for_si = self.get_journals_for(si.doctype, si.name)
|
||||
exc_je_for_adv = self.get_journals_for(adv.doctype, adv.name)
|
||||
self.assertEqual(len(exc_je_for_si), 0)
|
||||
self.assertEqual(len(exc_je_for_adv), 0)
|
||||
|
||||
self.remove_advance_accounts_from_party_master()
|
||||
|
||||
def test_71_advance_payment_against_purchase_invoice_in_foreign_currency(self):
|
||||
"""
|
||||
Supplier advance booked under Asset
|
||||
"""
|
||||
self.setup_advance_accounts_in_party_master()
|
||||
|
||||
usd_amount = 1
|
||||
inr_amount = 85
|
||||
exc_rate = 85
|
||||
adv = create_payment_entry(
|
||||
company=self.company,
|
||||
payment_type="Pay",
|
||||
party_type="Supplier",
|
||||
party=self.supplier,
|
||||
paid_from=self.cash,
|
||||
paid_to=self.advance_paid_usd,
|
||||
paid_amount=inr_amount,
|
||||
)
|
||||
adv.source_exchange_rate = 1
|
||||
adv.target_exchange_rate = exc_rate
|
||||
adv.received_amount = usd_amount
|
||||
adv.paid_amount = exc_rate * usd_amount
|
||||
adv.posting_date = nowdate()
|
||||
adv.save()
|
||||
# Make sure that advance account is still set
|
||||
self.assertEqual(adv.paid_to, self.advance_paid_usd)
|
||||
adv.submit()
|
||||
|
||||
pi = self.create_purchase_invoice(qty=1, conversion_rate=83, rate=1)
|
||||
self.assertEqual(pi.credit_to, self.creditors_usd)
|
||||
self.assert_ledger_outstanding(pi.doctype, pi.name, 83.0, 1.0)
|
||||
|
||||
pr = self.create_payment_reconciliation()
|
||||
pr.party_type = "Supplier"
|
||||
pr.party = self.supplier
|
||||
pr.receivable_payable_account = self.creditors_usd
|
||||
pr.default_advance_account = self.advance_paid_usd
|
||||
pr.get_unreconciled_entries()
|
||||
self.assertEqual(pr.invoices[0].invoice_number, pi.name)
|
||||
self.assertEqual(pr.payments[0].reference_name, adv.name)
|
||||
|
||||
# Allocate and Reconcile
|
||||
invoices = [x.as_dict() for x in pr.invoices]
|
||||
payments = [x.as_dict() for x in pr.payments]
|
||||
pr.allocate_entries(frappe._dict({"invoices": invoices, "payments": payments}))
|
||||
pr.reconcile()
|
||||
self.assertEqual(len(pr.invoices), 0)
|
||||
self.assertEqual(len(pr.payments), 0)
|
||||
self.assert_ledger_outstanding(pi.doctype, pi.name, 0.0, 0.0)
|
||||
|
||||
# Exc Gain/Loss journal should've been creatad
|
||||
exc_je_for_pi = self.get_journals_for(pi.doctype, pi.name)
|
||||
exc_je_for_adv = self.get_journals_for(adv.doctype, adv.name)
|
||||
self.assertEqual(len(exc_je_for_pi), 1)
|
||||
self.assertEqual(len(exc_je_for_adv), 1)
|
||||
self.assertEqual(exc_je_for_pi, exc_je_for_adv)
|
||||
|
||||
adv.reload()
|
||||
adv.cancel()
|
||||
pi.reload()
|
||||
self.assert_ledger_outstanding(pi.doctype, pi.name, 83.0, 1.0)
|
||||
# Exc Gain/Loss journal should've been cancelled
|
||||
exc_je_for_pi = self.get_journals_for(pi.doctype, pi.name)
|
||||
exc_je_for_adv = self.get_journals_for(adv.doctype, adv.name)
|
||||
self.assertEqual(len(exc_je_for_pi), 0)
|
||||
self.assertEqual(len(exc_je_for_adv), 0)
|
||||
|
||||
self.remove_advance_accounts_from_party_master()
|
||||
|
||||
def test_difference_posting_date_in_pi_and_si(self):
|
||||
self.setup_advance_accounts_in_party_master()
|
||||
|
||||
# create payment entry for customer
|
||||
adv = self.create_payment_entry(amount=1, source_exc_rate=83)
|
||||
adv.save()
|
||||
self.assertEqual(adv.paid_from, self.advance_received_usd)
|
||||
adv.submit()
|
||||
adv.reload()
|
||||
|
||||
# create sales invoice with advance received
|
||||
si = self.create_sales_invoice(qty=1, conversion_rate=80, rate=1, do_not_submit=True)
|
||||
si.debit_to = self.debtors_usd
|
||||
si.append(
|
||||
"advances",
|
||||
{
|
||||
"reference_type": adv.doctype,
|
||||
"reference_name": adv.name,
|
||||
"remarks": "Amount INR 1 received from _Test MC Customer USD\nTransaction reference no Test001 dated 2024-12-19",
|
||||
"advance_amount": 1.0,
|
||||
"allocated_amount": 1.0,
|
||||
"exchange_gain_loss": 3.0,
|
||||
"ref_exchange_rate": 83.0,
|
||||
"difference_posting_date": add_days(nowdate(), -2),
|
||||
},
|
||||
)
|
||||
si.save().submit()
|
||||
|
||||
# exc Gain/Loss journal should've been creatad
|
||||
exc_je_for_si = self.get_journals_for(si.doctype, si.name)
|
||||
exc_je_for_adv = self.get_journals_for(adv.doctype, adv.name)
|
||||
self.assertEqual(len(exc_je_for_si), 1)
|
||||
self.assertEqual(len(exc_je_for_adv), 1)
|
||||
self.assertEqual(exc_je_for_si, exc_je_for_adv)
|
||||
|
||||
# check jv created with difference_posting_date in sales invoice
|
||||
jv = frappe.get_doc("Journal Entry", exc_je_for_si[0].parent)
|
||||
sales_invoice = frappe.get_doc("Sales Invoice", si.name)
|
||||
self.assertEqual(sales_invoice.advances[0].difference_posting_date, jv.posting_date)
|
||||
|
||||
# create payment entry for supplier
|
||||
usd_amount = 1
|
||||
inr_amount = 85
|
||||
exc_rate = 85
|
||||
adv = create_payment_entry(
|
||||
company=self.company,
|
||||
payment_type="Pay",
|
||||
party_type="Supplier",
|
||||
party=self.supplier,
|
||||
paid_from=self.cash,
|
||||
paid_to=self.advance_paid_usd,
|
||||
paid_amount=inr_amount,
|
||||
)
|
||||
adv.source_exchange_rate = 1
|
||||
adv.target_exchange_rate = exc_rate
|
||||
adv.received_amount = usd_amount
|
||||
adv.paid_amount = exc_rate * usd_amount
|
||||
adv.posting_date = nowdate()
|
||||
adv.save()
|
||||
self.assertEqual(adv.paid_to, self.advance_paid_usd)
|
||||
adv.submit()
|
||||
|
||||
# create purchase invoice with advance paid
|
||||
pi = self.create_purchase_invoice(qty=1, conversion_rate=80, rate=1, do_not_submit=True)
|
||||
pi.append(
|
||||
"advances",
|
||||
{
|
||||
"reference_type": adv.doctype,
|
||||
"reference_name": adv.name,
|
||||
"remarks": "Amount INR 1 paid to _Test MC Supplier USD\nTransaction reference no Test001 dated 2024-12-20",
|
||||
"advance_amount": 1.0,
|
||||
"allocated_amount": 1.0,
|
||||
"exchange_gain_loss": 5.0,
|
||||
"ref_exchange_rate": 85.0,
|
||||
"difference_posting_date": add_days(nowdate(), -2),
|
||||
},
|
||||
)
|
||||
pi.save().submit()
|
||||
self.assertEqual(pi.credit_to, self.creditors_usd)
|
||||
|
||||
# exc Gain/Loss journal should've been creatad
|
||||
exc_je_for_pi = self.get_journals_for(pi.doctype, pi.name)
|
||||
exc_je_for_adv = self.get_journals_for(adv.doctype, adv.name)
|
||||
self.assertEqual(len(exc_je_for_pi), 1)
|
||||
self.assertEqual(len(exc_je_for_adv), 1)
|
||||
self.assertEqual(exc_je_for_pi, exc_je_for_adv)
|
||||
|
||||
# check jv created with difference_posting_date in purchase invoice
|
||||
journal_voucher = frappe.get_doc("Journal Entry", exc_je_for_pi[0].parent)
|
||||
purchase_invoice = frappe.get_doc("Purchase Invoice", pi.name)
|
||||
self.assertEqual(purchase_invoice.advances[0].difference_posting_date, journal_voucher.posting_date)
|
||||
|
||||
def test_company_validation_in_dimension(self):
|
||||
si = create_sales_invoice(do_not_submit=True)
|
||||
project = make_project({"project_name": "_Test Demo Project1", "company": "_Test Company 1"})
|
||||
si.project = project.name
|
||||
self.assertRaises(frappe.ValidationError, si.save)
|
||||
|
||||
si_1 = create_sales_invoice(do_not_submit=True)
|
||||
si_1.items[0].project = project.name
|
||||
self.assertRaises(frappe.ValidationError, si_1.save)
|
||||
>>>>>>> c94091d68f (test: add new unit test for company validation in accounting dimension)
|
||||
|
||||
Reference in New Issue
Block a user