lambda-erp 1.4.35__tar.gz → 1.4.38__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.35 → lambda_erp-1.4.38}/PKG-INFO +1 -1
- {lambda_erp-1.4.35 → lambda_erp-1.4.38}/api/attachments.py +42 -1
- {lambda_erp-1.4.35 → lambda_erp-1.4.38}/api/chat.py +1 -1
- {lambda_erp-1.4.35 → lambda_erp-1.4.38}/api/llm_provider.py +14 -1
- {lambda_erp-1.4.35 → lambda_erp-1.4.38}/lambda_erp/controllers/price_resolution.py +34 -0
- {lambda_erp-1.4.35 → lambda_erp-1.4.38}/lambda_erp/stock/consignment.py +3 -3
- {lambda_erp-1.4.35 → lambda_erp-1.4.38}/pyproject.toml +1 -1
- {lambda_erp-1.4.35 → lambda_erp-1.4.38}/.gitignore +0 -0
- {lambda_erp-1.4.35 → lambda_erp-1.4.38}/LICENSE +0 -0
- {lambda_erp-1.4.35 → lambda_erp-1.4.38}/README.md +0 -0
- {lambda_erp-1.4.35 → lambda_erp-1.4.38}/api/__init__.py +0 -0
- {lambda_erp-1.4.35 → lambda_erp-1.4.38}/api/auth.py +0 -0
- {lambda_erp-1.4.35 → lambda_erp-1.4.38}/api/bootstrap.py +0 -0
- {lambda_erp-1.4.35 → lambda_erp-1.4.38}/api/chat_links.py +0 -0
- {lambda_erp-1.4.35 → lambda_erp-1.4.38}/api/demo_limits.py +0 -0
- {lambda_erp-1.4.35 → lambda_erp-1.4.38}/api/deps.py +0 -0
- {lambda_erp-1.4.35 → lambda_erp-1.4.38}/api/erp_context.py +0 -0
- {lambda_erp-1.4.35 → lambda_erp-1.4.38}/api/errors.py +0 -0
- {lambda_erp-1.4.35 → lambda_erp-1.4.38}/api/list_columns.py +0 -0
- {lambda_erp-1.4.35 → lambda_erp-1.4.38}/api/list_values.py +0 -0
- {lambda_erp-1.4.35 → lambda_erp-1.4.38}/api/mail.py +0 -0
- {lambda_erp-1.4.35 → lambda_erp-1.4.38}/api/main.py +0 -0
- {lambda_erp-1.4.35 → lambda_erp-1.4.38}/api/mcp_oauth.py +0 -0
- {lambda_erp-1.4.35 → lambda_erp-1.4.38}/api/mentions.py +0 -0
- {lambda_erp-1.4.35 → lambda_erp-1.4.38}/api/menu_layout.py +0 -0
- {lambda_erp-1.4.35 → lambda_erp-1.4.38}/api/number_series.py +0 -0
- {lambda_erp-1.4.35 → lambda_erp-1.4.38}/api/oauth.py +0 -0
- {lambda_erp-1.4.35 → lambda_erp-1.4.38}/api/order_actions.py +0 -0
- {lambda_erp-1.4.35 → lambda_erp-1.4.38}/api/pdf.py +0 -0
- {lambda_erp-1.4.35 → lambda_erp-1.4.38}/api/pdf_contract.py +0 -0
- {lambda_erp-1.4.35 → lambda_erp-1.4.38}/api/pdf_exports.py +0 -0
- {lambda_erp-1.4.35 → lambda_erp-1.4.38}/api/pdf_fonts.py +0 -0
- {lambda_erp-1.4.35 → lambda_erp-1.4.38}/api/pdf_pages.py +0 -0
- {lambda_erp-1.4.35 → lambda_erp-1.4.38}/api/pdf_profiles.py +0 -0
- {lambda_erp-1.4.35 → lambda_erp-1.4.38}/api/pdf_templates.py +0 -0
- {lambda_erp-1.4.35 → lambda_erp-1.4.38}/api/pricing_actions.py +0 -0
- {lambda_erp-1.4.35 → lambda_erp-1.4.38}/api/providers.py +0 -0
- {lambda_erp-1.4.35 → lambda_erp-1.4.38}/api/record_attachments.py +0 -0
- {lambda_erp-1.4.35 → lambda_erp-1.4.38}/api/record_notes.py +0 -0
- {lambda_erp-1.4.35 → lambda_erp-1.4.38}/api/remarks_md.py +0 -0
- {lambda_erp-1.4.35 → lambda_erp-1.4.38}/api/routers/__init__.py +0 -0
- {lambda_erp-1.4.35 → lambda_erp-1.4.38}/api/routers/accounting.py +0 -0
- {lambda_erp-1.4.35 → lambda_erp-1.4.38}/api/routers/actions.py +0 -0
- {lambda_erp-1.4.35 → lambda_erp-1.4.38}/api/routers/admin.py +0 -0
- {lambda_erp-1.4.35 → lambda_erp-1.4.38}/api/routers/analytics.py +0 -0
- {lambda_erp-1.4.35 → lambda_erp-1.4.38}/api/routers/availability.py +0 -0
- {lambda_erp-1.4.35 → lambda_erp-1.4.38}/api/routers/bank_reconciliation.py +0 -0
- {lambda_erp-1.4.35 → lambda_erp-1.4.38}/api/routers/bank_statements.py +0 -0
- {lambda_erp-1.4.35 → lambda_erp-1.4.38}/api/routers/chat_api.py +0 -0
- {lambda_erp-1.4.35 → lambda_erp-1.4.38}/api/routers/documents.py +0 -0
- {lambda_erp-1.4.35 → lambda_erp-1.4.38}/api/routers/masters.py +0 -0
- {lambda_erp-1.4.35 → lambda_erp-1.4.38}/api/routers/mcp.py +0 -0
- {lambda_erp-1.4.35 → lambda_erp-1.4.38}/api/routers/pdf_templates.py +0 -0
- {lambda_erp-1.4.35 → lambda_erp-1.4.38}/api/routers/proposals.py +0 -0
- {lambda_erp-1.4.35 → lambda_erp-1.4.38}/api/routers/reports.py +0 -0
- {lambda_erp-1.4.35 → lambda_erp-1.4.38}/api/routers/setup.py +0 -0
- {lambda_erp-1.4.35 → lambda_erp-1.4.38}/api/services.py +0 -0
- {lambda_erp-1.4.35 → lambda_erp-1.4.38}/api/stock_actions.py +0 -0
- {lambda_erp-1.4.35 → lambda_erp-1.4.38}/api/templates/_proposal_totals.html +0 -0
- {lambda_erp-1.4.35 → lambda_erp-1.4.38}/api/templates/_record_base.html +0 -0
- {lambda_erp-1.4.35 → lambda_erp-1.4.38}/api/templates/delivery_note.html +0 -0
- {lambda_erp-1.4.35 → lambda_erp-1.4.38}/api/templates/document.html +0 -0
- {lambda_erp-1.4.35 → lambda_erp-1.4.38}/api/templates/proposal.html +0 -0
- {lambda_erp-1.4.35 → lambda_erp-1.4.38}/api/templates/record.html +0 -0
- {lambda_erp-1.4.35 → lambda_erp-1.4.38}/api/templates/reservation.html +0 -0
- {lambda_erp-1.4.35 → lambda_erp-1.4.38}/api/time_filters.py +0 -0
- {lambda_erp-1.4.35 → lambda_erp-1.4.38}/api/tool_permissions.py +0 -0
- {lambda_erp-1.4.35 → lambda_erp-1.4.38}/api/tool_results.py +0 -0
- {lambda_erp-1.4.35 → lambda_erp-1.4.38}/api/write_context.py +0 -0
- {lambda_erp-1.4.35 → lambda_erp-1.4.38}/docs/agents/README.md +0 -0
- {lambda_erp-1.4.35 → lambda_erp-1.4.38}/frontend/LICENSE +0 -0
- {lambda_erp-1.4.35 → lambda_erp-1.4.38}/frontend/README.md +0 -0
- {lambda_erp-1.4.35 → lambda_erp-1.4.38}/frontend/src/api/client.ts +0 -0
- {lambda_erp-1.4.35 → lambda_erp-1.4.38}/lambda_erp/__init__.py +0 -0
- {lambda_erp-1.4.35 → lambda_erp-1.4.38}/lambda_erp/accounting/__init__.py +0 -0
- {lambda_erp-1.4.35 → lambda_erp-1.4.38}/lambda_erp/accounting/bank_account.py +0 -0
- {lambda_erp-1.4.35 → lambda_erp-1.4.38}/lambda_erp/accounting/bank_reconciliation.py +0 -0
- {lambda_erp-1.4.35 → lambda_erp-1.4.38}/lambda_erp/accounting/bank_statement_import.py +0 -0
- {lambda_erp-1.4.35 → lambda_erp-1.4.38}/lambda_erp/accounting/bank_transaction.py +0 -0
- {lambda_erp-1.4.35 → lambda_erp-1.4.38}/lambda_erp/accounting/budget.py +0 -0
- {lambda_erp-1.4.35 → lambda_erp-1.4.38}/lambda_erp/accounting/camt.py +0 -0
- {lambda_erp-1.4.35 → lambda_erp-1.4.38}/lambda_erp/accounting/chart_of_accounts.py +0 -0
- {lambda_erp-1.4.35 → lambda_erp-1.4.38}/lambda_erp/accounting/general_ledger.py +0 -0
- {lambda_erp-1.4.35 → lambda_erp-1.4.38}/lambda_erp/accounting/journal_entry.py +0 -0
- {lambda_erp-1.4.35 → lambda_erp-1.4.38}/lambda_erp/accounting/payment_entry.py +0 -0
- {lambda_erp-1.4.35 → lambda_erp-1.4.38}/lambda_erp/accounting/pos_invoice.py +0 -0
- {lambda_erp-1.4.35 → lambda_erp-1.4.38}/lambda_erp/accounting/purchase_invoice.py +0 -0
- {lambda_erp-1.4.35 → lambda_erp-1.4.38}/lambda_erp/accounting/revaluation.py +0 -0
- {lambda_erp-1.4.35 → lambda_erp-1.4.38}/lambda_erp/accounting/sales_invoice.py +0 -0
- {lambda_erp-1.4.35 → lambda_erp-1.4.38}/lambda_erp/accounting/settlement.py +0 -0
- {lambda_erp-1.4.35 → lambda_erp-1.4.38}/lambda_erp/accounting/setup/__init__.py +0 -0
- {lambda_erp-1.4.35 → lambda_erp-1.4.38}/lambda_erp/accounting/setup/engine.py +0 -0
- {lambda_erp-1.4.35 → lambda_erp-1.4.38}/lambda_erp/accounting/setup/pack.py +0 -0
- {lambda_erp-1.4.35 → lambda_erp-1.4.38}/lambda_erp/accounting/setup/packs/__init__.py +0 -0
- {lambda_erp-1.4.35 → lambda_erp-1.4.38}/lambda_erp/accounting/setup/packs/ch.py +0 -0
- {lambda_erp-1.4.35 → lambda_erp-1.4.38}/lambda_erp/accounting/setup/packs/de_common.py +0 -0
- {lambda_erp-1.4.35 → lambda_erp-1.4.38}/lambda_erp/accounting/setup/packs/de_skr03.py +0 -0
- {lambda_erp-1.4.35 → lambda_erp-1.4.38}/lambda_erp/accounting/setup/packs/de_skr04.py +0 -0
- {lambda_erp-1.4.35 → lambda_erp-1.4.38}/lambda_erp/accounting/setup/packs/generic.py +0 -0
- {lambda_erp-1.4.35 → lambda_erp-1.4.38}/lambda_erp/accounting/setup/profiles.py +0 -0
- {lambda_erp-1.4.35 → lambda_erp-1.4.38}/lambda_erp/accounting/setup/spine.py +0 -0
- {lambda_erp-1.4.35 → lambda_erp-1.4.38}/lambda_erp/accounting/subscription.py +0 -0
- {lambda_erp-1.4.35 → lambda_erp-1.4.38}/lambda_erp/addresses.py +0 -0
- {lambda_erp-1.4.35 → lambda_erp-1.4.38}/lambda_erp/assets/__init__.py +0 -0
- {lambda_erp-1.4.35 → lambda_erp-1.4.38}/lambda_erp/assets/asset.py +0 -0
- {lambda_erp-1.4.35 → lambda_erp-1.4.38}/lambda_erp/assets/lifecycle.py +0 -0
- {lambda_erp-1.4.35 → lambda_erp-1.4.38}/lambda_erp/assets/reservation.py +0 -0
- {lambda_erp-1.4.35 → lambda_erp-1.4.38}/lambda_erp/backlog.py +0 -0
- {lambda_erp-1.4.35 → lambda_erp-1.4.38}/lambda_erp/bundles.py +0 -0
- {lambda_erp-1.4.35 → lambda_erp-1.4.38}/lambda_erp/buying/__init__.py +0 -0
- {lambda_erp-1.4.35 → lambda_erp-1.4.38}/lambda_erp/buying/purchase_order.py +0 -0
- {lambda_erp-1.4.35 → lambda_erp-1.4.38}/lambda_erp/controllers/__init__.py +0 -0
- {lambda_erp-1.4.35 → lambda_erp-1.4.38}/lambda_erp/controllers/currency.py +0 -0
- {lambda_erp-1.4.35 → lambda_erp-1.4.38}/lambda_erp/controllers/defaults.py +0 -0
- {lambda_erp-1.4.35 → lambda_erp-1.4.38}/lambda_erp/controllers/item_price.py +0 -0
- {lambda_erp-1.4.35 → lambda_erp-1.4.38}/lambda_erp/controllers/item_prices.py +0 -0
- {lambda_erp-1.4.35 → lambda_erp-1.4.38}/lambda_erp/controllers/pricing_rule.py +0 -0
- {lambda_erp-1.4.35 → lambda_erp-1.4.38}/lambda_erp/controllers/tax_defaults.py +0 -0
- {lambda_erp-1.4.35 → lambda_erp-1.4.38}/lambda_erp/controllers/taxes_and_totals.py +0 -0
- {lambda_erp-1.4.35 → lambda_erp-1.4.38}/lambda_erp/customer_terms.py +0 -0
- {lambda_erp-1.4.35 → lambda_erp-1.4.38}/lambda_erp/database.py +0 -0
- {lambda_erp-1.4.35 → lambda_erp-1.4.38}/lambda_erp/exceptions.py +0 -0
- {lambda_erp-1.4.35 → lambda_erp-1.4.38}/lambda_erp/hooks.py +0 -0
- {lambda_erp-1.4.35 → lambda_erp-1.4.38}/lambda_erp/master_integrity.py +0 -0
- {lambda_erp-1.4.35 → lambda_erp-1.4.38}/lambda_erp/model.py +0 -0
- {lambda_erp-1.4.35 → lambda_erp-1.4.38}/lambda_erp/order_closing.py +0 -0
- {lambda_erp-1.4.35 → lambda_erp-1.4.38}/lambda_erp/permissions.py +0 -0
- {lambda_erp-1.4.35 → lambda_erp-1.4.38}/lambda_erp/selling/__init__.py +0 -0
- {lambda_erp-1.4.35 → lambda_erp-1.4.38}/lambda_erp/selling/proposal.py +0 -0
- {lambda_erp-1.4.35 → lambda_erp-1.4.38}/lambda_erp/selling/quotation.py +0 -0
- {lambda_erp-1.4.35 → lambda_erp-1.4.38}/lambda_erp/selling/sales_order.py +0 -0
- {lambda_erp-1.4.35 → lambda_erp-1.4.38}/lambda_erp/simulation.py +0 -0
- {lambda_erp-1.4.35 → lambda_erp-1.4.38}/lambda_erp/stock/__init__.py +0 -0
- {lambda_erp-1.4.35 → lambda_erp-1.4.38}/lambda_erp/stock/delivery_note.py +0 -0
- {lambda_erp-1.4.35 → lambda_erp-1.4.38}/lambda_erp/stock/purchase_receipt.py +0 -0
- {lambda_erp-1.4.35 → lambda_erp-1.4.38}/lambda_erp/stock/reservation.py +0 -0
- {lambda_erp-1.4.35 → lambda_erp-1.4.38}/lambda_erp/stock/serial.py +0 -0
- {lambda_erp-1.4.35 → lambda_erp-1.4.38}/lambda_erp/stock/stock_count.py +0 -0
- {lambda_erp-1.4.35 → lambda_erp-1.4.38}/lambda_erp/stock/stock_entry.py +0 -0
- {lambda_erp-1.4.35 → lambda_erp-1.4.38}/lambda_erp/stock/stock_ledger.py +0 -0
- {lambda_erp-1.4.35 → lambda_erp-1.4.38}/lambda_erp/timestamps.py +0 -0
- {lambda_erp-1.4.35 → lambda_erp-1.4.38}/lambda_erp/units.py +0 -0
- {lambda_erp-1.4.35 → lambda_erp-1.4.38}/lambda_erp/utils.py +0 -0
- {lambda_erp-1.4.35 → lambda_erp-1.4.38}/lambda_erp/validation.py +0 -0
- {lambda_erp-1.4.35 → lambda_erp-1.4.38}/lambda_erp/workflow.py +0 -0
- {lambda_erp-1.4.35 → lambda_erp-1.4.38}/terraform/README.md +0 -0
|
@@ -61,10 +61,15 @@ STRUCTURED_TOOL_MIME_TYPES = {
|
|
|
61
61
|
# a one-line description, never the bytes.
|
|
62
62
|
FONT_MIME_TYPES = {"font/ttf", "font/otf", "font/woff", "font/woff2"}
|
|
63
63
|
|
|
64
|
+
# E-mail files (.eml). The model gets the headers, the readable text and the
|
|
65
|
+
# list of attached files, never the raw MIME source with its encoded parts.
|
|
66
|
+
EMAIL_MIME_TYPES = {"message/rfc822"}
|
|
67
|
+
EMAIL_TEXT_LIMIT = 50_000
|
|
68
|
+
|
|
64
69
|
ALLOWED_MIME_TYPES = {
|
|
65
70
|
"image/png", "image/jpeg", "image/gif", "image/webp",
|
|
66
71
|
"application/pdf",
|
|
67
|
-
} | OFFICE_MIME_TYPES | TEXT_MIME_TYPES | STRUCTURED_TOOL_MIME_TYPES | FONT_MIME_TYPES
|
|
72
|
+
} | OFFICE_MIME_TYPES | TEXT_MIME_TYPES | STRUCTURED_TOOL_MIME_TYPES | FONT_MIME_TYPES | EMAIL_MIME_TYPES
|
|
68
73
|
|
|
69
74
|
# Extension -> canonical mime, so a correctly-named file still uploads when the
|
|
70
75
|
# browser/OS mislabels its type (Office files are frequently sent as
|
|
@@ -87,6 +92,7 @@ _EXT_TO_MIME = {
|
|
|
87
92
|
"png": "image/png", "jpg": "image/jpeg", "jpeg": "image/jpeg",
|
|
88
93
|
"gif": "image/gif", "webp": "image/webp",
|
|
89
94
|
"ttf": "font/ttf", "otf": "font/otf", "woff": "font/woff", "woff2": "font/woff2",
|
|
95
|
+
"eml": "message/rfc822",
|
|
90
96
|
}
|
|
91
97
|
_MIME_TO_EXT = {m: e for e, m in _EXT_TO_MIME.items()}
|
|
92
98
|
|
|
@@ -435,6 +441,8 @@ def build_multimodal_content(attachment: dict) -> dict:
|
|
|
435
441
|
return {"type": "text", "text": (
|
|
436
442
|
f"[Font file: {filename} ({what}; id {attachment['id']}). To print a PDF template with it, "
|
|
437
443
|
"call add_attachment_to_pdf_template with this attachment id.]")}
|
|
444
|
+
if mime in EMAIL_MIME_TYPES:
|
|
445
|
+
return {"type": "text", "text": email_summary(attachment)}
|
|
438
446
|
if mime in TEXT_MIME_TYPES or mime.startswith("text/"):
|
|
439
447
|
text = attachment["data"].decode("utf-8", errors="replace")
|
|
440
448
|
return {"type": "text", "text": f"[File: {filename}]\n{text}"}
|
|
@@ -465,6 +473,39 @@ def build_multimodal_content(attachment: dict) -> dict:
|
|
|
465
473
|
return {"type": "text", "text": f"[Unsupported attachment: {filename}]"}
|
|
466
474
|
|
|
467
475
|
|
|
476
|
+
def email_summary(attachment: dict) -> str:
|
|
477
|
+
"""Readable form of an .eml attachment: headers, text body and attached files."""
|
|
478
|
+
import html as html_module
|
|
479
|
+
import re
|
|
480
|
+
from email import policy
|
|
481
|
+
from email.parser import BytesParser
|
|
482
|
+
|
|
483
|
+
message = BytesParser(policy=policy.default).parsebytes(attachment["data"])
|
|
484
|
+
head = [f"{key}: {message[key]}" for key in ("From", "To", "Cc", "Date", "Subject", "Message-ID") if message[key]]
|
|
485
|
+
body = message.get_body(preferencelist=("plain", "html"))
|
|
486
|
+
text = ""
|
|
487
|
+
if body is not None:
|
|
488
|
+
try:
|
|
489
|
+
text = body.get_content()
|
|
490
|
+
except (LookupError, ValueError):
|
|
491
|
+
text = body.get_payload(decode=True).decode("utf-8", errors="replace") if body.get_payload(decode=True) else ""
|
|
492
|
+
if body.get_content_subtype() == "html":
|
|
493
|
+
text = re.sub(r"(?is)<(script|style)[^>]*>.*?</\1>", " ", text)
|
|
494
|
+
text = html_module.unescape(re.sub(r"(?s)<[^>]+>", " ", text))
|
|
495
|
+
text = re.sub(r"[ \t]+", " ", text)
|
|
496
|
+
files = []
|
|
497
|
+
for part in message.iter_attachments():
|
|
498
|
+
payload = part.get_payload(decode=True) or b""
|
|
499
|
+
files.append(f"- {part.get_filename() or '(ohne Namen)'} ({part.get_content_type()}, {len(payload)} Bytes"
|
|
500
|
+
+ (", inline" if part.get_content_disposition() == "inline" else "") + ")")
|
|
501
|
+
text = text.strip()
|
|
502
|
+
if len(text) > EMAIL_TEXT_LIMIT:
|
|
503
|
+
text = text[:EMAIL_TEXT_LIMIT] + "\n[… gekürzt]"
|
|
504
|
+
return (f"[E-mail file: {attachment['filename']} (attachment id {attachment.get('id', '?')})]\n"
|
|
505
|
+
+ "\n".join(head) + "\n\n" + (text or "(kein Text)")
|
|
506
|
+
+ ("\n\nAttached files (not shown here):\n" + "\n".join(files) if files else ""))
|
|
507
|
+
|
|
508
|
+
|
|
468
509
|
def list_session_attachments(session_id: str, user_id: str) -> list[dict]:
|
|
469
510
|
"""Return metadata (no data) for all attachments in a session."""
|
|
470
511
|
db = get_db()
|
|
@@ -3307,7 +3307,7 @@ For a complete sales return (financial + stock): create and submit both a Credit
|
|
|
3307
3307
|
- A line without a rate is priced when the document is saved: the Item Price of the document's price list (a row for this customer/supplier beats the list price; the highest min_qty reached; the narrower, then newer validity), else the item's standard rate. Then at most ONE Pricing Rule applies on top: highest priority, then the most specific match, then min_qty, validity and name.
|
|
3308
3308
|
- Prices and rules are looked up for the document's date (`pricing_date` if set, else posting/transaction date). A price valid from next month does not apply to a document dated today.
|
|
3309
3309
|
- Each line records where its price came from: `price_source` (Item Price, Standard Rate, Entered, Manual, None), `price_reference` (the Item Price) and `pricing_rule`. A rate the user changes on a saved line becomes Manual and is never repriced; converted lines keep the price of their source document.
|
|
3310
|
-
- Use the `explain_price` action to answer "what would X cost for customer Y" and "why is this price what it is" — do not work prices out yourself. If a `price_missing` warning comes back, tell the user there is no price for that item instead of presenting 0.
|
|
3310
|
+
- Use the `explain_price` action to answer "what would X cost for customer Y" and "why is this price what it is" — do not work prices out yourself. For "why this price" name the applied rule AND every other rule in `rules_considered` that would also have matched, with its price and why it did not win (status, e.g. lower priority), so the user sees what was overridden. If a `price_missing` warning comes back, tell the user there is no price for that item instead of presenting 0.
|
|
3311
3311
|
- Deployments may add their own rule keys (for example a price family or a purchasing group); get_document_fields / the rule's `apply_on` and `applicable_for` show what is in use.
|
|
3312
3312
|
|
|
3313
3313
|
### Reservations, availability and picking (FEFO)
|
|
@@ -78,13 +78,26 @@ def not_configured_message() -> str:
|
|
|
78
78
|
return f"{settings.key_variable} is not configured"
|
|
79
79
|
|
|
80
80
|
|
|
81
|
+
def _client_timeout(timeout):
|
|
82
|
+
"""The timeout in the type the installed OpenAI SDK expects.
|
|
83
|
+
|
|
84
|
+
Since openai 3.x the SDK runs on its own HTTP client (httpx2), and httpx2
|
|
85
|
+
2.17 rejects an ``httpx.Timeout``. ``openai.Timeout`` is always the SDK's
|
|
86
|
+
own type, so convert instead of depending on which httpx the SDK uses.
|
|
87
|
+
"""
|
|
88
|
+
import openai
|
|
89
|
+
if timeout is None or isinstance(timeout, (int, float, openai.Timeout)):
|
|
90
|
+
return timeout
|
|
91
|
+
return openai.Timeout(connect=timeout.connect, read=timeout.read, write=timeout.write, pool=timeout.pool)
|
|
92
|
+
|
|
93
|
+
|
|
81
94
|
def client_kwargs(timeout: httpx.Timeout, erp_user: Optional[str] = None) -> dict:
|
|
82
95
|
"""Keyword arguments for ``OpenAI(...)`` with the configured provider."""
|
|
83
96
|
settings = llm_settings()
|
|
84
97
|
headers = {}
|
|
85
98
|
if settings.provider == "lambda" and erp_user:
|
|
86
99
|
headers[ERP_USER_HEADER] = str(erp_user)[:100]
|
|
87
|
-
kwargs = {"api_key": settings.api_key, "timeout": timeout}
|
|
100
|
+
kwargs = {"api_key": settings.api_key, "timeout": _client_timeout(timeout)}
|
|
88
101
|
if settings.base_url:
|
|
89
102
|
kwargs["base_url"] = settings.base_url
|
|
90
103
|
if headers:
|
|
@@ -306,6 +306,7 @@ def explain_document_line(doctype, name, line=1):
|
|
|
306
306
|
manual = source == "Manual"
|
|
307
307
|
carried = bool(flt(row.get("ignore_pricing_rule"))) and not manual
|
|
308
308
|
from lambda_erp.controllers.item_price import pricing_date
|
|
309
|
+
considered = _considered_now(doctype, doc, row, rule)
|
|
309
310
|
return {
|
|
310
311
|
"doctype": doctype, "name": name, "line": row.get("name"), "item_code": row.get("item_code"),
|
|
311
312
|
"qty": flt(row.get("qty")), "rate": flt(row.get("rate")), "price_list_rate": row.get("price_list_rate"),
|
|
@@ -313,5 +314,38 @@ def explain_document_line(doctype, name, line=1):
|
|
|
313
314
|
"pricing_date": pricing_date(doc), "docstatus": doc.docstatus,
|
|
314
315
|
"price_source": source, "price_reference": reference, "base": base, "pricing_rule": rule,
|
|
315
316
|
"manual": manual, "rules_skipped": bool(flt(row.get("ignore_pricing_rule")) or flt(doc.get("ignore_pricing_rule"))),
|
|
317
|
+
# Every rule that matches this line today, with whether it won or why not (e.g. a
|
|
318
|
+
# family price overridden by an association price of higher priority).
|
|
319
|
+
"rules_considered": considered,
|
|
316
320
|
"explanation": _summary(base, rule, row, manual=manual, carried=carried),
|
|
317
321
|
}
|
|
322
|
+
|
|
323
|
+
|
|
324
|
+
def _considered_now(doctype, doc, row, stored_rule):
|
|
325
|
+
"""The rules matching the line under today's rule set, each marked applied / lower priority / tied."""
|
|
326
|
+
from lambda_erp.controllers.item_price import pricing_date
|
|
327
|
+
buying = doctype in _BUYING
|
|
328
|
+
party = doc.get("supplier") if buying else doc.get("customer")
|
|
329
|
+
if not party or not row.get("item_code"):
|
|
330
|
+
return []
|
|
331
|
+
try:
|
|
332
|
+
now = explain_price(doctype, item_code=row["item_code"], qty=flt(row.get("qty")) or 1,
|
|
333
|
+
**({"supplier": party} if buying else {"customer": party}),
|
|
334
|
+
company=doc.get("company"), currency=doc.get("currency"), date=pricing_date(doc),
|
|
335
|
+
uom=row.get("uom") or None)
|
|
336
|
+
except ValidationError:
|
|
337
|
+
return []
|
|
338
|
+
applied = (stored_rule or {}).get("name")
|
|
339
|
+
top = max((r["priority"] for r in now["rules_considered"]), default=0)
|
|
340
|
+
result = []
|
|
341
|
+
for rule in now["rules_considered"]:
|
|
342
|
+
if rule["name"] == applied:
|
|
343
|
+
status = "angewendet"
|
|
344
|
+
elif rule["name"] in (now.get("tied_with") or []):
|
|
345
|
+
status = "gleichrangig"
|
|
346
|
+
elif rule["priority"] < top or applied:
|
|
347
|
+
status = "niedrigere Priorität"
|
|
348
|
+
else:
|
|
349
|
+
status = "nicht angewendet"
|
|
350
|
+
result.append({**rule, "status": status})
|
|
351
|
+
return result
|
|
@@ -181,10 +181,10 @@ class ConsignmentWithdrawal(Document):
|
|
|
181
181
|
"""Bill and withdraw once, through one Sales Invoice."""
|
|
182
182
|
from lambda_erp.accounting.sales_invoice import SalesInvoice
|
|
183
183
|
|
|
184
|
+
# No remarks: they are the printed notes on the customer's invoice. The
|
|
185
|
+
# withdrawal keeps the link to its invoice (sales_invoice).
|
|
184
186
|
invoice = SalesInvoice(
|
|
185
|
-
customer=self.customer, company=self.company, posting_date=self.posting_date, update_stock=1
|
|
186
|
-
remarks=f"Consignment withdrawal {self.name}"
|
|
187
|
-
+ (f" ({self.external_reference})" if self._data.get("external_reference") else ""))
|
|
187
|
+
customer=self.customer, company=self.company, posting_date=self.posting_date, update_stock=1)
|
|
188
188
|
for row in self.get("items"):
|
|
189
189
|
line = _dict(item_code=row["item_code"], qty=flt(row["qty"]), warehouse=self.warehouse,
|
|
190
190
|
batch_no=row.get("batch_no") or None, location=row.get("location") or None,
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|