test: pr billed amount against debit note

(cherry picked from commit 6d40844894)
This commit is contained in:
Gursheen Anand 2024-02-25 20:03:33 +05:30 committed by Mergify
parent bac2f66344
commit e67d579ac4

View File

@ -2405,6 +2405,41 @@ class TestPurchaseReceipt(FrappeTestCase):
"Stock Settings", "do_not_update_serial_batch_on_creation_of_auto_bundle", 1
)
def test_pr_billed_amount_against_return_entry(self):
from erpnext.accounts.doctype.purchase_invoice.purchase_invoice import make_debit_note
from erpnext.stock.doctype.purchase_receipt.purchase_receipt import (
make_purchase_invoice as make_pi_from_pr,
)
# Create a Purchase Receipt and Fully Bill it
pr = make_purchase_receipt(qty=10)
pi = make_pi_from_pr(pr.name)
pi.insert()
pi.submit()
# Debit Note - 50% Qty & enable updating PR billed amount
pi_return = make_debit_note(pi.name)
pi_return.items[0].qty = -5
pi_return.update_billed_amount_in_purchase_receipt = 1
pi_return.submit()
# Check if the billed amount reduced
pr.reload()
self.assertEqual(pr.per_billed, 50)
pi_return.reload()
pi_return.cancel()
# Debit Note - 50% Qty & disable updating PR billed amount
pi_return = make_debit_note(pi.name)
pi_return.items[0].qty = -5
pi_return.update_billed_amount_in_purchase_receipt = 0
pi_return.submit()
# Check if the billed amount stayed the same
pr.reload()
self.assertEqual(pr.per_billed, 100)
def prepare_data_for_internal_transfer():
from erpnext.accounts.doctype.sales_invoice.test_sales_invoice import create_internal_supplier