Skip to content

feat: Unit Price Items (backport #46214) #47410

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

Merged
merged 15 commits into from
May 23, 2025

Conversation

mergify[bot]
Copy link
Contributor

@mergify mergify bot commented May 5, 2025

Depends on #47537

Docs:

Closes #36012 (Refer for more Info)

Concept

  • Unit Price Items or Unit Price Contracts are a way to sell/agree upon a list of items whose quantity cannot be determined at the time of the sale but Rate/Unit Price can.
  • The quantity is determined once the job is fully or partially done and the agreement is to bill as per the Unit Price
Examples:
  • Sales Order for a Consultation firm:
Item Rate Qty
Consulting (per hour) $60 ?
  • Sales Order for a Construction Company for Road Work:
Item Rate Qty
Labour (per hour) $60 ?
Subcontracting/Partner Costs (per hour) $40 ?
  • The Sales Order/Quotation in both cases is agreed upon based on the unit cost/rate.
  • The ? Quantities will be determined once the job is done E.g. The hours put in for road work will be updated once half or all of the work is done. Invoicing is done on the basis of actual quantities.

Setup and Working

  • Screenshot 2025-02-28 at 11 07 53 PM
  • Screenshot 2025-03-17 at 7 43 00 PM
  • We now flag the record as has_unit_price_items if allowed via Settings and if it has any 0 qty items
  • We don't maintain row wise flags anymore. The user is free to leave the qty as 0. Nothing more
  • They will be reminded that the record contains unit price items
    Screenshot 2025-05-23 at 4 09 34 PM
  • A row is considered a unit price item only as long as it has 0 qty
  • Mapping to stock documents: Qty is mapped as is (0) until some qty is set in the Order, then it acts like a normal SO/PO row
  • Why 0 qty ? 1 Qty might be confusing as users might assume 1 qty is being sold in actuality. Also this makes handling billing, etc. easy with the least amount of code changes

Updating the SO/PO

Users can decide to manage their Transactions in two ways

  1. Keep updating the Qty in the Order ["Sales Order", "Purchase Order"]
    • Once a portion of work is done, users can update the qty in the SO/PO -> Then create SI/PI for the updated qty
  2. Keep the Qty 0 [SO, PO, RFQ, SQ, Quotation]
    • For those who might think constant updation SO is adding friction OR are not particular about tracking OR cannot update quantities in certain documents after submission, you can leave the quantities to be 0.
    • They can keep making Invoices with actual quantities against the SO/PO with 0 qty. The Billed % will always show as 0
    • The SO/PO will have to be manually Closed. Since there's no way to know when the Order is truly Completed.

TODO:

  • Extend to Purchase
  • Tests
  • Docs

Revival of #36024 in a hopefully cleaner way


This is an automatic backport of pull request #46214 done by Mergify.

marination and others added 8 commits May 5, 2025 16:59
(cherry picked from commit c1e4e7a)

# Conflicts:
#	erpnext/controllers/accounts_controller.py
#	erpnext/selling/doctype/quotation/quotation.json
#	erpnext/selling/doctype/sales_order/sales_order.py
#	erpnext/selling/doctype/selling_settings/selling_settings.json
(cherry picked from commit 71f65ba)

# Conflicts:
#	erpnext/selling/doctype/sales_order/sales_order.py
- chore: Extract `set_unit_price_items_note` into a util

(cherry picked from commit e403d3f)

# Conflicts:
#	erpnext/buying/doctype/buying_settings/buying_settings.json
#	erpnext/buying/doctype/purchase_order/purchase_order.json
#	erpnext/buying/doctype/request_for_quotation/request_for_quotation.json
#	erpnext/selling/doctype/quotation/quotation.json
#	erpnext/selling/doctype/selling_settings/selling_settings.json
(cherry picked from commit 8f96c0b)

# Conflicts:
#	erpnext/buying/doctype/request_for_quotation/test_request_for_quotation.py
#	erpnext/buying/doctype/supplier_quotation/test_supplier_quotation.py
- chore: Fix error message in accounts controller

(cherry picked from commit eea758f)

# Conflicts:
#	erpnext/buying/doctype/purchase_order/test_purchase_order.py
#	erpnext/buying/doctype/supplier_quotation/test_supplier_quotation.py
(cherry picked from commit 55981c8)

# Conflicts:
#	erpnext/selling/doctype/sales_order/test_sales_order.py
- The unit price check should depend on the row qty being 0
- Once the row ceases to be 0, it is treated as an ordinary row
- test: PO, SO and Quotation

(cherry picked from commit 0447c7b)

# Conflicts:
#	erpnext/selling/doctype/quotation/test_quotation.py
#	erpnext/selling/doctype/sales_order/test_sales_order.py
- `refresh` gets triggered twice and that renders the note twice
- Remove any existing note before rendering

(cherry picked from commit bf62f9a)

This comment was marked as outdated.

@marination
Copy link
Collaborator

marination commented May 12, 2025

@marination
Copy link
Collaborator

Linter failure is unrelated to the changes

@marination marination merged commit a6b1bdc into version-15-hotfix May 23, 2025
11 of 12 checks passed
@marination marination deleted the mergify/bp/version-15-hotfix/pr-46214 branch May 23, 2025 15:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant