Skip to content

Commit

Permalink
fix: provisional reverse entry amount
Browse files Browse the repository at this point in the history
(cherry picked from commit 3e59c66)
  • Loading branch information
GursheenK authored and mergify[bot] committed Feb 29, 2024
1 parent fca70e3 commit e62c49d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
6 changes: 3 additions & 3 deletions erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py
Original file line number Diff line number Diff line change
Expand Up @@ -869,7 +869,7 @@ def make_item_gl_entries(self, gl_entries):
purchase_receipt_doc_map[item.purchase_receipt] = purchase_receipt_doc

# Post reverse entry for Stock-Received-But-Not-Billed if it is booked in Purchase Receipt
expense_booked_in_pr = frappe.db.get_value(
expense_booked_in_pr, credit = frappe.db.get_value(
"GL Entry",
{
"is_cancelled": 0,
Expand All @@ -878,13 +878,13 @@ def make_item_gl_entries(self, gl_entries):
"voucher_detail_no": item.pr_detail,
"account": provisional_account,
},
["name"],
["name", "credit"],
)

if expense_booked_in_pr:
# Intentionally passing purchase invoice item to handle partial billing
purchase_receipt_doc.add_provisional_gl_entry(
item, gl_entries, self.posting_date, provisional_account, reverse=1
item, gl_entries, self.posting_date, provisional_account, reverse=1, item_amount=credit
)

if not self.is_internal_transfer():
Expand Down
9 changes: 6 additions & 3 deletions erpnext/stock/doctype/purchase_receipt/purchase_receipt.py
Original file line number Diff line number Diff line change
Expand Up @@ -615,16 +615,19 @@ def make_divisional_loss_gl_entry(item, outgoing_amount):
)

def add_provisional_gl_entry(
self, item, gl_entries, posting_date, provisional_account, reverse=0
self, item, gl_entries, posting_date, provisional_account, reverse=0, item_amount=None
):
credit_currency = get_account_currency(provisional_account)
expense_account = item.expense_account
debit_currency = get_account_currency(item.expense_account)
remarks = self.get("remarks") or _("Accounting Entry for Service")
multiplication_factor = 1
amount = item.base_amount

if reverse:
multiplication_factor = -1
# Post reverse entry for previously posted amount
amount = item_amount
expense_account = frappe.db.get_value(
"Purchase Receipt Item", {"name": item.get("pr_detail")}, ["expense_account"]
)
Expand All @@ -634,7 +637,7 @@ def add_provisional_gl_entry(
account=provisional_account,
cost_center=item.cost_center,
debit=0.0,
credit=multiplication_factor * item.base_amount,
credit=multiplication_factor * amount,
remarks=remarks,
against_account=expense_account,
account_currency=credit_currency,
Expand All @@ -648,7 +651,7 @@ def add_provisional_gl_entry(
gl_entries=gl_entries,
account=expense_account,
cost_center=item.cost_center,
debit=multiplication_factor * item.base_amount,
debit=multiplication_factor * amount,
credit=0.0,
remarks=remarks,
against_account=provisional_account,
Expand Down

0 comments on commit e62c49d

Please sign in to comment.