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 9, 2024
1 parent 4936514 commit 3fc2556
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 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) or (self.docstatus == 1 and self.grand_total == 0 and self.per_returned != 100 and self.is_return == 0)",
],
["Cancelled", "eval:self.docstatus==2"],
["Closed", "eval:self.status=='Closed' and self.docstatus != 2"],
],
Expand Down
3 changes: 2 additions & 1 deletion erpnext/stock/doctype/purchase_receipt/purchase_receipt.json
Original file line number Diff line number Diff line change
Expand Up @@ -1111,6 +1111,7 @@
"depends_on": "eval:!doc.__islocal",
"fieldname": "per_returned",
"fieldtype": "Percent",
"in_list_view": 1,
"label": "% Returned",
"no_copy": 1,
"print_hide": 1,
Expand Down Expand Up @@ -1272,7 +1273,7 @@
"idx": 261,
"is_submittable": 1,
"links": [],
"modified": "2024-04-08 20:23:03.699201",
"modified": "2024-07-04 14:50:10.538472",
"modified_by": "Administrator",
"module": "Stock",
"name": "Purchase Receipt",
Expand Down
18 changes: 17 additions & 1 deletion erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import erpnext
from erpnext.accounts.doctype.account.test_account import get_inventory_account
from erpnext.buying.doctype.supplier.test_supplier import create_supplier
from erpnext.controllers.accounts_controller import InvalidQtyError
from erpnext.controllers.buying_controller import QtyMismatchError
from erpnext.stock import get_warehouse_account_map
Expand Down Expand Up @@ -3269,6 +3270,22 @@ def test_do_not_use_batchwise_valuation_rate(self):
doc.flags.ignore_validate = True
doc.save()

def test_status_mapping(self):
item_code = "item_for_status"
create_item(item_code)
create_item("item_for_status")
warehouse = create_warehouse("Stores")
supplier = "Test Supplier"
create_supplier(supplier_name=supplier)
pr = make_purchase_receipt(
item_code=item_code,
warehouse=warehouse,
qty=1,
rate=0,
)
self.assertEqual(pr.grand_total, 0.0)
self.assertEqual(pr.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 @@ -3512,7 +3529,6 @@ def make_purchase_receipt(**args):
pr.insert()
if not args.do_not_submit:
pr.submit()

pr.load_from_db()

return pr
Expand Down

0 comments on commit 3fc2556

Please sign in to comment.