Skip to content

Commit

Permalink
fix: make offsetting entry for acc dimensions
Browse files Browse the repository at this point in the history
(cherry picked from commit d3759b3)
  • Loading branch information
GursheenK authored and mergify[bot] committed Aug 18, 2023
1 parent a623469 commit 3198f26
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@
"reference_document",
"default_dimension",
"mandatory_for_bs",
"mandatory_for_pl"
"mandatory_for_pl",
"column_break_lqns",
"automatically_post_balancing_accounting_entry",
"offsetting_account"
],
"fields": [
{
Expand Down Expand Up @@ -50,6 +53,23 @@
"fieldtype": "Check",
"in_list_view": 1,
"label": "Mandatory For Profit and Loss Account"
},
{
"default": "0",
"fieldname": "automatically_post_balancing_accounting_entry",
"fieldtype": "Check",
"label": "Automatically post balancing accounting entry"
},
{
"fieldname": "offsetting_account",
"fieldtype": "Link",
"label": "Offsetting Account",
"mandatory_depends_on": "eval: doc.automatically_post_balancing_accounting_entry",
"options": "Account"
},
{
"fieldname": "column_break_lqns",
"fieldtype": "Column Break"
}
],
"istable": 1,
Expand Down
44 changes: 44 additions & 0 deletions erpnext/accounts/doctype/journal_entry/journal_entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -913,8 +913,52 @@ def build_gl_map(self):
item=d,
)
)

self.make_acc_dimensions_offsetting_entry(gl_map, d)

return gl_map

def make_acc_dimensions_offsetting_entry(self, gl_map, d):
accounting_dimensions = frappe.db.get_list("Accounting Dimension", {"disabled": 0}, pluck="name")
for dimension in accounting_dimensions:
dimension_details = frappe.db.get_values(
"Accounting Dimension Detail",
{"parent": dimension},
["automatically_post_balancing_accounting_entry", "offsetting_account"],
)[0]
if dimension_details[0] == 1:
offsetting_account = dimension_details[1]
gl_map.append(
self.get_gl_dict(
{
"account": offsetting_account,
"party_type": d.party_type,
"due_date": self.due_date,
"party": d.party,
"against": d.against_account,
"debit": flt(d.credit, d.precision("credit")),
"credit": flt(d.debit, d.precision("credit")),
"account_currency": d.account_currency,
"debit_in_account_currency": flt(
d.credit_in_account_currency, d.precision("credit_in_account_currency")
),
"credit_in_account_currency": flt(
d.debit_in_account_currency, d.precision("debit_in_account_currency")
),
"against_voucher_type": d.reference_type,
"against_voucher": d.reference_name,
"remarks": _(
"Offsetting for Accounting Dimension - {dimension}".format(dimension=dimension)
),
"voucher_detail_no": d.reference_detail_no,
"cost_center": d.cost_center,
"project": d.project,
"finance_book": self.finance_book,
},
item=d,
)
)

def make_gl_entries(self, cancel=0, adv_adj=0):
from erpnext.accounts.general_ledger import make_gl_entries

Expand Down

0 comments on commit 3198f26

Please sign in to comment.