lambda-erp 1.4.32__tar.gz → 1.4.34__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.32 → lambda_erp-1.4.34}/PKG-INFO +1 -1
- {lambda_erp-1.4.32 → lambda_erp-1.4.34}/api/chat.py +2 -0
- {lambda_erp-1.4.32 → lambda_erp-1.4.34}/api/order_actions.py +23 -0
- {lambda_erp-1.4.32 → lambda_erp-1.4.34}/api/pdf.py +3 -0
- {lambda_erp-1.4.32 → lambda_erp-1.4.34}/api/pdf_templates.py +2 -0
- {lambda_erp-1.4.32 → lambda_erp-1.4.34}/api/templates/delivery_note.html +1 -0
- {lambda_erp-1.4.32 → lambda_erp-1.4.34}/api/templates/document.html +1 -0
- {lambda_erp-1.4.32 → lambda_erp-1.4.34}/lambda_erp/addresses.py +79 -0
- {lambda_erp-1.4.32 → lambda_erp-1.4.34}/lambda_erp/controllers/item_price.py +45 -0
- {lambda_erp-1.4.32 → lambda_erp-1.4.34}/lambda_erp/controllers/taxes_and_totals.py +9 -1
- {lambda_erp-1.4.32 → lambda_erp-1.4.34}/lambda_erp/database.py +11 -0
- {lambda_erp-1.4.32 → lambda_erp-1.4.34}/pyproject.toml +1 -1
- {lambda_erp-1.4.32 → lambda_erp-1.4.34}/.gitignore +0 -0
- {lambda_erp-1.4.32 → lambda_erp-1.4.34}/LICENSE +0 -0
- {lambda_erp-1.4.32 → lambda_erp-1.4.34}/README.md +0 -0
- {lambda_erp-1.4.32 → lambda_erp-1.4.34}/api/__init__.py +0 -0
- {lambda_erp-1.4.32 → lambda_erp-1.4.34}/api/attachments.py +0 -0
- {lambda_erp-1.4.32 → lambda_erp-1.4.34}/api/auth.py +0 -0
- {lambda_erp-1.4.32 → lambda_erp-1.4.34}/api/bootstrap.py +0 -0
- {lambda_erp-1.4.32 → lambda_erp-1.4.34}/api/chat_links.py +0 -0
- {lambda_erp-1.4.32 → lambda_erp-1.4.34}/api/demo_limits.py +0 -0
- {lambda_erp-1.4.32 → lambda_erp-1.4.34}/api/deps.py +0 -0
- {lambda_erp-1.4.32 → lambda_erp-1.4.34}/api/erp_context.py +0 -0
- {lambda_erp-1.4.32 → lambda_erp-1.4.34}/api/errors.py +0 -0
- {lambda_erp-1.4.32 → lambda_erp-1.4.34}/api/list_columns.py +0 -0
- {lambda_erp-1.4.32 → lambda_erp-1.4.34}/api/list_values.py +0 -0
- {lambda_erp-1.4.32 → lambda_erp-1.4.34}/api/llm_provider.py +0 -0
- {lambda_erp-1.4.32 → lambda_erp-1.4.34}/api/mail.py +0 -0
- {lambda_erp-1.4.32 → lambda_erp-1.4.34}/api/main.py +0 -0
- {lambda_erp-1.4.32 → lambda_erp-1.4.34}/api/mcp_oauth.py +0 -0
- {lambda_erp-1.4.32 → lambda_erp-1.4.34}/api/mentions.py +0 -0
- {lambda_erp-1.4.32 → lambda_erp-1.4.34}/api/menu_layout.py +0 -0
- {lambda_erp-1.4.32 → lambda_erp-1.4.34}/api/number_series.py +0 -0
- {lambda_erp-1.4.32 → lambda_erp-1.4.34}/api/oauth.py +0 -0
- {lambda_erp-1.4.32 → lambda_erp-1.4.34}/api/pdf_contract.py +0 -0
- {lambda_erp-1.4.32 → lambda_erp-1.4.34}/api/pdf_exports.py +0 -0
- {lambda_erp-1.4.32 → lambda_erp-1.4.34}/api/pdf_fonts.py +0 -0
- {lambda_erp-1.4.32 → lambda_erp-1.4.34}/api/pdf_pages.py +0 -0
- {lambda_erp-1.4.32 → lambda_erp-1.4.34}/api/pdf_profiles.py +0 -0
- {lambda_erp-1.4.32 → lambda_erp-1.4.34}/api/pricing_actions.py +0 -0
- {lambda_erp-1.4.32 → lambda_erp-1.4.34}/api/providers.py +0 -0
- {lambda_erp-1.4.32 → lambda_erp-1.4.34}/api/record_attachments.py +0 -0
- {lambda_erp-1.4.32 → lambda_erp-1.4.34}/api/record_notes.py +0 -0
- {lambda_erp-1.4.32 → lambda_erp-1.4.34}/api/remarks_md.py +0 -0
- {lambda_erp-1.4.32 → lambda_erp-1.4.34}/api/routers/__init__.py +0 -0
- {lambda_erp-1.4.32 → lambda_erp-1.4.34}/api/routers/accounting.py +0 -0
- {lambda_erp-1.4.32 → lambda_erp-1.4.34}/api/routers/actions.py +0 -0
- {lambda_erp-1.4.32 → lambda_erp-1.4.34}/api/routers/admin.py +0 -0
- {lambda_erp-1.4.32 → lambda_erp-1.4.34}/api/routers/analytics.py +0 -0
- {lambda_erp-1.4.32 → lambda_erp-1.4.34}/api/routers/availability.py +0 -0
- {lambda_erp-1.4.32 → lambda_erp-1.4.34}/api/routers/bank_reconciliation.py +0 -0
- {lambda_erp-1.4.32 → lambda_erp-1.4.34}/api/routers/bank_statements.py +0 -0
- {lambda_erp-1.4.32 → lambda_erp-1.4.34}/api/routers/chat_api.py +0 -0
- {lambda_erp-1.4.32 → lambda_erp-1.4.34}/api/routers/documents.py +0 -0
- {lambda_erp-1.4.32 → lambda_erp-1.4.34}/api/routers/masters.py +0 -0
- {lambda_erp-1.4.32 → lambda_erp-1.4.34}/api/routers/mcp.py +0 -0
- {lambda_erp-1.4.32 → lambda_erp-1.4.34}/api/routers/pdf_templates.py +0 -0
- {lambda_erp-1.4.32 → lambda_erp-1.4.34}/api/routers/proposals.py +0 -0
- {lambda_erp-1.4.32 → lambda_erp-1.4.34}/api/routers/reports.py +0 -0
- {lambda_erp-1.4.32 → lambda_erp-1.4.34}/api/routers/setup.py +0 -0
- {lambda_erp-1.4.32 → lambda_erp-1.4.34}/api/services.py +0 -0
- {lambda_erp-1.4.32 → lambda_erp-1.4.34}/api/stock_actions.py +0 -0
- {lambda_erp-1.4.32 → lambda_erp-1.4.34}/api/templates/_proposal_totals.html +0 -0
- {lambda_erp-1.4.32 → lambda_erp-1.4.34}/api/templates/_record_base.html +0 -0
- {lambda_erp-1.4.32 → lambda_erp-1.4.34}/api/templates/proposal.html +0 -0
- {lambda_erp-1.4.32 → lambda_erp-1.4.34}/api/templates/record.html +0 -0
- {lambda_erp-1.4.32 → lambda_erp-1.4.34}/api/templates/reservation.html +0 -0
- {lambda_erp-1.4.32 → lambda_erp-1.4.34}/api/time_filters.py +0 -0
- {lambda_erp-1.4.32 → lambda_erp-1.4.34}/api/tool_permissions.py +0 -0
- {lambda_erp-1.4.32 → lambda_erp-1.4.34}/api/tool_results.py +0 -0
- {lambda_erp-1.4.32 → lambda_erp-1.4.34}/api/write_context.py +0 -0
- {lambda_erp-1.4.32 → lambda_erp-1.4.34}/docs/agents/README.md +0 -0
- {lambda_erp-1.4.32 → lambda_erp-1.4.34}/frontend/LICENSE +0 -0
- {lambda_erp-1.4.32 → lambda_erp-1.4.34}/frontend/README.md +0 -0
- {lambda_erp-1.4.32 → lambda_erp-1.4.34}/frontend/src/api/client.ts +0 -0
- {lambda_erp-1.4.32 → lambda_erp-1.4.34}/lambda_erp/__init__.py +0 -0
- {lambda_erp-1.4.32 → lambda_erp-1.4.34}/lambda_erp/accounting/__init__.py +0 -0
- {lambda_erp-1.4.32 → lambda_erp-1.4.34}/lambda_erp/accounting/bank_account.py +0 -0
- {lambda_erp-1.4.32 → lambda_erp-1.4.34}/lambda_erp/accounting/bank_reconciliation.py +0 -0
- {lambda_erp-1.4.32 → lambda_erp-1.4.34}/lambda_erp/accounting/bank_statement_import.py +0 -0
- {lambda_erp-1.4.32 → lambda_erp-1.4.34}/lambda_erp/accounting/bank_transaction.py +0 -0
- {lambda_erp-1.4.32 → lambda_erp-1.4.34}/lambda_erp/accounting/budget.py +0 -0
- {lambda_erp-1.4.32 → lambda_erp-1.4.34}/lambda_erp/accounting/camt.py +0 -0
- {lambda_erp-1.4.32 → lambda_erp-1.4.34}/lambda_erp/accounting/chart_of_accounts.py +0 -0
- {lambda_erp-1.4.32 → lambda_erp-1.4.34}/lambda_erp/accounting/general_ledger.py +0 -0
- {lambda_erp-1.4.32 → lambda_erp-1.4.34}/lambda_erp/accounting/journal_entry.py +0 -0
- {lambda_erp-1.4.32 → lambda_erp-1.4.34}/lambda_erp/accounting/payment_entry.py +0 -0
- {lambda_erp-1.4.32 → lambda_erp-1.4.34}/lambda_erp/accounting/pos_invoice.py +0 -0
- {lambda_erp-1.4.32 → lambda_erp-1.4.34}/lambda_erp/accounting/purchase_invoice.py +0 -0
- {lambda_erp-1.4.32 → lambda_erp-1.4.34}/lambda_erp/accounting/revaluation.py +0 -0
- {lambda_erp-1.4.32 → lambda_erp-1.4.34}/lambda_erp/accounting/sales_invoice.py +0 -0
- {lambda_erp-1.4.32 → lambda_erp-1.4.34}/lambda_erp/accounting/settlement.py +0 -0
- {lambda_erp-1.4.32 → lambda_erp-1.4.34}/lambda_erp/accounting/setup/__init__.py +0 -0
- {lambda_erp-1.4.32 → lambda_erp-1.4.34}/lambda_erp/accounting/setup/engine.py +0 -0
- {lambda_erp-1.4.32 → lambda_erp-1.4.34}/lambda_erp/accounting/setup/pack.py +0 -0
- {lambda_erp-1.4.32 → lambda_erp-1.4.34}/lambda_erp/accounting/setup/packs/__init__.py +0 -0
- {lambda_erp-1.4.32 → lambda_erp-1.4.34}/lambda_erp/accounting/setup/packs/ch.py +0 -0
- {lambda_erp-1.4.32 → lambda_erp-1.4.34}/lambda_erp/accounting/setup/packs/de_common.py +0 -0
- {lambda_erp-1.4.32 → lambda_erp-1.4.34}/lambda_erp/accounting/setup/packs/de_skr03.py +0 -0
- {lambda_erp-1.4.32 → lambda_erp-1.4.34}/lambda_erp/accounting/setup/packs/de_skr04.py +0 -0
- {lambda_erp-1.4.32 → lambda_erp-1.4.34}/lambda_erp/accounting/setup/packs/generic.py +0 -0
- {lambda_erp-1.4.32 → lambda_erp-1.4.34}/lambda_erp/accounting/setup/profiles.py +0 -0
- {lambda_erp-1.4.32 → lambda_erp-1.4.34}/lambda_erp/accounting/setup/spine.py +0 -0
- {lambda_erp-1.4.32 → lambda_erp-1.4.34}/lambda_erp/accounting/subscription.py +0 -0
- {lambda_erp-1.4.32 → lambda_erp-1.4.34}/lambda_erp/assets/__init__.py +0 -0
- {lambda_erp-1.4.32 → lambda_erp-1.4.34}/lambda_erp/assets/asset.py +0 -0
- {lambda_erp-1.4.32 → lambda_erp-1.4.34}/lambda_erp/assets/lifecycle.py +0 -0
- {lambda_erp-1.4.32 → lambda_erp-1.4.34}/lambda_erp/assets/reservation.py +0 -0
- {lambda_erp-1.4.32 → lambda_erp-1.4.34}/lambda_erp/backlog.py +0 -0
- {lambda_erp-1.4.32 → lambda_erp-1.4.34}/lambda_erp/bundles.py +0 -0
- {lambda_erp-1.4.32 → lambda_erp-1.4.34}/lambda_erp/buying/__init__.py +0 -0
- {lambda_erp-1.4.32 → lambda_erp-1.4.34}/lambda_erp/buying/purchase_order.py +0 -0
- {lambda_erp-1.4.32 → lambda_erp-1.4.34}/lambda_erp/controllers/__init__.py +0 -0
- {lambda_erp-1.4.32 → lambda_erp-1.4.34}/lambda_erp/controllers/currency.py +0 -0
- {lambda_erp-1.4.32 → lambda_erp-1.4.34}/lambda_erp/controllers/defaults.py +0 -0
- {lambda_erp-1.4.32 → lambda_erp-1.4.34}/lambda_erp/controllers/item_prices.py +0 -0
- {lambda_erp-1.4.32 → lambda_erp-1.4.34}/lambda_erp/controllers/price_resolution.py +0 -0
- {lambda_erp-1.4.32 → lambda_erp-1.4.34}/lambda_erp/controllers/pricing_rule.py +0 -0
- {lambda_erp-1.4.32 → lambda_erp-1.4.34}/lambda_erp/controllers/tax_defaults.py +0 -0
- {lambda_erp-1.4.32 → lambda_erp-1.4.34}/lambda_erp/customer_terms.py +0 -0
- {lambda_erp-1.4.32 → lambda_erp-1.4.34}/lambda_erp/exceptions.py +0 -0
- {lambda_erp-1.4.32 → lambda_erp-1.4.34}/lambda_erp/hooks.py +0 -0
- {lambda_erp-1.4.32 → lambda_erp-1.4.34}/lambda_erp/master_integrity.py +0 -0
- {lambda_erp-1.4.32 → lambda_erp-1.4.34}/lambda_erp/model.py +0 -0
- {lambda_erp-1.4.32 → lambda_erp-1.4.34}/lambda_erp/order_closing.py +0 -0
- {lambda_erp-1.4.32 → lambda_erp-1.4.34}/lambda_erp/permissions.py +0 -0
- {lambda_erp-1.4.32 → lambda_erp-1.4.34}/lambda_erp/selling/__init__.py +0 -0
- {lambda_erp-1.4.32 → lambda_erp-1.4.34}/lambda_erp/selling/proposal.py +0 -0
- {lambda_erp-1.4.32 → lambda_erp-1.4.34}/lambda_erp/selling/quotation.py +0 -0
- {lambda_erp-1.4.32 → lambda_erp-1.4.34}/lambda_erp/selling/sales_order.py +0 -0
- {lambda_erp-1.4.32 → lambda_erp-1.4.34}/lambda_erp/simulation.py +0 -0
- {lambda_erp-1.4.32 → lambda_erp-1.4.34}/lambda_erp/stock/__init__.py +0 -0
- {lambda_erp-1.4.32 → lambda_erp-1.4.34}/lambda_erp/stock/consignment.py +0 -0
- {lambda_erp-1.4.32 → lambda_erp-1.4.34}/lambda_erp/stock/delivery_note.py +0 -0
- {lambda_erp-1.4.32 → lambda_erp-1.4.34}/lambda_erp/stock/purchase_receipt.py +0 -0
- {lambda_erp-1.4.32 → lambda_erp-1.4.34}/lambda_erp/stock/reservation.py +0 -0
- {lambda_erp-1.4.32 → lambda_erp-1.4.34}/lambda_erp/stock/serial.py +0 -0
- {lambda_erp-1.4.32 → lambda_erp-1.4.34}/lambda_erp/stock/stock_count.py +0 -0
- {lambda_erp-1.4.32 → lambda_erp-1.4.34}/lambda_erp/stock/stock_entry.py +0 -0
- {lambda_erp-1.4.32 → lambda_erp-1.4.34}/lambda_erp/stock/stock_ledger.py +0 -0
- {lambda_erp-1.4.32 → lambda_erp-1.4.34}/lambda_erp/timestamps.py +0 -0
- {lambda_erp-1.4.32 → lambda_erp-1.4.34}/lambda_erp/units.py +0 -0
- {lambda_erp-1.4.32 → lambda_erp-1.4.34}/lambda_erp/utils.py +0 -0
- {lambda_erp-1.4.32 → lambda_erp-1.4.34}/lambda_erp/validation.py +0 -0
- {lambda_erp-1.4.32 → lambda_erp-1.4.34}/lambda_erp/workflow.py +0 -0
- {lambda_erp-1.4.32 → lambda_erp-1.4.34}/terraform/README.md +0 -0
|
@@ -3195,6 +3195,7 @@ Quotations also have `intro_text`: the opening text (greeting, "Gerne unterbreit
|
|
|
3195
3195
|
|
|
3196
3196
|
### Deductions on a line
|
|
3197
3197
|
To take an amount off one position (already invoiced, credited from a previous project, a project rebate), keep the position at its full price and put the deduction on that same line: `price_list_rate` = full price per unit, `discount_amount` = deduction per unit, `discount_label` = its printed text (e.g. "Abzüglich bereits verrechnet (Rechnung SINV-0003)"). The line then counts the net (rate = price_list_rate − discount_amount); the PDF prints the full price and the deduction as an italic sub-line. A deduction can't exceed its position's price, so a line never goes negative and keeps its tax rate. Sending only `rate` with a new deduction takes that rate as the full price. To remove one, set `discount_amount` 0, `discount_label` empty and `rate` back to the full price. The deduction is carried into the sales order and invoice. There are no negative lines: a deduction always belongs to a position.
|
|
3198
|
+
A deduction can also be a percentage of the full price: `discount_percentage` (e.g. 15) with `price_list_rate` and `discount_label`; the ERP computes `discount_amount` and the rate. 100 % is free of charge (rate 0, the full price is printed with the deduction below). Name the reason in `discount_label`, starting with one of the standard reasons so everyone uses the same words: "Rabatt", "Gratis", "Kulanz", "Testrabatt", optionally followed by " – " and details (e.g. "Testrabatt – Erstbestellung"). Ask which reason applies when the user doesn't say; don't invent one. A line with a deduction text keeps the agreed price; pricing rules no longer change it.
|
|
3198
3199
|
|
|
3199
3200
|
### Internal notes (never printed)
|
|
3200
3201
|
`remarks` is PRINTED and goes to the customer or supplier. Internal team remarks ("customer disputes line 2", "@Anna please check the price") belong in an internal note on the record instead: `add_record_note` (doctype = the record type slug, e.g. `sales-invoice` or `customer`; record_id = its name), read with `list_record_notes`, change with `update_record_note` / `delete_record_note`. Every document and master type supports them; they appear in the record's "Internal notes" card and never change the record. To notify a colleague, first `search_mention_users` and put their exact `mention_text` in the body. Never put internal remarks into `remarks`, and never copy internal notes into customer-facing text.
|
|
@@ -3294,6 +3295,7 @@ For a complete sales return (financial + stock): create and submit both a Credit
|
|
|
3294
3295
|
- A delivery for less than ordered leaves the rest of the line open; convert the order again later for the remainder. Converters only ever propose what is left, and submit rechecks, so a repeated conversion cannot deliver or bill twice.
|
|
3295
3296
|
- Deliver first, invoice after: convert the submitted **Delivery Note** to a Sales Invoice (convert_document doctype="delivery-note", target_doctype="Sales Invoice"). It bills what that delivery delivered and has not been billed, and does not move stock again. Converting the Sales Order to a Sales Invoice instead bills the ordered quantity regardless of delivery.
|
|
3296
3297
|
- **Closing the rest of a line** (the customer no longer wants what is still open, a supplier will never deliver the rest): use the `close_order_lines` action on the submitted order with the lines and a reason. Do not cancel or amend the order, and do not create a return for goods that were never delivered. Deliveries and invoices already posted stay. Delivered or invoiced quantities cannot be closed (a credit note corrects those). `reopen_order_lines` undoes it.
|
|
3298
|
+
- **Addresses**: a customer can have several saved addresses (central store, radiology, accounting) and earlier one-off addresses typed on single orders. When the user asks which addresses a customer has or has used, or an order names a delivery point that is not the default, call `list_customer_addresses` and offer the matching ones. On a draft, a saved address is set by its id (shipping_address / billing_address); an earlier or new one-off address goes into shipping_address_display / billing_address_display with the link left empty. Department and delivery / STOP codes belong in the address text so they print on the delivery note. The customer's notes for delivery notes and invoices (delivery_note_text / invoice_note_text on the customer) are copied into a new document's customer_note and printed; change customer_note on the draft for a one-time difference.
|
|
3297
3299
|
- **Customer billing terms** (on the customer master): customer_type (Company / Individual), billing_cycle (Per Delivery / Monthly; a Monthly customer's deliveries are not invoiced one by one but with the collective invoice at month end), payment_terms_days (the invoice due date; default 30) and credit_limit. Going over the credit limit is a WARNING on the order or invoice (credit_limit_exceeded), never a reason to refuse or hold back an order: say it, then carry on.
|
|
3298
3300
|
- **Monthly / collective invoice** (several deliveries to one customer billed together): check the unbilled-deliveries report for the customer and period, then use `prepare_collective_invoice` (customer + from_date/to_date, or delivery_notes, or the delivery note lines). It drafts ONE Sales Invoice whose lines keep their delivery note and order line; already billed lines are never taken again. Show the draft before submitting.
|
|
3299
3301
|
- Receive first, invoice after works the same on the purchasing side: convert the submitted **Purchase Receipt** to a Purchase Invoice (convert_document doctype="purchase-receipt", target_doctype="Purchase Invoice"). It bills what was received and not billed, at the received price, and does not move stock again.
|
|
@@ -23,6 +23,18 @@ class ReopenOrderLines(mentions.Input):
|
|
|
23
23
|
lines: list[str] | None = Field(default=None, max_length=500)
|
|
24
24
|
|
|
25
25
|
|
|
26
|
+
class CustomerAddresses(mentions.Input):
|
|
27
|
+
customer: str = Field(min_length=1, max_length=200)
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def list_customer_addresses(args):
|
|
31
|
+
data = CustomerAddresses.model_validate(args)
|
|
32
|
+
permissions.require_readable("Customer", data.customer)
|
|
33
|
+
permissions.require("Address", "read")
|
|
34
|
+
from lambda_erp.addresses import customer_addresses
|
|
35
|
+
return customer_addresses(data.customer)
|
|
36
|
+
|
|
37
|
+
|
|
26
38
|
class CollectiveInvoice(mentions.Input):
|
|
27
39
|
customer: str | None = Field(default=None, max_length=200)
|
|
28
40
|
company: str | None = Field(default=None, max_length=200)
|
|
@@ -103,6 +115,17 @@ def initialize_order_actions():
|
|
|
103
115
|
"Undo close_order_lines on a submitted sales or purchase order: the closed quantity of `lines` (or of "
|
|
104
116
|
"every closed line) is open again. A released reservation is not restored; reserve again if needed."),
|
|
105
117
|
parameters=ReopenOrderLines.model_json_schema(), minimum_role="manager")
|
|
118
|
+
services.register_action(
|
|
119
|
+
"list_customer_addresses", list_customer_addresses,
|
|
120
|
+
description=(
|
|
121
|
+
"READ-ONLY: a customer's saved addresses (with label, for invoices / deliveries, defaults, delivery "
|
|
122
|
+
"instructions) and the delivery and invoice addresses its documents used that are NOT on record "
|
|
123
|
+
"(typed for one order), newest first with times used, last used and the last document. Use it when "
|
|
124
|
+
"the user asks which addresses a customer has or has used, or when an order names an address that "
|
|
125
|
+
"differs from the default. To use a saved one, set shipping_address / billing_address (its id) on the "
|
|
126
|
+
"draft; to use an earlier or a new one-off address, set shipping_address_display / "
|
|
127
|
+
"billing_address_display to the text and leave the link empty. Never invent an address."),
|
|
128
|
+
parameters=CustomerAddresses.model_json_schema(), minimum_role="viewer")
|
|
106
129
|
services.register_action(
|
|
107
130
|
"prepare_collective_invoice", prepare_collective_invoice,
|
|
108
131
|
description=(
|
|
@@ -357,6 +357,9 @@ def _render_commercial_pdf(doctype, name, doc, contract, layout=None, blocked=No
|
|
|
357
357
|
delivery_lines=delivery_lines,
|
|
358
358
|
delivery_label="Delivery address",
|
|
359
359
|
delivery_instructions=delivery_instructions(doc) if file == "delivery_note.html" else None,
|
|
360
|
+
# The customer's note for this document type, as copied onto the document
|
|
361
|
+
# (lambda_erp/addresses.py apply_customer_note).
|
|
362
|
+
customer_note=(doc.get("customer_note") or "").strip() or None,
|
|
360
363
|
currency=currency,
|
|
361
364
|
meta_fields=meta_fields,
|
|
362
365
|
items=items,
|
|
@@ -685,6 +685,8 @@ Variables:
|
|
|
685
685
|
_PARTY_VARIABLES = """- company_name, company_info (email, phone, address, city, zip_code, country, tax_id, iban)
|
|
686
686
|
- party_label ("Customer"/"Supplier"), party_name, party_info (email, phone, address, city, zip_code, country, tax_id)
|
|
687
687
|
- title: the document title; pdf_state_notice: "Draft"/"Cancelled" text or empty; pdf_status; page_size ("A4"/"Letter")
|
|
688
|
+
- address_lines (the address the document goes to, first line the recipient), delivery_lines / delivery_label (a differing delivery address), delivery_instructions (delivery notes)
|
|
689
|
+
- customer_note (delivery notes and invoices, may be empty): the customer's note for this document, e.g. "Rechnung per E-Mail an …"; print it close to the address when set
|
|
688
690
|
"""
|
|
689
691
|
|
|
690
692
|
_TEXT_VARIABLES = """- intro_html: the intro text as safe HTML ({{ intro_html|safe }}); print it near the top, usually under the title
|
|
@@ -120,6 +120,7 @@
|
|
|
120
120
|
{% if delivery_instructions %}<div class="detail" style="margin-top: 4px;">{{ delivery_instructions }}</div>{% endif %}
|
|
121
121
|
</div>
|
|
122
122
|
</div>
|
|
123
|
+
{% if customer_note %}<div class="customer-note" style="margin: 0 0 12px; padding: 6px 8px; border-left: 3px solid #334b70; background: #f1f5f9; font-size: 9pt; white-space: pre-wrap;">{{ customer_note }}</div>{% endif %}
|
|
123
124
|
|
|
124
125
|
{# ---- Meta fields ---- #}
|
|
125
126
|
{% if meta_fields %}
|
|
@@ -116,6 +116,7 @@
|
|
|
116
116
|
{% if delivery_instructions %}<div class="detail" style="margin-top: 4px;">{{ delivery_instructions }}</div>{% endif %}
|
|
117
117
|
</div>
|
|
118
118
|
</div>
|
|
119
|
+
{% if customer_note %}<div class="customer-note" style="margin: 0 0 12px; padding: 6px 8px; border-left: 3px solid #334b70; background: #f1f5f9; font-size: 9pt; white-space: pre-wrap;">{{ customer_note }}</div>{% endif %}
|
|
119
120
|
|
|
120
121
|
{# ---- Meta fields ---- #}
|
|
121
122
|
{% if meta_fields %}
|
|
@@ -100,6 +100,7 @@ def resolve_document_addresses(doc):
|
|
|
100
100
|
before the document validates, on every save and on submit."""
|
|
101
101
|
if doc.DOCTYPE not in SOURCES:
|
|
102
102
|
return
|
|
103
|
+
apply_customer_note(doc)
|
|
103
104
|
db = get_db()
|
|
104
105
|
if "billing_address" not in _columns(doc.DOCTYPE) or not _columns("Address"):
|
|
105
106
|
return
|
|
@@ -189,3 +190,81 @@ def delivery_instructions(doc):
|
|
|
189
190
|
if not link or not _columns("Address"):
|
|
190
191
|
return None
|
|
191
192
|
return get_db().get_value("Address", link, "instructions") or None
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
# -- what a customer's documents have used --------------------------------------
|
|
196
|
+
|
|
197
|
+
USED_IN = ("Quotation", "Sales Order", "Delivery Note", "Sales Invoice")
|
|
198
|
+
NOTE_FIELDS = {"Delivery Note": "delivery_note_text", "Sales Invoice": "invoice_note_text"}
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
def _same_text(a, b):
|
|
202
|
+
return " ".join(str(a or "").split()).lower() == " ".join(str(b or "").split()).lower()
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
def customer_addresses(customer, limit=20):
|
|
206
|
+
"""The customer's saved addresses and the delivery and invoice addresses
|
|
207
|
+
its documents have used that are not on record (typed for one order):
|
|
208
|
+
newest first, with how often and when last, and the last document.
|
|
209
|
+
|
|
210
|
+
Read-only: picking one means setting the link (saved) or the printed text
|
|
211
|
+
(used before) on a draft."""
|
|
212
|
+
db = get_db()
|
|
213
|
+
if not customer:
|
|
214
|
+
raise ValidationError("Name the customer")
|
|
215
|
+
customer_name = db.get_value("Customer", customer, "customer_name")
|
|
216
|
+
if customer_name is None:
|
|
217
|
+
raise ValidationError(f"Customer {customer} not found")
|
|
218
|
+
saved = []
|
|
219
|
+
if _columns("Address"):
|
|
220
|
+
for row in db.get_all("Address", filters={"customer": customer}, fields=["*"], order_by="label"):
|
|
221
|
+
saved.append({"address": row["name"], "label": row.get("label"), "title": row.get("address_title"),
|
|
222
|
+
"text": format_address(row, customer_name),
|
|
223
|
+
"for_invoices": bool(flt(row.get("is_billing"))),
|
|
224
|
+
"for_deliveries": bool(flt(row.get("is_shipping"))),
|
|
225
|
+
"default_invoice": bool(flt(row.get("is_default_billing"))),
|
|
226
|
+
"default_delivery": bool(flt(row.get("is_default_shipping"))),
|
|
227
|
+
"disabled": bool(flt(row.get("disabled"))),
|
|
228
|
+
"instructions": row.get("instructions") or None})
|
|
229
|
+
used = {"shipping": {}, "billing": {}}
|
|
230
|
+
for doctype in USED_IN:
|
|
231
|
+
columns = _columns(doctype)
|
|
232
|
+
if "shipping_address_display" not in columns:
|
|
233
|
+
continue
|
|
234
|
+
date = "posting_date" if "posting_date" in columns else "transaction_date"
|
|
235
|
+
for kind in ("shipping", "billing"):
|
|
236
|
+
rows = db.sql(
|
|
237
|
+
f'SELECT name, {kind}_address_display AS text, {date} AS date FROM "{doctype}" '
|
|
238
|
+
"WHERE customer = ? AND docstatus < 2 AND COALESCE(discarded, 0) = 0 "
|
|
239
|
+
f"AND COALESCE({kind}_address_display, '') <> ''", [customer])
|
|
240
|
+
for row in rows:
|
|
241
|
+
key = " ".join(str(row["text"]).split()).lower()
|
|
242
|
+
if any(_same_text(row["text"], s["text"]) for s in saved):
|
|
243
|
+
continue
|
|
244
|
+
entry = used[kind].setdefault(key, {"text": str(row["text"]).strip(), "times": 0,
|
|
245
|
+
"last_used": None, "last_document": None})
|
|
246
|
+
entry["times"] += 1
|
|
247
|
+
day = str(row["date"] or "")[:10]
|
|
248
|
+
if entry["last_used"] is None or day > entry["last_used"]:
|
|
249
|
+
entry["last_used"], entry["last_document"] = day, {"doctype": doctype, "name": row["name"]}
|
|
250
|
+
def newest(entries):
|
|
251
|
+
return sorted(entries.values(), key=lambda e: (e["last_used"] or "", e["times"]), reverse=True)[:limit]
|
|
252
|
+
return {"customer": customer, "customer_name": customer_name, "saved": saved,
|
|
253
|
+
"used_delivery_addresses": newest(used["shipping"]),
|
|
254
|
+
"used_invoice_addresses": newest(used["billing"])}
|
|
255
|
+
|
|
256
|
+
|
|
257
|
+
def apply_customer_note(doc):
|
|
258
|
+
"""A new delivery note or invoice starts with the customer's note for that
|
|
259
|
+
document type (e.g. "Rechnung per E-Mail an …"). Copied once, like the
|
|
260
|
+
address text, so it can be changed for one document and an issued document
|
|
261
|
+
keeps it."""
|
|
262
|
+
field = NOTE_FIELDS.get(doc.DOCTYPE)
|
|
263
|
+
if not field or doc.docstatus != 0 or "customer_note" not in _columns(doc.DOCTYPE):
|
|
264
|
+
return
|
|
265
|
+
if doc._data.get("customer_note") is not None or not doc.get("customer"):
|
|
266
|
+
return
|
|
267
|
+
if field not in _columns("Customer"):
|
|
268
|
+
return
|
|
269
|
+
note = get_db().get_value("Customer", doc.customer, field)
|
|
270
|
+
doc._data["customer_note"] = (note or "").strip() or None
|
|
@@ -249,6 +249,50 @@ def find_item_price(item_code, price_list, qty=0, party_field=None, party=None,
|
|
|
249
249
|
return best
|
|
250
250
|
|
|
251
251
|
|
|
252
|
+
# Documents whose stock lines need a warehouse; an invoice only when it moves stock.
|
|
253
|
+
WAREHOUSE_DOCUMENTS = {"Quotation", "Sales Order", "Delivery Note", "Purchase Order", "Purchase Receipt"}
|
|
254
|
+
STOCK_INVOICES = {"Sales Invoice", "Purchase Invoice", "POS Invoice"}
|
|
255
|
+
|
|
256
|
+
|
|
257
|
+
def default_warehouse(item_code, company):
|
|
258
|
+
"""Where a stock line of this item goes when nobody named a warehouse: the
|
|
259
|
+
item's default warehouse (if it belongs to the company), else the company's
|
|
260
|
+
only warehouse. Group, disabled and consignment warehouses never count.
|
|
261
|
+
None when it is not clear; then the line keeps asking for one."""
|
|
262
|
+
db = get_db()
|
|
263
|
+
columns = db._get_table_columns("Warehouse")
|
|
264
|
+
usable = ["COALESCE(is_group, 0) = 0", "COALESCE(disabled, 0) = 0"]
|
|
265
|
+
if "consignment_customer" in columns:
|
|
266
|
+
usable.append("COALESCE(consignment_customer, '') = ''")
|
|
267
|
+
preferred = db.get_value("Item", item_code, "default_warehouse") if "default_warehouse" in db._get_table_columns("Item") else None
|
|
268
|
+
if preferred:
|
|
269
|
+
where, params = ["name = ?", *usable], [preferred]
|
|
270
|
+
if company:
|
|
271
|
+
where.append("company = ?")
|
|
272
|
+
params.append(company)
|
|
273
|
+
rows = db.sql('SELECT name FROM "Warehouse" WHERE ' + " AND ".join(where), params)
|
|
274
|
+
if rows:
|
|
275
|
+
return preferred
|
|
276
|
+
if not company:
|
|
277
|
+
return None
|
|
278
|
+
rows = db.sql('SELECT name FROM "Warehouse" WHERE company = ? AND ' + " AND ".join(usable) + " LIMIT 2", [company])
|
|
279
|
+
return rows[0]["name"] if len(rows) == 1 else None
|
|
280
|
+
|
|
281
|
+
|
|
282
|
+
def _set_default_warehouse(doc, item, item_code):
|
|
283
|
+
if item.get("warehouse") or doc.docstatus != 0:
|
|
284
|
+
return
|
|
285
|
+
if doc.DOCTYPE not in WAREHOUSE_DOCUMENTS and not (doc.DOCTYPE in STOCK_INVOICES and flt(doc.get("update_stock"))):
|
|
286
|
+
return
|
|
287
|
+
if "warehouse" not in get_db()._get_table_columns(doc.CHILD_TABLES["items"][0]):
|
|
288
|
+
return
|
|
289
|
+
if not get_db().get_value("Item", item_code, "is_stock_item"):
|
|
290
|
+
return
|
|
291
|
+
chosen = default_warehouse(item_code, doc.get("company"))
|
|
292
|
+
if chosen:
|
|
293
|
+
item["warehouse"] = chosen
|
|
294
|
+
|
|
295
|
+
|
|
252
296
|
def set_item_defaults(doc, party_type=None, party_field=None, *, set_description=True):
|
|
253
297
|
"""Fill item names, units and unsupplied rates from master data.
|
|
254
298
|
|
|
@@ -278,6 +322,7 @@ def set_item_defaults(doc, party_type=None, party_field=None, *, set_description
|
|
|
278
322
|
)
|
|
279
323
|
if not item_data:
|
|
280
324
|
continue
|
|
325
|
+
_set_default_warehouse(doc, item, item_code)
|
|
281
326
|
|
|
282
327
|
# A line entered in one of the item's further units (2 Karton) is
|
|
283
328
|
# converted to the stock unit here, before it is priced; see units.py.
|
|
@@ -95,9 +95,17 @@ class TaxCalculator:
|
|
|
95
95
|
item['rate'] = 0.0
|
|
96
96
|
elif flt(item.get("discount_percentage")) == 100:
|
|
97
97
|
item["rate"] = 0.0
|
|
98
|
+
# Free of charge: the whole price is the deduction, so a labelled
|
|
99
|
+
# line prints the full price and "Gratis" below it.
|
|
100
|
+
if item.get("price_list_rate") not in (None, ""):
|
|
101
|
+
item["discount_amount"] = money(dec(item["price_list_rate"]), places)
|
|
98
102
|
elif item.get("price_list_rate") is not None and (flt(item['price_list_rate']) != 0 or item.get('rate') is None):
|
|
99
103
|
list_rate, percent = dec(item["price_list_rate"]), dec(item.get("discount_percentage"))
|
|
100
|
-
if item.get("rate") is None
|
|
104
|
+
if item.get("rate") is None and percent <= 0 and flt(item.get("discount_amount")) > 0:
|
|
105
|
+
# Full price and a deduction per unit, without a rate: the
|
|
106
|
+
# deduction comes off (it used to be dropped).
|
|
107
|
+
item["rate"] = float(list_rate - dec(item["discount_amount"]))
|
|
108
|
+
elif item.get("rate") is None or percent > 0:
|
|
101
109
|
item["rate"] = money(list_rate * (1 - percent / HUNDRED), places)
|
|
102
110
|
item["discount_amount"] = money(list_rate * percent / HUNDRED, places)
|
|
103
111
|
elif item.get("discount_amount"):
|
|
@@ -3932,6 +3932,16 @@ def _m073_customer_terms(db: "Database") -> None:
|
|
|
3932
3932
|
db.ensure_column("Customer", "payment_terms_days", "INTEGER")
|
|
3933
3933
|
|
|
3934
3934
|
|
|
3935
|
+
def _m074_customer_notes(db: "Database") -> None:
|
|
3936
|
+
"""A customer's note for its delivery notes and its invoices
|
|
3937
|
+
(lambda_erp/addresses.py apply_customer_note), copied onto new documents
|
|
3938
|
+
and printed. Empty everywhere after the migration."""
|
|
3939
|
+
db.ensure_column("Customer", "delivery_note_text", "TEXT")
|
|
3940
|
+
db.ensure_column("Customer", "invoice_note_text", "TEXT")
|
|
3941
|
+
db.ensure_column("Delivery Note", "customer_note", "TEXT")
|
|
3942
|
+
db.ensure_column("Sales Invoice", "customer_note", "TEXT")
|
|
3943
|
+
|
|
3944
|
+
|
|
3935
3945
|
Database.MIGRATIONS = [
|
|
3936
3946
|
(1, "chat_message_session_id", _m001_chat_message_session_id),
|
|
3937
3947
|
(2, "chat_session_user_id", _m002_chat_session_user_id),
|
|
@@ -4006,6 +4016,7 @@ Database.MIGRATIONS = [
|
|
|
4006
4016
|
(71, "order_line_closing", _m071_order_line_closing),
|
|
4007
4017
|
(72, "mail_log", _m072_mail_log),
|
|
4008
4018
|
(73, "customer_terms", _m073_customer_terms),
|
|
4019
|
+
(74, "customer_notes", _m074_customer_notes),
|
|
4009
4020
|
]
|
|
4010
4021
|
|
|
4011
4022
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|