Merge pull request #30754 from deepeshgarg007/round_off_account_cost_center

fix: First preference to parent cost center rather than round off cost center
This commit is contained in:
Deepesh Garg
2022-04-25 17:06:19 +05:30
committed by GitHub
4 changed files with 60 additions and 4 deletions

View File

@@ -1369,7 +1369,9 @@ class PurchaseInvoice(BuyingController):
if (
not self.is_internal_transfer() and self.rounding_adjustment and self.base_rounding_adjustment
):
round_off_account, round_off_cost_center = get_round_off_account_and_cost_center(self.company)
round_off_account, round_off_cost_center = get_round_off_account_and_cost_center(
self.company, "Purchase Invoice", self.name
)
gl_entries.append(
self.get_gl_dict(

View File

@@ -1466,7 +1466,9 @@ class SalesInvoice(SellingController):
and self.base_rounding_adjustment
and not self.is_internal_transfer()
):
round_off_account, round_off_cost_center = get_round_off_account_and_cost_center(self.company)
round_off_account, round_off_cost_center = get_round_off_account_and_cost_center(
self.company, "Sales Invoice", self.name
)
gl_entries.append(
self.get_gl_dict(

View File

@@ -1978,6 +1978,13 @@ class TestSalesInvoice(unittest.TestCase):
self.assertEqual(expected_values[gle.account][2], gle.credit)
def test_rounding_adjustment_3(self):
from erpnext.accounts.doctype.accounting_dimension.test_accounting_dimension import (
create_dimension,
disable_dimension,
)
create_dimension()
si = create_sales_invoice(do_not_save=True)
si.items = []
for d in [(1122, 2), (1122.01, 1), (1122.01, 1)]:
@@ -2005,6 +2012,10 @@ class TestSalesInvoice(unittest.TestCase):
"included_in_print_rate": 1,
},
)
si.cost_center = "_Test Cost Center 2 - _TC"
si.location = "Block 1"
si.save()
si.submit()
self.assertEqual(si.net_total, 4007.16)
@@ -2040,6 +2051,18 @@ class TestSalesInvoice(unittest.TestCase):
self.assertEqual(debit_credit_diff, 0)
round_off_gle = frappe.db.get_value(
"GL Entry",
{"voucher_type": "Sales Invoice", "voucher_no": si.name, "account": "Round Off - _TC"},
["cost_center", "location"],
as_dict=1,
)
self.assertEqual(round_off_gle.cost_center, "_Test Cost Center 2 - _TC")
self.assertEqual(round_off_gle.location, "Block 1")
disable_dimension()
def test_sales_invoice_with_shipping_rule(self):
from erpnext.accounts.doctype.shipping_rule.test_shipping_rule import create_shipping_rule