mirror of
https://github.com/frappe/erpnext.git
synced 2026-03-20 18:54:55 +00:00
fix: provisional reverse entry amount
(cherry picked from commit 3e59c66806)
This commit is contained in:
@@ -1033,7 +1033,7 @@ class PurchaseInvoice(BuyingController):
|
|||||||
purchase_receipt_doc_map[item.purchase_receipt] = purchase_receipt_doc
|
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
|
# 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",
|
"GL Entry",
|
||||||
{
|
{
|
||||||
"is_cancelled": 0,
|
"is_cancelled": 0,
|
||||||
@@ -1042,13 +1042,13 @@ class PurchaseInvoice(BuyingController):
|
|||||||
"voucher_detail_no": item.pr_detail,
|
"voucher_detail_no": item.pr_detail,
|
||||||
"account": provisional_account,
|
"account": provisional_account,
|
||||||
},
|
},
|
||||||
["name"],
|
["name", "credit"],
|
||||||
)
|
)
|
||||||
|
|
||||||
if expense_booked_in_pr:
|
if expense_booked_in_pr:
|
||||||
# Intentionally passing purchase invoice item to handle partial billing
|
# Intentionally passing purchase invoice item to handle partial billing
|
||||||
purchase_receipt_doc.add_provisional_gl_entry(
|
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():
|
if not self.is_internal_transfer():
|
||||||
|
|||||||
@@ -727,16 +727,19 @@ class PurchaseReceipt(BuyingController):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def add_provisional_gl_entry(
|
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)
|
credit_currency = get_account_currency(provisional_account)
|
||||||
expense_account = item.expense_account
|
expense_account = item.expense_account
|
||||||
debit_currency = get_account_currency(item.expense_account)
|
debit_currency = get_account_currency(item.expense_account)
|
||||||
remarks = self.get("remarks") or _("Accounting Entry for Service")
|
remarks = self.get("remarks") or _("Accounting Entry for Service")
|
||||||
multiplication_factor = 1
|
multiplication_factor = 1
|
||||||
|
amount = item.base_amount
|
||||||
|
|
||||||
if reverse:
|
if reverse:
|
||||||
multiplication_factor = -1
|
multiplication_factor = -1
|
||||||
|
# Post reverse entry for previously posted amount
|
||||||
|
amount = item_amount
|
||||||
expense_account = frappe.db.get_value(
|
expense_account = frappe.db.get_value(
|
||||||
"Purchase Receipt Item", {"name": item.get("pr_detail")}, ["expense_account"]
|
"Purchase Receipt Item", {"name": item.get("pr_detail")}, ["expense_account"]
|
||||||
)
|
)
|
||||||
@@ -746,7 +749,7 @@ class PurchaseReceipt(BuyingController):
|
|||||||
account=provisional_account,
|
account=provisional_account,
|
||||||
cost_center=item.cost_center,
|
cost_center=item.cost_center,
|
||||||
debit=0.0,
|
debit=0.0,
|
||||||
credit=multiplication_factor * item.base_amount,
|
credit=multiplication_factor * amount,
|
||||||
remarks=remarks,
|
remarks=remarks,
|
||||||
against_account=expense_account,
|
against_account=expense_account,
|
||||||
account_currency=credit_currency,
|
account_currency=credit_currency,
|
||||||
@@ -760,7 +763,7 @@ class PurchaseReceipt(BuyingController):
|
|||||||
gl_entries=gl_entries,
|
gl_entries=gl_entries,
|
||||||
account=expense_account,
|
account=expense_account,
|
||||||
cost_center=item.cost_center,
|
cost_center=item.cost_center,
|
||||||
debit=multiplication_factor * item.base_amount,
|
debit=multiplication_factor * amount,
|
||||||
credit=0.0,
|
credit=0.0,
|
||||||
remarks=remarks,
|
remarks=remarks,
|
||||||
against_account=provisional_account,
|
against_account=provisional_account,
|
||||||
|
|||||||
Reference in New Issue
Block a user