Custom discount management app for ERPNext.
This app provides:
- Discount approval workflow for Quotation and Sales Order.
- Item Group / Item specific discount rules.
- Landed cost based selling price updates for imported items.
- Adds custom fields to Quotation and Sales Order:
approval_statusapproval_commentsrequires_discount_approval
- Custom workflows enforce approval when discount limits are exceeded.
- ERPNext core max discount validation is bypassed in favor of this flow.
- Doctype: Item Group Discount Rule
- Apply rules by:
- Item Group (auto-populates items from a group)
- Item (manual selection only)
- Rules define a maximum discount percentage.
- Manual deletions in the items list are preserved.
- Adds
Item.is_importedand aLanded Cost Componentschild table. - On Purchase Receipt or Landed Cost Voucher submission:
- Calculates landed cost per imported item.
- Updates or creates Item Price in the standard selling price list.
pricing_rule/hooks.py- Registers doctypes, events, JS, and overrides.
pricing_rule/overrides/quotation.pypricing_rule/overrides/sales_order.pypricing_rule/overrides/sales_invoice.py
pricing_rule/discount_management/discount_approval.py- Approval workflow logic, validations, and API endpoints.
pricing_rule/discount_management/discount_rules.py- Applies max discount to Item based on active rules.
pricing_rule/discount_management/doctype/item_group_discount_rule/- Item Group Discount Rule doctype, controller, and client JS.
pricing_rule/discount_management/landed_cost.py- Recalculates selling price for imported items.
pricing_rule/fixtures/custom_field.jsonpricing_rule/fixtures/workflow.jsonpricing_rule/fixtures/workflow_state.jsonpricing_rule/fixtures/workflow_action_master.json
cd $PATH_TO_YOUR_BENCH
bench get-app $URL_OF_THIS_REPO --branch develop
bench install-app pricing_ruleThis app uses pre-commit for code formatting and linting.
cd apps/pricing_rule
pre-commit installEnabled tools:
- ruff
- eslint
- prettier
- pyupgrade
MIT