Skip to content

Commit

Permalink
fix: corrected mismatch in the Purchase Receipt Status #15620
Browse files Browse the repository at this point in the history
  • Loading branch information
Poorvi-R-Bhat committed Jul 3, 2024
1 parent 1dae215 commit d9cb33e
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 4 deletions.
5 changes: 4 additions & 1 deletion erpnext/controllers/status_updater.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,10 @@ def validate_status(status, options):
["To Bill", "eval:self.per_billed == 0 and self.docstatus == 1"],
["Partly Billed", "eval:self.per_billed > 0 and self.per_billed < 100 and self.docstatus == 1"],
["Return Issued", "eval:self.per_returned == 100 and self.docstatus == 1"],
["Completed", "eval:self.per_billed == 100 and self.docstatus == 1"],
[
"Completed",
"eval:(self.per_billed == 100 and self.docstatus == 1 and self.grand_total != 0) or (self.docstatus == 1 and self.grand_total == 0)",
],
["Cancelled", "eval:self.docstatus==2"],
["Closed", "eval:self.status=='Closed' and self.docstatus != 2"],
],
Expand Down
38 changes: 35 additions & 3 deletions erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.py
Original file line number Diff line number Diff line change
Expand Up @@ -3210,6 +3210,39 @@ def create_lcv(self, receipt_document_type, receipt_document, company, expense_a
lcv.save().submit()
return lcv

def test_status_mapping(self):
purchase_receipt = frappe.get_doc(
{
"doctype": "Purchase Receipt",
"supplier": "Test Supplier",
"grand_total": 0.0,
"base_rounded_total": 0.0,
"rounded_total": 0.0,
"base_net_total": 0.0,
"posting_date": frappe.utils.today(),
"items": [
{
"item_code": "item_for_status",
"item_name": "item_for_status",
"description": "item_for_status",
"uom": "Nos",
"qty": 1,
"rate": 0,
"amount": 0,
"base_rate": 0,
"base_amount": 0,
"warehouse": "Stores - W",
}
],
}
)
purchase_receipt.insert()
purchase_receipt.save()
purchase_receipt.submit()
purchase_receipt.reload()
self.assertEqual(purchase_receipt.grand_total, 0.0)
self.assertEqual(purchase_receipt.status, "Completed")


def prepare_data_for_internal_transfer():
from erpnext.accounts.doctype.sales_invoice.test_sales_invoice import create_internal_supplier
Expand Down Expand Up @@ -3453,11 +3486,10 @@ def make_purchase_receipt(**args):
pr.insert()
if not args.do_not_submit:
pr.submit()

pr.load_from_db()
pr.load_from_db()

return pr


test_dependencies = ["BOM", "Item Price", "Location"]
test_records = frappe.get_test_records("Purchase Receipt")
test_records = frappe.get_test_records("Purchase Receipt")

0 comments on commit d9cb33e

Please sign in to comment.