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

feat: fetching of qty as per received qty from PR to PI #25837

Merged
Changes from 1 commit
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
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
32 changes: 30 additions & 2 deletions erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.py
Original file line number Diff line number Diff line change
Expand Up @@ -414,11 +414,18 @@ def test_purchase_return_partial(self):
self.assertEqual(return_pr_2.items[0].qty, -3)

# Make PI against unreturned amount
buying_settings = frappe.get_single("Buying Settings")
AfshanKhan marked this conversation as resolved.
Show resolved Hide resolved
buying_settings.consider_rejected_quantity_for_purchase_invoice = 0
buying_settings.save()

pi = make_purchase_invoice(pr.name)
pi.submit()

self.assertEqual(pi.items[0].qty, 3)

buying_settings.consider_rejected_quantity_for_purchase_invoice = 1
buying_settings.save()

pr.load_from_db()
# PR should be completed on billing all unreturned amount
self.assertEqual(pr.items[0].billed_amt, 150)
Expand Down Expand Up @@ -760,8 +767,18 @@ def test_make_purchase_invoice_from_pr_for_returned_qty(self):
pr1.items[0].purchase_receipt_item = pr.items[0].name
pr1.submit()

pi = make_purchase_invoice(pr.name)
self.assertEqual(pi.items[0].qty, 3)
buying_settings = frappe.get_single("Buying Settings")
buying_settings.consider_rejected_quantity_for_purchase_invoice = 0
buying_settings.save()

pi1 = make_purchase_invoice(pr.name)
self.assertEqual(pi1.items[0].qty, 3)

buying_settings.consider_rejected_quantity_for_purchase_invoice = 1
buying_settings.save()

pi2 = make_purchase_invoice(pr.name)
self.assertEqual(pi2.items[0].qty, 4)

pr1.cancel()
pr.reload()
Expand Down Expand Up @@ -791,10 +808,21 @@ def test_make_purchase_invoice_from_pr_with_returned_qty_duplicate_items(self):
pr2.items[0].purchase_receipt_item = pr1.items[0].name
pr2.submit()

buying_settings = frappe.get_single("Buying Settings")
buying_settings.consider_rejected_quantity_for_purchase_invoice = 0
buying_settings.save()

pi2 = make_purchase_invoice(pr1.name)
self.assertEqual(pi2.items[0].qty, 2)
self.assertEqual(pi2.items[1].qty, 1)

buying_settings.consider_rejected_quantity_for_purchase_invoice = 1
buying_settings.save()

pi3 = make_purchase_invoice(pr1.name)
self.assertEqual(pi3.items[0].qty, 8)
self.assertEqual(pi3.items[1].qty, 1)

pr2.cancel()
pi1.cancel()
pr1.reload()
Expand Down