Skip to content

Commit

Permalink
refactor: build gl_map and reconcile in utils
Browse files Browse the repository at this point in the history
  • Loading branch information
ruthra-kumar committed Jun 8, 2022
1 parent 171c317 commit 8871025
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 20 deletions.
6 changes: 0 additions & 6 deletions erpnext/accounts/doctype/journal_entry/journal_entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -838,12 +838,6 @@ def build_gl_map(self, cancel=0):
)
return gl_map

def make_payment_ledger_entries(self, cancel=0, adv_adj=0):
from erpnext.accounts.utils import create_payment_ledger_entry

gl_map = self.build_gl_map(cancel)
create_payment_ledger_entry(gl_map, cancel=cancel, adv_adj=adv_adj)

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

Expand Down
13 changes: 1 addition & 12 deletions erpnext/accounts/doctype/payment_entry/payment_entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,7 @@
)
from erpnext.accounts.general_ledger import make_gl_entries, process_gl_map
from erpnext.accounts.party import get_party_account
from erpnext.accounts.utils import (
create_payment_ledger_entry,
get_account_currency,
get_balance_on,
get_outstanding_invoices,
)
from erpnext.accounts.utils import get_account_currency, get_balance_on, get_outstanding_invoices
from erpnext.controllers.accounts_controller import (
AccountsController,
get_supplier_block_status,
Expand Down Expand Up @@ -801,12 +796,6 @@ def build_gl_map(self):
self.add_tax_gl_entries(gl_entries)
return gl_entries

def make_payment_ledger_entries(self, cancel=0, adv_adj=0):
# used only on reconciliation
gl_entries = self.build_gl_map()
gl_entries = process_gl_map(gl_entries)
create_payment_ledger_entry(gl_entries, cancel=cancel, adv_adj=adv_adj)

def make_gl_entries(self, cancel=0, adv_adj=0):
gl_entries = self.build_gl_map()
gl_entries = process_gl_map(gl_entries)
Expand Down
7 changes: 5 additions & 2 deletions erpnext/accounts/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,8 @@ def reconcile_against_document(args):
# cancel advance entry
doc = frappe.get_doc(voucher_type, voucher_no)
frappe.flags.ignore_party_validation = True
doc.make_payment_ledger_entries(cancel=1, adv_adj=1)
gl_map = doc.build_gl_map(cancel=1)
create_payment_ledger_entry(gl_map, cancel=1, adv_adj=1)

for entry in entries:
check_if_advance_entry_modified(entry)
Expand All @@ -440,7 +441,9 @@ def reconcile_against_document(args):
doc.save(ignore_permissions=True)
# re-submit advance entry
doc = frappe.get_doc(entry.voucher_type, entry.voucher_no)
doc.make_payment_ledger_entries(cancel=0, adv_adj=1)
gl_map = doc.build_gl_map(cancel=1)
create_payment_ledger_entry(gl_map, cancel=1, adv_adj=1)

frappe.flags.ignore_party_validation = False

if entry.voucher_type in ("Payment Entry", "Journal Entry"):
Expand Down

0 comments on commit 8871025

Please sign in to comment.