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

fix: corrected mismatch in the Purchase Receipt Status #15620 (backport #42138) #42252

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 4 additions & 1 deletion erpnext/controllers/status_updater.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,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
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
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.buying_controller import QtyMismatchError
from erpnext.stock import get_warehouse_account_map
from erpnext.stock.doctype.item.test_item import create_item, make_item
Expand Down Expand Up @@ -3229,6 +3230,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 @@ -3471,7 +3488,6 @@ def make_purchase_receipt(**args):
pr.insert()
if not args.do_not_submit:
pr.submit()

pr.load_from_db()

return pr
Expand Down
Loading