Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: adjusted incoming rate for zero rated item in purchase receipt #44415

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1742,6 +1742,30 @@ def test_adjust_incoming_rate(self):

frappe.db.set_single_value("Buying Settings", "set_landed_cost_based_on_purchase_invoice_rate", 1)

# Cost of Item is zero in Purchase Receipt
pr = make_purchase_receipt(qty=1, rate=0)

stock_value_difference = frappe.db.get_value(
"Stock Ledger Entry",
{"voucher_type": "Purchase Receipt", "voucher_no": pr.name},
"stock_value_difference",
)
self.assertEqual(stock_value_difference, 0)

pi = create_purchase_invoice_from_receipt(pr.name)
for row in pi.items:
row.rate = 150

pi.save()
pi.submit()

stock_value_difference = frappe.db.get_value(
"Stock Ledger Entry",
{"voucher_type": "Purchase Receipt", "voucher_no": pr.name},
"stock_value_difference",
)
self.assertEqual(stock_value_difference, 150)

# Increase the cost of the item

pr = make_purchase_receipt(qty=1, rate=100)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1076,7 +1076,7 @@ def update_billing_percentage(pr_doc, update_modified=True, adjust_incoming_rate

if adjust_incoming_rate:
adjusted_amt = 0.0
if item.billed_amt and item.amount:
if item.billed_amt is not None and item.amount is not None:
adjusted_amt = flt(item.billed_amt) - flt(item.amount)

adjusted_amt = adjusted_amt * flt(pr_doc.conversion_rate)
Expand Down
Loading