fix: provisional reverse entry amount
diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py
index c4e09b4..4b1641e 100644
--- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py
+++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py
@@ -1025,7 +1025,7 @@
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,
@@ -1034,13 +1034,13 @@
"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():
diff --git a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py
index bf6080b..360b911 100644
--- a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py
+++ b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py
@@ -730,16 +730,19 @@
)
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"]
)
@@ -749,7 +752,7 @@
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,
@@ -763,7 +766,7 @@
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,