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 43b79e3 commit fb253d4
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
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
33 changes: 33 additions & 0 deletions erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.py
Original file line number Diff line number Diff line change
Expand Up @@ -3060,6 +3060,39 @@ def test_purchase_return_from_rejected_warehouse(self):
self.assertEqual(pr_return.items[0].rejected_qty, 0.0)
self.assertEqual(pr_return.items[0].rejected_warehouse, "")

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

0 comments on commit fb253d4

Please sign in to comment.