lambda-erp 1.4.21__tar.gz → 1.4.23__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {lambda_erp-1.4.21 → lambda_erp-1.4.23}/PKG-INFO +3 -1
- {lambda_erp-1.4.21 → lambda_erp-1.4.23}/README.md +2 -0
- {lambda_erp-1.4.21 → lambda_erp-1.4.23}/api/chat.py +9 -0
- {lambda_erp-1.4.21 → lambda_erp-1.4.23}/api/pdf.py +19 -0
- {lambda_erp-1.4.21 → lambda_erp-1.4.23}/api/pdf_profiles.py +4 -1
- {lambda_erp-1.4.21 → lambda_erp-1.4.23}/api/pdf_templates.py +1 -0
- {lambda_erp-1.4.21 → lambda_erp-1.4.23}/api/services.py +3 -0
- {lambda_erp-1.4.21 → lambda_erp-1.4.23}/api/templates/delivery_note.html +1 -1
- {lambda_erp-1.4.21 → lambda_erp-1.4.23}/api/templates/document.html +4 -3
- {lambda_erp-1.4.21 → lambda_erp-1.4.23}/lambda_erp/accounting/pos_invoice.py +2 -1
- {lambda_erp-1.4.21 → lambda_erp-1.4.23}/lambda_erp/accounting/purchase_invoice.py +2 -1
- {lambda_erp-1.4.21 → lambda_erp-1.4.23}/lambda_erp/accounting/sales_invoice.py +2 -1
- {lambda_erp-1.4.21 → lambda_erp-1.4.23}/lambda_erp/buying/purchase_order.py +2 -1
- {lambda_erp-1.4.21 → lambda_erp-1.4.23}/lambda_erp/controllers/item_price.py +59 -9
- {lambda_erp-1.4.21 → lambda_erp-1.4.23}/lambda_erp/controllers/taxes_and_totals.py +14 -4
- {lambda_erp-1.4.21 → lambda_erp-1.4.23}/lambda_erp/database.py +47 -0
- {lambda_erp-1.4.21 → lambda_erp-1.4.23}/lambda_erp/permissions.py +20 -0
- {lambda_erp-1.4.21 → lambda_erp-1.4.23}/lambda_erp/selling/quotation.py +6 -3
- {lambda_erp-1.4.21 → lambda_erp-1.4.23}/lambda_erp/selling/sales_order.py +2 -1
- {lambda_erp-1.4.21 → lambda_erp-1.4.23}/lambda_erp/stock/consignment.py +17 -6
- {lambda_erp-1.4.21 → lambda_erp-1.4.23}/lambda_erp/stock/delivery_note.py +6 -3
- {lambda_erp-1.4.21 → lambda_erp-1.4.23}/lambda_erp/stock/purchase_receipt.py +6 -3
- {lambda_erp-1.4.21 → lambda_erp-1.4.23}/lambda_erp/stock/stock_count.py +11 -0
- {lambda_erp-1.4.21 → lambda_erp-1.4.23}/lambda_erp/stock/stock_entry.py +4 -0
- lambda_erp-1.4.23/lambda_erp/units.py +223 -0
- {lambda_erp-1.4.21 → lambda_erp-1.4.23}/lambda_erp/workflow.py +6 -0
- {lambda_erp-1.4.21 → lambda_erp-1.4.23}/pyproject.toml +1 -1
- {lambda_erp-1.4.21 → lambda_erp-1.4.23}/.gitignore +0 -0
- {lambda_erp-1.4.21 → lambda_erp-1.4.23}/LICENSE +0 -0
- {lambda_erp-1.4.21 → lambda_erp-1.4.23}/api/__init__.py +0 -0
- {lambda_erp-1.4.21 → lambda_erp-1.4.23}/api/attachments.py +0 -0
- {lambda_erp-1.4.21 → lambda_erp-1.4.23}/api/auth.py +0 -0
- {lambda_erp-1.4.21 → lambda_erp-1.4.23}/api/bootstrap.py +0 -0
- {lambda_erp-1.4.21 → lambda_erp-1.4.23}/api/chat_links.py +0 -0
- {lambda_erp-1.4.21 → lambda_erp-1.4.23}/api/demo_limits.py +0 -0
- {lambda_erp-1.4.21 → lambda_erp-1.4.23}/api/deps.py +0 -0
- {lambda_erp-1.4.21 → lambda_erp-1.4.23}/api/erp_context.py +0 -0
- {lambda_erp-1.4.21 → lambda_erp-1.4.23}/api/errors.py +0 -0
- {lambda_erp-1.4.21 → lambda_erp-1.4.23}/api/list_values.py +0 -0
- {lambda_erp-1.4.21 → lambda_erp-1.4.23}/api/llm_provider.py +0 -0
- {lambda_erp-1.4.21 → lambda_erp-1.4.23}/api/main.py +0 -0
- {lambda_erp-1.4.21 → lambda_erp-1.4.23}/api/mcp_oauth.py +0 -0
- {lambda_erp-1.4.21 → lambda_erp-1.4.23}/api/mentions.py +0 -0
- {lambda_erp-1.4.21 → lambda_erp-1.4.23}/api/menu_layout.py +0 -0
- {lambda_erp-1.4.21 → lambda_erp-1.4.23}/api/oauth.py +0 -0
- {lambda_erp-1.4.21 → lambda_erp-1.4.23}/api/pdf_contract.py +0 -0
- {lambda_erp-1.4.21 → lambda_erp-1.4.23}/api/pdf_exports.py +0 -0
- {lambda_erp-1.4.21 → lambda_erp-1.4.23}/api/pdf_fonts.py +0 -0
- {lambda_erp-1.4.21 → lambda_erp-1.4.23}/api/pdf_pages.py +0 -0
- {lambda_erp-1.4.21 → lambda_erp-1.4.23}/api/pricing_actions.py +0 -0
- {lambda_erp-1.4.21 → lambda_erp-1.4.23}/api/providers.py +0 -0
- {lambda_erp-1.4.21 → lambda_erp-1.4.23}/api/record_attachments.py +0 -0
- {lambda_erp-1.4.21 → lambda_erp-1.4.23}/api/record_notes.py +0 -0
- {lambda_erp-1.4.21 → lambda_erp-1.4.23}/api/remarks_md.py +0 -0
- {lambda_erp-1.4.21 → lambda_erp-1.4.23}/api/routers/__init__.py +0 -0
- {lambda_erp-1.4.21 → lambda_erp-1.4.23}/api/routers/accounting.py +0 -0
- {lambda_erp-1.4.21 → lambda_erp-1.4.23}/api/routers/actions.py +0 -0
- {lambda_erp-1.4.21 → lambda_erp-1.4.23}/api/routers/admin.py +0 -0
- {lambda_erp-1.4.21 → lambda_erp-1.4.23}/api/routers/analytics.py +0 -0
- {lambda_erp-1.4.21 → lambda_erp-1.4.23}/api/routers/availability.py +0 -0
- {lambda_erp-1.4.21 → lambda_erp-1.4.23}/api/routers/bank_reconciliation.py +0 -0
- {lambda_erp-1.4.21 → lambda_erp-1.4.23}/api/routers/bank_statements.py +0 -0
- {lambda_erp-1.4.21 → lambda_erp-1.4.23}/api/routers/chat_api.py +0 -0
- {lambda_erp-1.4.21 → lambda_erp-1.4.23}/api/routers/documents.py +0 -0
- {lambda_erp-1.4.21 → lambda_erp-1.4.23}/api/routers/masters.py +0 -0
- {lambda_erp-1.4.21 → lambda_erp-1.4.23}/api/routers/mcp.py +0 -0
- {lambda_erp-1.4.21 → lambda_erp-1.4.23}/api/routers/pdf_templates.py +0 -0
- {lambda_erp-1.4.21 → lambda_erp-1.4.23}/api/routers/proposals.py +0 -0
- {lambda_erp-1.4.21 → lambda_erp-1.4.23}/api/routers/reports.py +0 -0
- {lambda_erp-1.4.21 → lambda_erp-1.4.23}/api/routers/setup.py +0 -0
- {lambda_erp-1.4.21 → lambda_erp-1.4.23}/api/stock_actions.py +0 -0
- {lambda_erp-1.4.21 → lambda_erp-1.4.23}/api/templates/_proposal_totals.html +0 -0
- {lambda_erp-1.4.21 → lambda_erp-1.4.23}/api/templates/_record_base.html +0 -0
- {lambda_erp-1.4.21 → lambda_erp-1.4.23}/api/templates/proposal.html +0 -0
- {lambda_erp-1.4.21 → lambda_erp-1.4.23}/api/templates/record.html +0 -0
- {lambda_erp-1.4.21 → lambda_erp-1.4.23}/api/templates/reservation.html +0 -0
- {lambda_erp-1.4.21 → lambda_erp-1.4.23}/api/time_filters.py +0 -0
- {lambda_erp-1.4.21 → lambda_erp-1.4.23}/api/tool_permissions.py +0 -0
- {lambda_erp-1.4.21 → lambda_erp-1.4.23}/api/write_context.py +0 -0
- {lambda_erp-1.4.21 → lambda_erp-1.4.23}/docs/agents/README.md +0 -0
- {lambda_erp-1.4.21 → lambda_erp-1.4.23}/frontend/LICENSE +0 -0
- {lambda_erp-1.4.21 → lambda_erp-1.4.23}/frontend/README.md +0 -0
- {lambda_erp-1.4.21 → lambda_erp-1.4.23}/frontend/src/api/client.ts +0 -0
- {lambda_erp-1.4.21 → lambda_erp-1.4.23}/lambda_erp/__init__.py +0 -0
- {lambda_erp-1.4.21 → lambda_erp-1.4.23}/lambda_erp/accounting/__init__.py +0 -0
- {lambda_erp-1.4.21 → lambda_erp-1.4.23}/lambda_erp/accounting/bank_account.py +0 -0
- {lambda_erp-1.4.21 → lambda_erp-1.4.23}/lambda_erp/accounting/bank_reconciliation.py +0 -0
- {lambda_erp-1.4.21 → lambda_erp-1.4.23}/lambda_erp/accounting/bank_statement_import.py +0 -0
- {lambda_erp-1.4.21 → lambda_erp-1.4.23}/lambda_erp/accounting/bank_transaction.py +0 -0
- {lambda_erp-1.4.21 → lambda_erp-1.4.23}/lambda_erp/accounting/budget.py +0 -0
- {lambda_erp-1.4.21 → lambda_erp-1.4.23}/lambda_erp/accounting/camt.py +0 -0
- {lambda_erp-1.4.21 → lambda_erp-1.4.23}/lambda_erp/accounting/chart_of_accounts.py +0 -0
- {lambda_erp-1.4.21 → lambda_erp-1.4.23}/lambda_erp/accounting/general_ledger.py +0 -0
- {lambda_erp-1.4.21 → lambda_erp-1.4.23}/lambda_erp/accounting/journal_entry.py +0 -0
- {lambda_erp-1.4.21 → lambda_erp-1.4.23}/lambda_erp/accounting/payment_entry.py +0 -0
- {lambda_erp-1.4.21 → lambda_erp-1.4.23}/lambda_erp/accounting/revaluation.py +0 -0
- {lambda_erp-1.4.21 → lambda_erp-1.4.23}/lambda_erp/accounting/settlement.py +0 -0
- {lambda_erp-1.4.21 → lambda_erp-1.4.23}/lambda_erp/accounting/setup/__init__.py +0 -0
- {lambda_erp-1.4.21 → lambda_erp-1.4.23}/lambda_erp/accounting/setup/engine.py +0 -0
- {lambda_erp-1.4.21 → lambda_erp-1.4.23}/lambda_erp/accounting/setup/pack.py +0 -0
- {lambda_erp-1.4.21 → lambda_erp-1.4.23}/lambda_erp/accounting/setup/packs/__init__.py +0 -0
- {lambda_erp-1.4.21 → lambda_erp-1.4.23}/lambda_erp/accounting/setup/packs/ch.py +0 -0
- {lambda_erp-1.4.21 → lambda_erp-1.4.23}/lambda_erp/accounting/setup/packs/de_common.py +0 -0
- {lambda_erp-1.4.21 → lambda_erp-1.4.23}/lambda_erp/accounting/setup/packs/de_skr03.py +0 -0
- {lambda_erp-1.4.21 → lambda_erp-1.4.23}/lambda_erp/accounting/setup/packs/de_skr04.py +0 -0
- {lambda_erp-1.4.21 → lambda_erp-1.4.23}/lambda_erp/accounting/setup/packs/generic.py +0 -0
- {lambda_erp-1.4.21 → lambda_erp-1.4.23}/lambda_erp/accounting/setup/profiles.py +0 -0
- {lambda_erp-1.4.21 → lambda_erp-1.4.23}/lambda_erp/accounting/setup/spine.py +0 -0
- {lambda_erp-1.4.21 → lambda_erp-1.4.23}/lambda_erp/accounting/subscription.py +0 -0
- {lambda_erp-1.4.21 → lambda_erp-1.4.23}/lambda_erp/addresses.py +0 -0
- {lambda_erp-1.4.21 → lambda_erp-1.4.23}/lambda_erp/assets/__init__.py +0 -0
- {lambda_erp-1.4.21 → lambda_erp-1.4.23}/lambda_erp/assets/asset.py +0 -0
- {lambda_erp-1.4.21 → lambda_erp-1.4.23}/lambda_erp/assets/lifecycle.py +0 -0
- {lambda_erp-1.4.21 → lambda_erp-1.4.23}/lambda_erp/assets/reservation.py +0 -0
- {lambda_erp-1.4.21 → lambda_erp-1.4.23}/lambda_erp/backlog.py +0 -0
- {lambda_erp-1.4.21 → lambda_erp-1.4.23}/lambda_erp/bundles.py +0 -0
- {lambda_erp-1.4.21 → lambda_erp-1.4.23}/lambda_erp/buying/__init__.py +0 -0
- {lambda_erp-1.4.21 → lambda_erp-1.4.23}/lambda_erp/controllers/__init__.py +0 -0
- {lambda_erp-1.4.21 → lambda_erp-1.4.23}/lambda_erp/controllers/currency.py +0 -0
- {lambda_erp-1.4.21 → lambda_erp-1.4.23}/lambda_erp/controllers/defaults.py +0 -0
- {lambda_erp-1.4.21 → lambda_erp-1.4.23}/lambda_erp/controllers/item_prices.py +0 -0
- {lambda_erp-1.4.21 → lambda_erp-1.4.23}/lambda_erp/controllers/price_resolution.py +0 -0
- {lambda_erp-1.4.21 → lambda_erp-1.4.23}/lambda_erp/controllers/pricing_rule.py +0 -0
- {lambda_erp-1.4.21 → lambda_erp-1.4.23}/lambda_erp/controllers/tax_defaults.py +0 -0
- {lambda_erp-1.4.21 → lambda_erp-1.4.23}/lambda_erp/exceptions.py +0 -0
- {lambda_erp-1.4.21 → lambda_erp-1.4.23}/lambda_erp/hooks.py +0 -0
- {lambda_erp-1.4.21 → lambda_erp-1.4.23}/lambda_erp/master_integrity.py +0 -0
- {lambda_erp-1.4.21 → lambda_erp-1.4.23}/lambda_erp/model.py +0 -0
- {lambda_erp-1.4.21 → lambda_erp-1.4.23}/lambda_erp/selling/__init__.py +0 -0
- {lambda_erp-1.4.21 → lambda_erp-1.4.23}/lambda_erp/selling/proposal.py +0 -0
- {lambda_erp-1.4.21 → lambda_erp-1.4.23}/lambda_erp/simulation.py +0 -0
- {lambda_erp-1.4.21 → lambda_erp-1.4.23}/lambda_erp/stock/__init__.py +0 -0
- {lambda_erp-1.4.21 → lambda_erp-1.4.23}/lambda_erp/stock/reservation.py +0 -0
- {lambda_erp-1.4.21 → lambda_erp-1.4.23}/lambda_erp/stock/serial.py +0 -0
- {lambda_erp-1.4.21 → lambda_erp-1.4.23}/lambda_erp/stock/stock_ledger.py +0 -0
- {lambda_erp-1.4.21 → lambda_erp-1.4.23}/lambda_erp/timestamps.py +0 -0
- {lambda_erp-1.4.21 → lambda_erp-1.4.23}/lambda_erp/utils.py +0 -0
- {lambda_erp-1.4.21 → lambda_erp-1.4.23}/lambda_erp/validation.py +0 -0
- {lambda_erp-1.4.21 → lambda_erp-1.4.23}/terraform/README.md +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: lambda-erp
|
|
3
|
-
Version: 1.4.
|
|
3
|
+
Version: 1.4.23
|
|
4
4
|
Summary: Core ERP logic - accounting, sales, purchasing, inventory
|
|
5
5
|
Author: TORUS INVESTMENTS AG
|
|
6
6
|
License-Expression: Apache-2.0
|
|
@@ -34,6 +34,8 @@ Description-Content-Type: text/markdown
|
|
|
34
34
|
|
|
35
35
|
Lambda ERP is a simpler ERP: create invoices, check inventory, answer accounting questions, and change reports by asking for what you need in plain language.
|
|
36
36
|
|
|
37
|
+
Developed by [Lambda](https://lambda.dev/erp).
|
|
38
|
+
|
|
37
39
|
https://github.com/user-attachments/assets/1b2749ef-10e7-42f5-9cce-df5628292667
|
|
38
40
|
|
|
39
41
|
<p align="center">
|
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
|
|
5
5
|
Lambda ERP is a simpler ERP: create invoices, check inventory, answer accounting questions, and change reports by asking for what you need in plain language.
|
|
6
6
|
|
|
7
|
+
Developed by [Lambda](https://lambda.dev/erp).
|
|
8
|
+
|
|
7
9
|
https://github.com/user-attachments/assets/1b2749ef-10e7-42f5-9cce-df5628292667
|
|
8
10
|
|
|
9
11
|
<p align="center">
|
|
@@ -3060,6 +3060,15 @@ For a complete sales return (financial + stock): create and submit both a Credit
|
|
|
3060
3060
|
- On quotations, sales orders, delivery notes and sales / POS invoices, put the bundle's item_code and qty on a line and save: the line is replaced by one line per item of the bundle, which are then ordinary lines. Do not give a bundle line a rate, discount or batch; do not expand a bundle by hand.
|
|
3061
3061
|
- When the user names a set, look for it with list_documents doctype="item-bundle" (or the item) before listing single items yourself.
|
|
3062
3062
|
|
|
3063
|
+
### Units of measure (ordering in a pack, stocking in pieces)
|
|
3064
|
+
- An item is stocked in its `stock_uom`. An **Item Unit** (doctype `item-unit`: item_code, uom, conversion_factor = stock units per unit, e.g. Karton = 100) gives it a further unit. List an item's units with list_documents doctype="item-unit" filtered by item_code.
|
|
3065
|
+
- To enter a line in such a unit, send `qty` and `rate` in that unit and name it in `uom` (qty 2, uom "Karton", rate 290). On save the line is stored per stock unit (qty 200, rate 2.90) and keeps `order_uom`, `conversion_factor` and `order_qty` (2). Amounts are unchanged: 2 x 290 = 200 x 2.90.
|
|
3066
|
+
- On a stored line `qty`, `rate`, delivered/billed quantities and every stock figure are in the stock unit; `order_qty` + `order_uom` say what was ordered. Tell the user both when they differ ("2 Karton = 200 Stk"). Never multiply or divide by the factor yourself before sending a line: either send the entered unit in `uom`, or send stock units.
|
|
3067
|
+
- A unit the item does not have is refused. Do not guess a factor from a product name or from "VE"/"Pack": ask, or have an Item Unit created first.
|
|
3068
|
+
- An Item Price with `uom` set is a price per that unit (290 per Karton) and is used for lines entered in it; a price without `uom` is per stock unit. `per_qty` on an Item Price means the rate buys that many units (12.50 per 100 = 0.125 each); it is not a pack size.
|
|
3069
|
+
- An Item Unit with must_be_whole_number = 1 takes whole quantities only (2 Karton, not 1.5); say so instead of rounding.
|
|
3070
|
+
- Consignment withdrawals (qty + uom) and stock counts (counted_qty + uom) can be entered in a unit the same way; returns too (qty -1, uom "Karton").
|
|
3071
|
+
|
|
3063
3072
|
### Addresses
|
|
3064
3073
|
- A customer can have several addresses (master_type="address": customer, label, is_billing, is_shipping, is_default_billing, is_default_shipping, recipient_name, contact_person, address, zip_code, city, country, instructions). Search them with search_masters master_type="address" and the customer's name.
|
|
3065
3074
|
- Quotation, Sales Order, Delivery Note and Sales Invoice carry `billing_address` and `shipping_address` (address record ids of that customer) and `billing_address_display` / `shipping_address_display` (the text that prints). Leave them out to get the customer's defaults; documents made from an order follow the order.
|
|
@@ -110,6 +110,25 @@ def add_line_deductions(items):
|
|
|
110
110
|
item["discount_total"], item["discount_label"] = deduction["amount"], deduction["label"]
|
|
111
111
|
else:
|
|
112
112
|
item["discount_total"] = 0
|
|
113
|
+
add_order_unit(item)
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
def add_order_unit(item):
|
|
117
|
+
"""A line ordered in a further unit of the item (lambda_erp/units.py) is
|
|
118
|
+
stored per stock unit. For printing it also gets the price per ordered
|
|
119
|
+
unit: item.order_rate (and item.order_gross_rate before a deduction), next
|
|
120
|
+
to item.order_qty and item.order_uom. item.ordered_in_unit says whether
|
|
121
|
+
the line has them."""
|
|
122
|
+
try:
|
|
123
|
+
factor = float(item.get("conversion_factor") or 0)
|
|
124
|
+
except (TypeError, ValueError):
|
|
125
|
+
factor = 0
|
|
126
|
+
ordered = bool(item.get("order_uom")) and factor > 0
|
|
127
|
+
item["ordered_in_unit"] = ordered
|
|
128
|
+
if ordered:
|
|
129
|
+
item["order_rate"] = round(float(item.get("rate") or 0) * factor, 2)
|
|
130
|
+
if item.get("gross_rate") is not None:
|
|
131
|
+
item["order_gross_rate"] = round(float(item.get("gross_rate") or 0) * factor, 2)
|
|
113
132
|
|
|
114
133
|
|
|
115
134
|
def fill_text_placeholders(text, doc, party_name=None, company_name=None) -> str:
|
|
@@ -107,8 +107,11 @@ PROFILES.update({
|
|
|
107
107
|
'Price List': PDFProfile('record', 'Price list overview',
|
|
108
108
|
fields=('price_list_name', 'currency', 'selling', 'buying', 'enabled'),
|
|
109
109
|
required=('price_list_name', 'currency')),
|
|
110
|
+
'Item Unit': PDFProfile('record', 'Item unit',
|
|
111
|
+
fields=('item_code', 'uom', 'conversion_factor', 'must_be_whole_number', 'enabled'),
|
|
112
|
+
required=('item_code', 'uom', 'conversion_factor')),
|
|
110
113
|
'Item Price': PDFProfile('record', 'Item price overview',
|
|
111
|
-
fields=('item_code', 'price_list', 'customer', 'supplier', 'uom', 'min_qty', 'rate', 'valid_from', 'valid_upto', 'enabled'),
|
|
114
|
+
fields=('item_code', 'price_list', 'customer', 'supplier', 'uom', 'per_qty', 'min_qty', 'rate', 'valid_from', 'valid_upto', 'enabled'),
|
|
112
115
|
required=('item_code', 'price_list', 'rate')),
|
|
113
116
|
'Bank Account': PDFProfile('record', 'Bank account overview',
|
|
114
117
|
fields=('account_name', 'company', 'account', 'iban', 'currency', 'bank_name', 'bic', 'disabled'), required=('account_name', 'company', 'account', 'iban', 'currency')),
|
|
@@ -697,6 +697,7 @@ _REFERENCES = {
|
|
|
697
697
|
"commercial": """- doc: the document (name, transaction_date or posting_date, valid_till / due_date / delivery_date, customer or supplier and their _name, currency, net_total, total_taxes_and_charges, grand_total, outstanding_amount (invoices), is_return (credit note), remarks, status, docstatus, ...)
|
|
698
698
|
<<PARTY>>- currency, meta_fields (list of {label, value})
|
|
699
699
|
- items: list of {idx, item_code, item_name, description, qty, uom, rate, amount, discount_percentage, frequency}
|
|
700
|
+
A line ordered in a further unit of the item (2 Karton of 100) is stored per stock unit: qty 200, uom Stk, rate 2.90. Then item.ordered_in_unit is true and item.order_qty (2), item.order_uom (Karton), item.conversion_factor (100) and item.order_rate (290.00, the price per ordered unit) say what was ordered. Print order_qty + order_uom and order_rate for such a line (the stock quantity may go below); item.amount is the same either way. Never print item.rate with two decimals for it: 12.99 a carton is 0.1299 a piece.
|
|
700
701
|
A line can carry a deduction (e.g. "Abzüglich bereits verrechnet"): then item.discount_total > 0 (the deduction for the whole line), item.discount_label is its text, and item.gross_rate / item.gross_amount are the full price. Print the full price on the line and a sub-line with the label and −discount_total; item.amount is the net (gross_amount − discount_total). A layout that ignores it prints only the net amount (and gets a warning).
|
|
701
702
|
- taxes: list of {description, rate, tax_amount, total}
|
|
702
703
|
<<TEXTS>>- recurring_summary: per billing period [{frequency, label, net_total, grand_total, ...}]; show_frequency: whether any line recurs
|
|
@@ -39,6 +39,7 @@ from lambda_erp.stock.reservation import StockReservation
|
|
|
39
39
|
from lambda_erp.stock.consignment import ConsignmentWithdrawal
|
|
40
40
|
from lambda_erp.stock.stock_count import StockCount
|
|
41
41
|
from lambda_erp.bundles import ItemBundle
|
|
42
|
+
from lambda_erp.units import ItemUnit
|
|
42
43
|
|
|
43
44
|
|
|
44
45
|
# --- Doctype registries ---
|
|
@@ -75,6 +76,8 @@ DOCUMENT_CLASSES = {
|
|
|
75
76
|
# Counted quantities; submitting books the differences with a reason.
|
|
76
77
|
"Stock Count": StockCount,
|
|
77
78
|
"Item Bundle": ItemBundle,
|
|
79
|
+
# A further unit of an item (carton of 100) that lines may be entered in.
|
|
80
|
+
"Item Unit": ItemUnit,
|
|
78
81
|
}
|
|
79
82
|
|
|
80
83
|
CONVERTERS = {
|
|
@@ -158,7 +158,7 @@
|
|
|
158
158
|
<td>{{ item.item_name or item.description or "" }}{% if item.item_name and item.description and item.description != item.item_name %}<br><span style="color: #555">{{ item.description }}</span>{% endif %}</td>
|
|
159
159
|
<td>{{ item.warehouse_name or item.warehouse or "" }}</td>
|
|
160
160
|
<td class="num">{{ "%g"|format(item.qty or 0) }}</td>
|
|
161
|
-
<td>{{ item.uom or "" }}</td>
|
|
161
|
+
<td>{{ item.uom or "" }}{% if item.order_uom and item.conversion_factor %}<br><span style="color: #555; font-size: 85%">= {{ "%g"|format(item.order_qty or 0) }} {{ item.order_uom }}</span>{% endif %}</td>
|
|
162
162
|
</tr>
|
|
163
163
|
{% endfor %}
|
|
164
164
|
</tbody>
|
|
@@ -154,9 +154,10 @@
|
|
|
154
154
|
<td style="font-weight: 600">{{ item.item_code or "" }}</td>
|
|
155
155
|
<td>{{ item.item_name or item.description or "" }}{% if item.frequency %}<br>{{ item.frequency }}{% endif %}</td>
|
|
156
156
|
{% if show_warehouse %}<td>{{ item.warehouse or "" }}</td>{% endif %}
|
|
157
|
-
|
|
157
|
+
{# A line ordered in a further unit prints that unit and its price; the stock quantity below. #}
|
|
158
|
+
<td class="num">{% if item.ordered_in_unit %}{{ "%g"|format(item.order_qty or 0) }} {{ item.order_uom }}<br><span style="color: #555; font-size: 85%">= {{ "%g"|format(item.qty or 0) }} {{ item.uom or "" }}</span>{% else %}{{ item.qty }}{% endif %}</td>
|
|
158
159
|
{% if item.discount_total %}
|
|
159
|
-
<td class="num">{{ "%.2f"|format(item.gross_rate) }}</td>
|
|
160
|
+
<td class="num">{{ "%.2f"|format(item.order_gross_rate if item.ordered_in_unit else item.gross_rate) }}</td>
|
|
160
161
|
<td class="num">{{ "%.2f"|format(item.gross_amount) }}</td>
|
|
161
162
|
</tr>
|
|
162
163
|
<tr class="deduction">
|
|
@@ -168,7 +169,7 @@
|
|
|
168
169
|
<td></td>
|
|
169
170
|
<td class="num">−{{ "%.2f"|format(item.discount_total) }}</td>
|
|
170
171
|
{% else %}
|
|
171
|
-
<td class="num">{{ "%.2f"|format(item.rate or 0) }}</td>
|
|
172
|
+
<td class="num">{{ "%.2f"|format(item.order_rate if item.ordered_in_unit else (item.rate or 0)) }}</td>
|
|
172
173
|
<td class="num">{{ "%.2f"|format(item.amount) }}</td>
|
|
173
174
|
{% endif %}
|
|
174
175
|
</tr>
|
|
@@ -336,7 +336,8 @@ def make_pos_return(posi_name):
|
|
|
336
336
|
item_name=item.get("item_name"),
|
|
337
337
|
description=item.get("description"),
|
|
338
338
|
qty=-flt(item.get("qty")),
|
|
339
|
-
uom=item.get("uom"),
|
|
339
|
+
uom=item.get("uom"), order_uom=item.get("order_uom"),
|
|
340
|
+
conversion_factor=item.get("conversion_factor"),
|
|
340
341
|
rate=flt(item.get("rate")),
|
|
341
342
|
income_account=item.get("income_account"),
|
|
342
343
|
cost_center=item.get("cost_center"),
|
|
@@ -469,7 +469,8 @@ def make_purchase_return(pinv_name):
|
|
|
469
469
|
item_name=item.get("item_name"),
|
|
470
470
|
description=item.get("description"),
|
|
471
471
|
qty=-flt(item.get("qty")),
|
|
472
|
-
uom=item.get("uom"),
|
|
472
|
+
uom=item.get("uom"), order_uom=item.get("order_uom"),
|
|
473
|
+
conversion_factor=item.get("conversion_factor"),
|
|
473
474
|
rate=flt(item.get("rate")),
|
|
474
475
|
expense_account=item.get("expense_account"),
|
|
475
476
|
cost_center=item.get("cost_center"),
|
|
@@ -457,7 +457,8 @@ def make_sales_return(sinv_name):
|
|
|
457
457
|
item_name=item.get("item_name"),
|
|
458
458
|
description=item.get("description"),
|
|
459
459
|
qty=-flt(item.get("qty")),
|
|
460
|
-
uom=item.get("uom"),
|
|
460
|
+
uom=item.get("uom"), order_uom=item.get("order_uom"),
|
|
461
|
+
conversion_factor=item.get("conversion_factor"),
|
|
461
462
|
rate=flt(item.get("rate")),
|
|
462
463
|
income_account=item.get("income_account"),
|
|
463
464
|
cost_center=item.get("cost_center"),
|
|
@@ -118,7 +118,8 @@ def make_purchase_invoice(purchase_order_name):
|
|
|
118
118
|
item_name=item.get("item_name"),
|
|
119
119
|
description=item.get("description"),
|
|
120
120
|
qty=unbilled,
|
|
121
|
-
uom=item.get("uom"),
|
|
121
|
+
uom=item.get("uom"), order_uom=item.get("order_uom"),
|
|
122
|
+
conversion_factor=item.get("conversion_factor"),
|
|
122
123
|
rate=item.get("rate"),
|
|
123
124
|
warehouse=item.get("warehouse"),
|
|
124
125
|
purchase_order=po.name,
|
|
@@ -28,6 +28,7 @@ import math
|
|
|
28
28
|
from lambda_erp.model import Document
|
|
29
29
|
from lambda_erp.utils import flt, getdate, nowdate
|
|
30
30
|
from lambda_erp.database import get_db
|
|
31
|
+
from lambda_erp import units
|
|
31
32
|
from lambda_erp.exceptions import ValidationError
|
|
32
33
|
|
|
33
34
|
|
|
@@ -79,6 +80,8 @@ class ItemPrice(Document):
|
|
|
79
80
|
CONDITIONAL_REQUIREMENTS = (
|
|
80
81
|
'A row without a customer/supplier is the list price for that item. A row naming a party overrides it for that party only.',
|
|
81
82
|
'min_qty sets a volume break: the highest min_qty at or below the line quantity wins.',
|
|
83
|
+
'per_qty: the rate is the price of this many units (rate 12.50, per_qty 100 = 0.125 each). Default 1. '
|
|
84
|
+
'It is not a pack size: for a carton of 100 give the item an Item Unit and set uom on the price.',
|
|
82
85
|
'A customer may only be set on a selling Price List, a supplier only on a buying one.',
|
|
83
86
|
)
|
|
84
87
|
|
|
@@ -95,6 +98,17 @@ class ItemPrice(Document):
|
|
|
95
98
|
raise ValidationError("Min Qty cannot be negative")
|
|
96
99
|
if flt(self.rate) < 0:
|
|
97
100
|
raise ValidationError("Rate cannot be negative")
|
|
101
|
+
per = self._data.get("per_qty")
|
|
102
|
+
if per in (None, ""):
|
|
103
|
+
self._data["per_qty"] = 1
|
|
104
|
+
else:
|
|
105
|
+
try:
|
|
106
|
+
per = float(per)
|
|
107
|
+
except (TypeError, ValueError):
|
|
108
|
+
raise ValidationError("Per Qty must be a number")
|
|
109
|
+
if not math.isfinite(per) or per <= 0:
|
|
110
|
+
raise ValidationError("Per Qty must be positive")
|
|
111
|
+
self._data["per_qty"] = per
|
|
98
112
|
if self.customer and self.supplier:
|
|
99
113
|
raise ValidationError("An Item Price names either a customer or a supplier, not both")
|
|
100
114
|
|
|
@@ -224,7 +238,15 @@ def find_item_price(item_code, price_list, qty=0, party_field=None, party=None,
|
|
|
224
238
|
unit_match = 1 if (uom and row.get("uom") == uom) else 0
|
|
225
239
|
return (party_match, unit_match, flt(row.get("min_qty")), *_validity_rank(row), str(row.get("name")))
|
|
226
240
|
|
|
227
|
-
|
|
241
|
+
best = dict(max(rows, key=rank))
|
|
242
|
+
# A price quoted per several units (12.50 per 100): `rate` of the row
|
|
243
|
+
# that is returned is the price of ONE unit; `quoted_rate` and `per_qty`
|
|
244
|
+
# keep what the price list says.
|
|
245
|
+
per = flt(best.get("per_qty"))
|
|
246
|
+
if per > 0 and per != 1:
|
|
247
|
+
best["quoted_rate"] = flt(best["rate"])
|
|
248
|
+
best["rate"] = flt(best["rate"]) / per
|
|
249
|
+
return best
|
|
228
250
|
|
|
229
251
|
|
|
230
252
|
def set_item_defaults(doc, party_type=None, party_field=None, *, set_description=True):
|
|
@@ -244,7 +266,9 @@ def set_item_defaults(doc, party_type=None, party_field=None, *, set_description
|
|
|
244
266
|
stamps = "price_source" in db._get_table_columns(doc.CHILD_TABLES["items"][0]) \
|
|
245
267
|
if "items" in getattr(doc, "CHILD_TABLES", {}) else False
|
|
246
268
|
|
|
247
|
-
|
|
269
|
+
unit_columns = units.has_unit_columns(doc)
|
|
270
|
+
|
|
271
|
+
for position, item in enumerate(doc.get("items") or [], 1):
|
|
248
272
|
item_code = item.get("item_code")
|
|
249
273
|
if not item_code:
|
|
250
274
|
continue
|
|
@@ -255,6 +279,15 @@ def set_item_defaults(doc, party_type=None, party_field=None, *, set_description
|
|
|
255
279
|
if not item_data:
|
|
256
280
|
continue
|
|
257
281
|
|
|
282
|
+
# A line entered in one of the item's further units (2 Karton) is
|
|
283
|
+
# converted to the stock unit here, before it is priced; see units.py.
|
|
284
|
+
factor = entered_uom = entered_qty = None
|
|
285
|
+
if unit_columns:
|
|
286
|
+
factor = units.pending_factor(item, item_data.stock_uom, f"{doc.DOCTYPE} row {position}")
|
|
287
|
+
if factor:
|
|
288
|
+
entered_uom = str(item.get("uom")).strip()
|
|
289
|
+
entered_qty = units.convert_line(item, item_data.stock_uom, factor)
|
|
290
|
+
|
|
258
291
|
if not item.get("item_name"):
|
|
259
292
|
item["item_name"] = item_data.item_name
|
|
260
293
|
if set_description:
|
|
@@ -262,13 +295,27 @@ def set_item_defaults(doc, party_type=None, party_field=None, *, set_description
|
|
|
262
295
|
item["uom"] = item.get("uom") or item_data.stock_uom
|
|
263
296
|
|
|
264
297
|
if item.get("rate") is None and item.get("price_list_rate") is None:
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
298
|
+
# A price quoted for the entered unit (290.00 per Karton) comes
|
|
299
|
+
# first and is taken per stock unit; else the price per stock
|
|
300
|
+
# unit, with volume breaks counted in stock units.
|
|
301
|
+
row = unit_row = None
|
|
302
|
+
if factor:
|
|
303
|
+
unit_row = find_item_price(
|
|
304
|
+
item_code, price_list, qty=entered_qty,
|
|
305
|
+
party_field=party_field, party=party, uom=entered_uom, date=date)
|
|
306
|
+
if unit_row is not None and unit_row.get("uom") != entered_uom:
|
|
307
|
+
unit_row = None
|
|
308
|
+
row = unit_row
|
|
309
|
+
if row is None:
|
|
310
|
+
row = find_item_price(
|
|
311
|
+
item_code, price_list,
|
|
312
|
+
qty=flt(item.get("qty", 0)),
|
|
313
|
+
party_field=party_field, party=party,
|
|
314
|
+
uom=item.get("uom") or item_data.stock_uom,
|
|
315
|
+
date=date,
|
|
316
|
+
)
|
|
317
|
+
if unit_row is not None:
|
|
318
|
+
row["rate"] = flt(row["rate"]) / factor
|
|
272
319
|
# Where the base price came from is kept on the line
|
|
273
320
|
# (price_source / price_reference), see price_resolution.py.
|
|
274
321
|
if row is None:
|
|
@@ -282,3 +329,6 @@ def set_item_defaults(doc, party_type=None, party_field=None, *, set_description
|
|
|
282
329
|
item["price_source"], item["price_reference"] = source, reference
|
|
283
330
|
from lambda_erp.controllers import price_resolution
|
|
284
331
|
price_resolution.trace_base(item, source, reference, price_list, row)
|
|
332
|
+
|
|
333
|
+
if unit_columns:
|
|
334
|
+
units.stamp_order_qty(item)
|
|
@@ -31,7 +31,7 @@ informational: nothing is posted, owed or paid from them.
|
|
|
31
31
|
|
|
32
32
|
import json
|
|
33
33
|
from decimal import Decimal
|
|
34
|
-
from lambda_erp.utils import flt, cint, _dict, dec, money
|
|
34
|
+
from lambda_erp.utils import flt, cint, _dict, dec, money, round_half_up
|
|
35
35
|
from lambda_erp.exceptions import ValidationError
|
|
36
36
|
|
|
37
37
|
HUNDRED = Decimal(100)
|
|
@@ -80,6 +80,16 @@ class TaxCalculator:
|
|
|
80
80
|
conversion_rate = dec(self.doc.get("conversion_rate") or 1.0)
|
|
81
81
|
|
|
82
82
|
for item in self.doc.get("items"):
|
|
83
|
+
# A line ordered in a further unit (units.py) carries its price
|
|
84
|
+
# per stock unit: 12.99 per carton of 100 is 0.1299 a piece.
|
|
85
|
+
# Rounding that to the cent would move the line amount, so the
|
|
86
|
+
# unit rate keeps six places there; amounts round as always.
|
|
87
|
+
places = 6 if flt(item.get("conversion_factor")) not in (0.0, 1.0) else 2
|
|
88
|
+
# The same holds for a list price finer than a cent (12.50 per
|
|
89
|
+
# 100 is 0.125 each): a discount on it is not rounded to the cent.
|
|
90
|
+
list_price = item.get("price_list_rate")
|
|
91
|
+
if places == 2 and list_price not in (None, "") and dec(list_price) != round_half_up(list_price, 2):
|
|
92
|
+
places = 6
|
|
83
93
|
# Apply discount to get rate from price_list_rate
|
|
84
94
|
if item.get('rate') is not None and flt(item['rate']) == 0:
|
|
85
95
|
item['rate'] = 0.0
|
|
@@ -88,14 +98,14 @@ class TaxCalculator:
|
|
|
88
98
|
elif item.get("price_list_rate") is not None and (flt(item['price_list_rate']) != 0 or item.get('rate') is None):
|
|
89
99
|
list_rate, percent = dec(item["price_list_rate"]), dec(item.get("discount_percentage"))
|
|
90
100
|
if item.get("rate") is None or percent > 0:
|
|
91
|
-
item["rate"] = money(list_rate * (1 - percent / HUNDRED))
|
|
92
|
-
item["discount_amount"] = money(list_rate * percent / HUNDRED)
|
|
101
|
+
item["rate"] = money(list_rate * (1 - percent / HUNDRED), places)
|
|
102
|
+
item["discount_amount"] = money(list_rate * percent / HUNDRED, places)
|
|
93
103
|
elif item.get("discount_amount"):
|
|
94
104
|
item["rate"] = float(list_rate - dec(item["discount_amount"]))
|
|
95
105
|
|
|
96
106
|
rate = dec(item.get("rate"))
|
|
97
107
|
# Set net_rate = rate (before inclusive tax adjustment)
|
|
98
|
-
item["net_rate"] = money(rate)
|
|
108
|
+
item["net_rate"] = money(rate, places)
|
|
99
109
|
|
|
100
110
|
# Calculate amount: the decimal product, rounded once
|
|
101
111
|
item["amount"] = money(rate * dec(item.get("qty", 0)))
|
|
@@ -3661,6 +3661,51 @@ def _m064_item_bundles(db: "Database") -> None:
|
|
|
3661
3661
|
db.ensure_column(table, "bundle_qty", "REAL")
|
|
3662
3662
|
|
|
3663
3663
|
|
|
3664
|
+
def _m067_item_units(db: "Database") -> None:
|
|
3665
|
+
"""Units of measure (see docs/units.md): further units per item with a
|
|
3666
|
+
conversion factor, and on every item line what it was ordered as. No
|
|
3667
|
+
existing line changes: without `order_uom` a line is in the stock unit,
|
|
3668
|
+
as all lines were."""
|
|
3669
|
+
db.conn.execute(db._ddl(
|
|
3670
|
+
"""CREATE TABLE IF NOT EXISTS "Item Unit" (
|
|
3671
|
+
name TEXT PRIMARY KEY,
|
|
3672
|
+
item_code TEXT NOT NULL,
|
|
3673
|
+
uom TEXT NOT NULL,
|
|
3674
|
+
conversion_factor REAL DEFAULT 1,
|
|
3675
|
+
enabled INTEGER DEFAULT 1,
|
|
3676
|
+
docstatus INTEGER DEFAULT 0,
|
|
3677
|
+
discarded INTEGER DEFAULT 0,
|
|
3678
|
+
creation TEXT,
|
|
3679
|
+
modified TEXT
|
|
3680
|
+
)"""))
|
|
3681
|
+
db.conn.execute(db._ddl('CREATE INDEX IF NOT EXISTS "ix_item_unit_item_code" ON "Item Unit" (item_code)'))
|
|
3682
|
+
db.conn.commit()
|
|
3683
|
+
db._col_cache.pop("Item Unit", None)
|
|
3684
|
+
db._text_col_cache.pop("Item Unit", None)
|
|
3685
|
+
for table in ("Quotation Item", "Sales Order Item", "Purchase Order Item", "Sales Invoice Item",
|
|
3686
|
+
"Purchase Invoice Item", "Delivery Note Item", "Purchase Receipt Item", "POS Invoice Item",
|
|
3687
|
+
"Stock Entry Detail"):
|
|
3688
|
+
db.ensure_column(table, "order_uom", "TEXT")
|
|
3689
|
+
db.ensure_column(table, "conversion_factor", "REAL")
|
|
3690
|
+
db.ensure_column(table, "order_qty", "REAL")
|
|
3691
|
+
|
|
3692
|
+
|
|
3693
|
+
def _m068_units_completed(db: "Database") -> None:
|
|
3694
|
+
"""Units of measure, the rest (see docs/units.md): consignment
|
|
3695
|
+
withdrawals and stock counts can be entered in a further unit, a unit can
|
|
3696
|
+
require whole quantities, and an Item Price can be quoted per several
|
|
3697
|
+
units. Existing rows keep their meaning: per_qty 1, no whole-number rule."""
|
|
3698
|
+
db.ensure_column("Item Unit", "must_be_whole_number", "INTEGER DEFAULT 0")
|
|
3699
|
+
db.ensure_column("Item Price", "per_qty", "REAL DEFAULT 1")
|
|
3700
|
+
for table in ("Consignment Withdrawal Item", "Stock Count Item"):
|
|
3701
|
+
if not db._get_table_columns(table):
|
|
3702
|
+
continue
|
|
3703
|
+
db.ensure_column(table, "uom", "TEXT")
|
|
3704
|
+
db.ensure_column(table, "order_uom", "TEXT")
|
|
3705
|
+
db.ensure_column(table, "conversion_factor", "REAL")
|
|
3706
|
+
db.ensure_column(table, "order_qty", "REAL")
|
|
3707
|
+
|
|
3708
|
+
|
|
3664
3709
|
def _m065_record_attachments(db: "Database") -> None:
|
|
3665
3710
|
"""Files kept with a document or master record, and a tracking reference
|
|
3666
3711
|
on delivery notes (see docs/attachments.md)."""
|
|
@@ -3801,6 +3846,8 @@ Database.MIGRATIONS = [
|
|
|
3801
3846
|
(64, "item_bundles", _m064_item_bundles),
|
|
3802
3847
|
(65, "record_attachments", _m065_record_attachments),
|
|
3803
3848
|
(66, "attachment_sensitivity", _m066_attachment_sensitivity),
|
|
3849
|
+
(67, "item_units", _m067_item_units),
|
|
3850
|
+
(68, "units_completed", _m068_units_completed),
|
|
3804
3851
|
]
|
|
3805
3852
|
|
|
3806
3853
|
|
|
@@ -307,6 +307,7 @@ def _core_record_scopes():
|
|
|
307
307
|
register_record_scope("Address", "warehouse", unrelated=True)
|
|
308
308
|
for dimension in ("customer", "warehouse"):
|
|
309
309
|
register_record_scope("Item Bundle", dimension, unrelated=True)
|
|
310
|
+
register_record_scope("Item Unit", dimension, unrelated=True)
|
|
310
311
|
for doctype in ("Payment Entry", "Subscription", "Reservation"):
|
|
311
312
|
register_record_scope(doctype, "customer", "party", when=("party_type", "Customer"))
|
|
312
313
|
register_record_scope("Journal Entry", "customer", child="accounts", child_table="Journal Entry Account",
|
|
@@ -981,9 +982,28 @@ def restore_hidden_values(doctype, stored_rows, new_rows, child):
|
|
|
981
982
|
for field in fields:
|
|
982
983
|
if field in stored:
|
|
983
984
|
row[field] = stored[field]
|
|
985
|
+
_keep_restored_per_stock_unit(row, stored, fields)
|
|
984
986
|
return fresh
|
|
985
987
|
|
|
986
988
|
|
|
989
|
+
def _keep_restored_per_stock_unit(row, stored, fields):
|
|
990
|
+
"""A stored line's hidden rate is per stock unit. If the user re-enters the
|
|
991
|
+
line in a further unit of the item (uom "Karton"), saving divides every
|
|
992
|
+
rate on the line by the unit's factor (units.py), which would divide the
|
|
993
|
+
restored rate a second time. The restored values are therefore put back
|
|
994
|
+
per the entered unit, so the conversion ends at the stored price."""
|
|
995
|
+
from lambda_erp import units
|
|
996
|
+
entered = str(row.get("uom") or "").strip()
|
|
997
|
+
if not entered or entered == str(stored.get("uom") or "").strip():
|
|
998
|
+
return
|
|
999
|
+
factor = units.conversion_factor(row.get("item_code"), entered)
|
|
1000
|
+
if not factor:
|
|
1001
|
+
return
|
|
1002
|
+
for field in units.RATE_FIELDS + ("basic_rate", "valuation_rate"):
|
|
1003
|
+
if field in fields and row.get(field) not in (None, ""):
|
|
1004
|
+
row[field] = float(row[field]) * factor
|
|
1005
|
+
|
|
1006
|
+
|
|
987
1007
|
def require_hidden_complete(doctype, doc, fresh=None):
|
|
988
1008
|
"""After the server has validated a document written by a restricted
|
|
989
1009
|
user: a new line that needs a hidden value must have got one. `fresh` is
|
|
@@ -188,7 +188,8 @@ def make_sales_order(quotation_name):
|
|
|
188
188
|
item_name=item.get("item_name"),
|
|
189
189
|
description=item.get("description"),
|
|
190
190
|
qty=item.get("qty"),
|
|
191
|
-
uom=item.get("uom"),
|
|
191
|
+
uom=item.get("uom"), order_uom=item.get("order_uom"),
|
|
192
|
+
conversion_factor=item.get("conversion_factor"),
|
|
192
193
|
rate=item.get("rate"),
|
|
193
194
|
price_list_rate=item.get("price_list_rate"),
|
|
194
195
|
discount_percentage=item.get("discount_percentage"),
|
|
@@ -244,7 +245,8 @@ def make_sales_invoice_from_quotation(quotation_name):
|
|
|
244
245
|
item_name=item.get("item_name"),
|
|
245
246
|
description=item.get("description"),
|
|
246
247
|
qty=item.get("qty"),
|
|
247
|
-
uom=item.get("uom"),
|
|
248
|
+
uom=item.get("uom"), order_uom=item.get("order_uom"),
|
|
249
|
+
conversion_factor=item.get("conversion_factor"),
|
|
248
250
|
rate=item.get("rate"),
|
|
249
251
|
price_list_rate=item.get("price_list_rate"),
|
|
250
252
|
discount_percentage=item.get("discount_percentage"),
|
|
@@ -295,7 +297,8 @@ def make_delivery_note_from_quotation(quotation_name):
|
|
|
295
297
|
item_name=item.get("item_name"),
|
|
296
298
|
description=item.get("description"),
|
|
297
299
|
qty=item.get("qty"),
|
|
298
|
-
uom=item.get("uom"),
|
|
300
|
+
uom=item.get("uom"), order_uom=item.get("order_uom"),
|
|
301
|
+
conversion_factor=item.get("conversion_factor"),
|
|
299
302
|
rate=item.get("rate"),
|
|
300
303
|
warehouse=item.get("warehouse"),
|
|
301
304
|
))
|
|
@@ -160,7 +160,8 @@ def make_sales_invoice(sales_order_name):
|
|
|
160
160
|
item_name=item.get("item_name"),
|
|
161
161
|
description=item.get("description"),
|
|
162
162
|
qty=unbilled_qty,
|
|
163
|
-
uom=item.get("uom"),
|
|
163
|
+
uom=item.get("uom"), order_uom=item.get("order_uom"),
|
|
164
|
+
conversion_factor=item.get("conversion_factor"),
|
|
164
165
|
rate=item.get("rate"),
|
|
165
166
|
price_list_rate=item.get("price_list_rate"),
|
|
166
167
|
discount_percentage=item.get("discount_percentage"),
|
|
@@ -60,11 +60,16 @@ def _serials(value):
|
|
|
60
60
|
def content_hash(warehouse, items, replenish=False):
|
|
61
61
|
"""What a withdrawal report says, reduced to what matters: the same
|
|
62
62
|
report gives the same hash whatever the order of its lines."""
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
63
|
+
# In stock units: a report of "1 Karton" and the stored line of 100 pieces
|
|
64
|
+
# are the same report (units.py).
|
|
65
|
+
from lambda_erp import units
|
|
66
|
+
|
|
67
|
+
def line(row):
|
|
68
|
+
qty, rate = units.in_stock_units(row)
|
|
69
|
+
return (str(row.get("item_code") or ""), str(row.get("batch_no") or ""), str(row.get("location") or ""),
|
|
70
|
+
round(qty, 6), None if rate is None else round(rate, 6), sorted(_serials(row.get("serial_no"))))
|
|
71
|
+
|
|
72
|
+
lines = sorted(line(row) for row in items or [])
|
|
68
73
|
payload = json.dumps({"warehouse": warehouse, "lines": lines, "replenish": bool(flt(replenish))},
|
|
69
74
|
sort_keys=True, default=str)
|
|
70
75
|
return hashlib.sha256(payload.encode()).hexdigest()
|
|
@@ -114,6 +119,10 @@ class ConsignmentWithdrawal(Document):
|
|
|
114
119
|
self.posting_date = nowdate()
|
|
115
120
|
if not self.get("items"):
|
|
116
121
|
raise ValidationError("At least one item is required")
|
|
122
|
+
# Reported by the carton: rows in a further unit of the item become
|
|
123
|
+
# stock units before anything reads the quantity (units.py).
|
|
124
|
+
from lambda_erp import units
|
|
125
|
+
units.apply_units(self, rate_fields=("rate",))
|
|
117
126
|
for idx, row in enumerate(self.get("items"), 1):
|
|
118
127
|
if not row.get("item_code"):
|
|
119
128
|
raise ValidationError(f"Consignment Withdrawal row {idx}: Item Code is required")
|
|
@@ -179,7 +188,9 @@ class ConsignmentWithdrawal(Document):
|
|
|
179
188
|
for row in self.get("items"):
|
|
180
189
|
line = _dict(item_code=row["item_code"], qty=flt(row["qty"]), warehouse=self.warehouse,
|
|
181
190
|
batch_no=row.get("batch_no") or None, location=row.get("location") or None,
|
|
182
|
-
serial_no=row.get("serial_no") or None
|
|
191
|
+
serial_no=row.get("serial_no") or None,
|
|
192
|
+
order_uom=row.get("order_uom") or None,
|
|
193
|
+
conversion_factor=row.get("conversion_factor") or None)
|
|
183
194
|
if row.get("rate") is not None:
|
|
184
195
|
line["rate"] = flt(row["rate"])
|
|
185
196
|
invoice.append("items", line)
|
|
@@ -188,7 +188,8 @@ def make_delivery_note(sales_order_name):
|
|
|
188
188
|
item_name=item.get("item_name"),
|
|
189
189
|
description=item.get("description"),
|
|
190
190
|
qty=pick["qty"],
|
|
191
|
-
uom=item.get("uom"),
|
|
191
|
+
uom=item.get("uom"), order_uom=item.get("order_uom"),
|
|
192
|
+
conversion_factor=item.get("conversion_factor"),
|
|
192
193
|
rate=item.get("rate"),
|
|
193
194
|
warehouse=item.get("warehouse"),
|
|
194
195
|
batch_no=pick.get("batch_no"),
|
|
@@ -237,7 +238,8 @@ def make_delivery_return(dn_name):
|
|
|
237
238
|
item_name=item.get("item_name"),
|
|
238
239
|
description=item.get("description"),
|
|
239
240
|
qty=-flt(item.get("qty")),
|
|
240
|
-
uom=item.get("uom"),
|
|
241
|
+
uom=item.get("uom"), order_uom=item.get("order_uom"),
|
|
242
|
+
conversion_factor=item.get("conversion_factor"),
|
|
241
243
|
rate=flt(item.get("rate")),
|
|
242
244
|
warehouse=item.get("warehouse"),
|
|
243
245
|
batch_no=item.get("batch_no"),
|
|
@@ -284,7 +286,8 @@ def make_sales_invoice_from_delivery_note(dn_name):
|
|
|
284
286
|
item_name=item.get("item_name"),
|
|
285
287
|
description=item.get("description"),
|
|
286
288
|
qty=unbilled,
|
|
287
|
-
uom=item.get("uom"),
|
|
289
|
+
uom=item.get("uom"), order_uom=item.get("order_uom"),
|
|
290
|
+
conversion_factor=item.get("conversion_factor"),
|
|
288
291
|
rate=item.get("rate"),
|
|
289
292
|
price_list_rate=item.get("price_list_rate"),
|
|
290
293
|
discount_percentage=item.get("discount_percentage"),
|
|
@@ -263,7 +263,8 @@ def make_purchase_receipt(purchase_order_name):
|
|
|
263
263
|
item_name=item.get("item_name"),
|
|
264
264
|
description=item.get("description"),
|
|
265
265
|
qty=unreceived,
|
|
266
|
-
uom=item.get("uom"),
|
|
266
|
+
uom=item.get("uom"), order_uom=item.get("order_uom"),
|
|
267
|
+
conversion_factor=item.get("conversion_factor"),
|
|
267
268
|
rate=item.get("rate"),
|
|
268
269
|
warehouse=item.get("warehouse"),
|
|
269
270
|
against_purchase_order=po.name,
|
|
@@ -309,7 +310,8 @@ def make_purchase_receipt_return(prec_name):
|
|
|
309
310
|
item_name=item.get("item_name"),
|
|
310
311
|
description=item.get("description"),
|
|
311
312
|
qty=-flt(item.get("qty")),
|
|
312
|
-
uom=item.get("uom"),
|
|
313
|
+
uom=item.get("uom"), order_uom=item.get("order_uom"),
|
|
314
|
+
conversion_factor=item.get("conversion_factor"),
|
|
313
315
|
rate=flt(item.get("rate")),
|
|
314
316
|
warehouse=item.get("warehouse"),
|
|
315
317
|
batch_no=item.get("batch_no"),
|
|
@@ -356,7 +358,8 @@ def make_purchase_invoice_from_purchase_receipt(receipt_name):
|
|
|
356
358
|
item_name=item.get("item_name"),
|
|
357
359
|
description=item.get("description"),
|
|
358
360
|
qty=unbilled,
|
|
359
|
-
uom=item.get("uom"),
|
|
361
|
+
uom=item.get("uom"), order_uom=item.get("order_uom"),
|
|
362
|
+
conversion_factor=item.get("conversion_factor"),
|
|
360
363
|
rate=item.get("rate"),
|
|
361
364
|
price_list_rate=item.get("price_list_rate"),
|
|
362
365
|
discount_percentage=item.get("discount_percentage"),
|