lambda-erp 1.4.39__tar.gz → 1.4.40__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.39 → lambda_erp-1.4.40}/PKG-INFO +1 -1
- {lambda_erp-1.4.39 → lambda_erp-1.4.40}/api/chat.py +2 -1
- {lambda_erp-1.4.39 → lambda_erp-1.4.40}/api/pdf.py +7 -1
- {lambda_erp-1.4.39 → lambda_erp-1.4.40}/lambda_erp/accounting/purchase_invoice.py +46 -1
- {lambda_erp-1.4.39 → lambda_erp-1.4.40}/lambda_erp/database.py +15 -0
- {lambda_erp-1.4.39 → lambda_erp-1.4.40}/pyproject.toml +1 -1
- {lambda_erp-1.4.39 → lambda_erp-1.4.40}/.gitignore +0 -0
- {lambda_erp-1.4.39 → lambda_erp-1.4.40}/LICENSE +0 -0
- {lambda_erp-1.4.39 → lambda_erp-1.4.40}/README.md +0 -0
- {lambda_erp-1.4.39 → lambda_erp-1.4.40}/api/__init__.py +0 -0
- {lambda_erp-1.4.39 → lambda_erp-1.4.40}/api/attachments.py +0 -0
- {lambda_erp-1.4.39 → lambda_erp-1.4.40}/api/auth.py +0 -0
- {lambda_erp-1.4.39 → lambda_erp-1.4.40}/api/bootstrap.py +0 -0
- {lambda_erp-1.4.39 → lambda_erp-1.4.40}/api/chat_links.py +0 -0
- {lambda_erp-1.4.39 → lambda_erp-1.4.40}/api/demo_limits.py +0 -0
- {lambda_erp-1.4.39 → lambda_erp-1.4.40}/api/deps.py +0 -0
- {lambda_erp-1.4.39 → lambda_erp-1.4.40}/api/erp_context.py +0 -0
- {lambda_erp-1.4.39 → lambda_erp-1.4.40}/api/errors.py +0 -0
- {lambda_erp-1.4.39 → lambda_erp-1.4.40}/api/list_columns.py +0 -0
- {lambda_erp-1.4.39 → lambda_erp-1.4.40}/api/list_values.py +0 -0
- {lambda_erp-1.4.39 → lambda_erp-1.4.40}/api/llm_provider.py +0 -0
- {lambda_erp-1.4.39 → lambda_erp-1.4.40}/api/mail.py +0 -0
- {lambda_erp-1.4.39 → lambda_erp-1.4.40}/api/main.py +0 -0
- {lambda_erp-1.4.39 → lambda_erp-1.4.40}/api/mcp_oauth.py +0 -0
- {lambda_erp-1.4.39 → lambda_erp-1.4.40}/api/mentions.py +0 -0
- {lambda_erp-1.4.39 → lambda_erp-1.4.40}/api/menu_layout.py +0 -0
- {lambda_erp-1.4.39 → lambda_erp-1.4.40}/api/number_series.py +0 -0
- {lambda_erp-1.4.39 → lambda_erp-1.4.40}/api/oauth.py +0 -0
- {lambda_erp-1.4.39 → lambda_erp-1.4.40}/api/order_actions.py +0 -0
- {lambda_erp-1.4.39 → lambda_erp-1.4.40}/api/pdf_contract.py +0 -0
- {lambda_erp-1.4.39 → lambda_erp-1.4.40}/api/pdf_exports.py +0 -0
- {lambda_erp-1.4.39 → lambda_erp-1.4.40}/api/pdf_fonts.py +0 -0
- {lambda_erp-1.4.39 → lambda_erp-1.4.40}/api/pdf_pages.py +0 -0
- {lambda_erp-1.4.39 → lambda_erp-1.4.40}/api/pdf_profiles.py +0 -0
- {lambda_erp-1.4.39 → lambda_erp-1.4.40}/api/pdf_templates.py +0 -0
- {lambda_erp-1.4.39 → lambda_erp-1.4.40}/api/pricing_actions.py +0 -0
- {lambda_erp-1.4.39 → lambda_erp-1.4.40}/api/providers.py +0 -0
- {lambda_erp-1.4.39 → lambda_erp-1.4.40}/api/record_attachments.py +0 -0
- {lambda_erp-1.4.39 → lambda_erp-1.4.40}/api/record_notes.py +0 -0
- {lambda_erp-1.4.39 → lambda_erp-1.4.40}/api/remarks_md.py +0 -0
- {lambda_erp-1.4.39 → lambda_erp-1.4.40}/api/routers/__init__.py +0 -0
- {lambda_erp-1.4.39 → lambda_erp-1.4.40}/api/routers/accounting.py +0 -0
- {lambda_erp-1.4.39 → lambda_erp-1.4.40}/api/routers/actions.py +0 -0
- {lambda_erp-1.4.39 → lambda_erp-1.4.40}/api/routers/admin.py +0 -0
- {lambda_erp-1.4.39 → lambda_erp-1.4.40}/api/routers/analytics.py +0 -0
- {lambda_erp-1.4.39 → lambda_erp-1.4.40}/api/routers/availability.py +0 -0
- {lambda_erp-1.4.39 → lambda_erp-1.4.40}/api/routers/bank_reconciliation.py +0 -0
- {lambda_erp-1.4.39 → lambda_erp-1.4.40}/api/routers/bank_statements.py +0 -0
- {lambda_erp-1.4.39 → lambda_erp-1.4.40}/api/routers/chat_api.py +0 -0
- {lambda_erp-1.4.39 → lambda_erp-1.4.40}/api/routers/documents.py +0 -0
- {lambda_erp-1.4.39 → lambda_erp-1.4.40}/api/routers/masters.py +0 -0
- {lambda_erp-1.4.39 → lambda_erp-1.4.40}/api/routers/mcp.py +0 -0
- {lambda_erp-1.4.39 → lambda_erp-1.4.40}/api/routers/pdf_templates.py +0 -0
- {lambda_erp-1.4.39 → lambda_erp-1.4.40}/api/routers/proposals.py +0 -0
- {lambda_erp-1.4.39 → lambda_erp-1.4.40}/api/routers/reports.py +0 -0
- {lambda_erp-1.4.39 → lambda_erp-1.4.40}/api/routers/setup.py +0 -0
- {lambda_erp-1.4.39 → lambda_erp-1.4.40}/api/services.py +0 -0
- {lambda_erp-1.4.39 → lambda_erp-1.4.40}/api/stock_actions.py +0 -0
- {lambda_erp-1.4.39 → lambda_erp-1.4.40}/api/templates/_proposal_totals.html +0 -0
- {lambda_erp-1.4.39 → lambda_erp-1.4.40}/api/templates/_record_base.html +0 -0
- {lambda_erp-1.4.39 → lambda_erp-1.4.40}/api/templates/delivery_note.html +0 -0
- {lambda_erp-1.4.39 → lambda_erp-1.4.40}/api/templates/document.html +0 -0
- {lambda_erp-1.4.39 → lambda_erp-1.4.40}/api/templates/proposal.html +0 -0
- {lambda_erp-1.4.39 → lambda_erp-1.4.40}/api/templates/record.html +0 -0
- {lambda_erp-1.4.39 → lambda_erp-1.4.40}/api/templates/reservation.html +0 -0
- {lambda_erp-1.4.39 → lambda_erp-1.4.40}/api/time_filters.py +0 -0
- {lambda_erp-1.4.39 → lambda_erp-1.4.40}/api/tool_permissions.py +0 -0
- {lambda_erp-1.4.39 → lambda_erp-1.4.40}/api/tool_results.py +0 -0
- {lambda_erp-1.4.39 → lambda_erp-1.4.40}/api/write_context.py +0 -0
- {lambda_erp-1.4.39 → lambda_erp-1.4.40}/docs/agents/README.md +0 -0
- {lambda_erp-1.4.39 → lambda_erp-1.4.40}/frontend/LICENSE +0 -0
- {lambda_erp-1.4.39 → lambda_erp-1.4.40}/frontend/README.md +0 -0
- {lambda_erp-1.4.39 → lambda_erp-1.4.40}/frontend/src/api/client.ts +0 -0
- {lambda_erp-1.4.39 → lambda_erp-1.4.40}/lambda_erp/__init__.py +0 -0
- {lambda_erp-1.4.39 → lambda_erp-1.4.40}/lambda_erp/accounting/__init__.py +0 -0
- {lambda_erp-1.4.39 → lambda_erp-1.4.40}/lambda_erp/accounting/bank_account.py +0 -0
- {lambda_erp-1.4.39 → lambda_erp-1.4.40}/lambda_erp/accounting/bank_reconciliation.py +0 -0
- {lambda_erp-1.4.39 → lambda_erp-1.4.40}/lambda_erp/accounting/bank_statement_import.py +0 -0
- {lambda_erp-1.4.39 → lambda_erp-1.4.40}/lambda_erp/accounting/bank_transaction.py +0 -0
- {lambda_erp-1.4.39 → lambda_erp-1.4.40}/lambda_erp/accounting/budget.py +0 -0
- {lambda_erp-1.4.39 → lambda_erp-1.4.40}/lambda_erp/accounting/camt.py +0 -0
- {lambda_erp-1.4.39 → lambda_erp-1.4.40}/lambda_erp/accounting/chart_of_accounts.py +0 -0
- {lambda_erp-1.4.39 → lambda_erp-1.4.40}/lambda_erp/accounting/general_ledger.py +0 -0
- {lambda_erp-1.4.39 → lambda_erp-1.4.40}/lambda_erp/accounting/journal_entry.py +0 -0
- {lambda_erp-1.4.39 → lambda_erp-1.4.40}/lambda_erp/accounting/payment_entry.py +0 -0
- {lambda_erp-1.4.39 → lambda_erp-1.4.40}/lambda_erp/accounting/pos_invoice.py +0 -0
- {lambda_erp-1.4.39 → lambda_erp-1.4.40}/lambda_erp/accounting/revaluation.py +0 -0
- {lambda_erp-1.4.39 → lambda_erp-1.4.40}/lambda_erp/accounting/sales_invoice.py +0 -0
- {lambda_erp-1.4.39 → lambda_erp-1.4.40}/lambda_erp/accounting/settlement.py +0 -0
- {lambda_erp-1.4.39 → lambda_erp-1.4.40}/lambda_erp/accounting/setup/__init__.py +0 -0
- {lambda_erp-1.4.39 → lambda_erp-1.4.40}/lambda_erp/accounting/setup/engine.py +0 -0
- {lambda_erp-1.4.39 → lambda_erp-1.4.40}/lambda_erp/accounting/setup/pack.py +0 -0
- {lambda_erp-1.4.39 → lambda_erp-1.4.40}/lambda_erp/accounting/setup/packs/__init__.py +0 -0
- {lambda_erp-1.4.39 → lambda_erp-1.4.40}/lambda_erp/accounting/setup/packs/ch.py +0 -0
- {lambda_erp-1.4.39 → lambda_erp-1.4.40}/lambda_erp/accounting/setup/packs/de_common.py +0 -0
- {lambda_erp-1.4.39 → lambda_erp-1.4.40}/lambda_erp/accounting/setup/packs/de_skr03.py +0 -0
- {lambda_erp-1.4.39 → lambda_erp-1.4.40}/lambda_erp/accounting/setup/packs/de_skr04.py +0 -0
- {lambda_erp-1.4.39 → lambda_erp-1.4.40}/lambda_erp/accounting/setup/packs/generic.py +0 -0
- {lambda_erp-1.4.39 → lambda_erp-1.4.40}/lambda_erp/accounting/setup/profiles.py +0 -0
- {lambda_erp-1.4.39 → lambda_erp-1.4.40}/lambda_erp/accounting/setup/spine.py +0 -0
- {lambda_erp-1.4.39 → lambda_erp-1.4.40}/lambda_erp/accounting/subscription.py +0 -0
- {lambda_erp-1.4.39 → lambda_erp-1.4.40}/lambda_erp/addresses.py +0 -0
- {lambda_erp-1.4.39 → lambda_erp-1.4.40}/lambda_erp/assets/__init__.py +0 -0
- {lambda_erp-1.4.39 → lambda_erp-1.4.40}/lambda_erp/assets/asset.py +0 -0
- {lambda_erp-1.4.39 → lambda_erp-1.4.40}/lambda_erp/assets/lifecycle.py +0 -0
- {lambda_erp-1.4.39 → lambda_erp-1.4.40}/lambda_erp/assets/reservation.py +0 -0
- {lambda_erp-1.4.39 → lambda_erp-1.4.40}/lambda_erp/backlog.py +0 -0
- {lambda_erp-1.4.39 → lambda_erp-1.4.40}/lambda_erp/bundles.py +0 -0
- {lambda_erp-1.4.39 → lambda_erp-1.4.40}/lambda_erp/buying/__init__.py +0 -0
- {lambda_erp-1.4.39 → lambda_erp-1.4.40}/lambda_erp/buying/purchase_order.py +0 -0
- {lambda_erp-1.4.39 → lambda_erp-1.4.40}/lambda_erp/controllers/__init__.py +0 -0
- {lambda_erp-1.4.39 → lambda_erp-1.4.40}/lambda_erp/controllers/currency.py +0 -0
- {lambda_erp-1.4.39 → lambda_erp-1.4.40}/lambda_erp/controllers/defaults.py +0 -0
- {lambda_erp-1.4.39 → lambda_erp-1.4.40}/lambda_erp/controllers/item_price.py +0 -0
- {lambda_erp-1.4.39 → lambda_erp-1.4.40}/lambda_erp/controllers/item_prices.py +0 -0
- {lambda_erp-1.4.39 → lambda_erp-1.4.40}/lambda_erp/controllers/price_resolution.py +0 -0
- {lambda_erp-1.4.39 → lambda_erp-1.4.40}/lambda_erp/controllers/pricing_rule.py +0 -0
- {lambda_erp-1.4.39 → lambda_erp-1.4.40}/lambda_erp/controllers/tax_defaults.py +0 -0
- {lambda_erp-1.4.39 → lambda_erp-1.4.40}/lambda_erp/controllers/taxes_and_totals.py +0 -0
- {lambda_erp-1.4.39 → lambda_erp-1.4.40}/lambda_erp/customer_terms.py +0 -0
- {lambda_erp-1.4.39 → lambda_erp-1.4.40}/lambda_erp/exceptions.py +0 -0
- {lambda_erp-1.4.39 → lambda_erp-1.4.40}/lambda_erp/hooks.py +0 -0
- {lambda_erp-1.4.39 → lambda_erp-1.4.40}/lambda_erp/master_integrity.py +0 -0
- {lambda_erp-1.4.39 → lambda_erp-1.4.40}/lambda_erp/model.py +0 -0
- {lambda_erp-1.4.39 → lambda_erp-1.4.40}/lambda_erp/order_closing.py +0 -0
- {lambda_erp-1.4.39 → lambda_erp-1.4.40}/lambda_erp/permissions.py +0 -0
- {lambda_erp-1.4.39 → lambda_erp-1.4.40}/lambda_erp/selling/__init__.py +0 -0
- {lambda_erp-1.4.39 → lambda_erp-1.4.40}/lambda_erp/selling/proposal.py +0 -0
- {lambda_erp-1.4.39 → lambda_erp-1.4.40}/lambda_erp/selling/quotation.py +0 -0
- {lambda_erp-1.4.39 → lambda_erp-1.4.40}/lambda_erp/selling/sales_order.py +0 -0
- {lambda_erp-1.4.39 → lambda_erp-1.4.40}/lambda_erp/simulation.py +0 -0
- {lambda_erp-1.4.39 → lambda_erp-1.4.40}/lambda_erp/stock/__init__.py +0 -0
- {lambda_erp-1.4.39 → lambda_erp-1.4.40}/lambda_erp/stock/consignment.py +0 -0
- {lambda_erp-1.4.39 → lambda_erp-1.4.40}/lambda_erp/stock/delivery_note.py +0 -0
- {lambda_erp-1.4.39 → lambda_erp-1.4.40}/lambda_erp/stock/purchase_receipt.py +0 -0
- {lambda_erp-1.4.39 → lambda_erp-1.4.40}/lambda_erp/stock/reservation.py +0 -0
- {lambda_erp-1.4.39 → lambda_erp-1.4.40}/lambda_erp/stock/serial.py +0 -0
- {lambda_erp-1.4.39 → lambda_erp-1.4.40}/lambda_erp/stock/stock_count.py +0 -0
- {lambda_erp-1.4.39 → lambda_erp-1.4.40}/lambda_erp/stock/stock_entry.py +0 -0
- {lambda_erp-1.4.39 → lambda_erp-1.4.40}/lambda_erp/stock/stock_ledger.py +0 -0
- {lambda_erp-1.4.39 → lambda_erp-1.4.40}/lambda_erp/timestamps.py +0 -0
- {lambda_erp-1.4.39 → lambda_erp-1.4.40}/lambda_erp/units.py +0 -0
- {lambda_erp-1.4.39 → lambda_erp-1.4.40}/lambda_erp/utils.py +0 -0
- {lambda_erp-1.4.39 → lambda_erp-1.4.40}/lambda_erp/validation.py +0 -0
- {lambda_erp-1.4.39 → lambda_erp-1.4.40}/lambda_erp/workflow.py +0 -0
- {lambda_erp-1.4.39 → lambda_erp-1.4.40}/terraform/README.md +0 -0
|
@@ -3206,6 +3206,7 @@ Purchase Order → Purchase Receipt (receiving) / Purchase Invoice (billing) →
|
|
|
3206
3206
|
- **Purchase Order:** Commitment to buy from supplier. No financial or stock impact.
|
|
3207
3207
|
- **Purchase Receipt:** Receives goods into warehouse. **Posts stock entries** (inventory increases). Requires warehouse on each item.
|
|
3208
3208
|
- **Purchase Invoice:** Records supplier bill. Always **posts GL entries** and creates outstanding amount.
|
|
3209
|
+
Set `bill_no` to the supplier's invoice number (preserved verbatim, checked for duplicates per supplier) and `bill_date` to the date printed on the supplier's bill (YYYY-MM-DD, if given) whenever mentioned or visible on an uploaded bill — never drop them or put them into `remarks`.
|
|
3209
3210
|
For non-stock/services: Debit Expense, Credit Accounts Payable.
|
|
3210
3211
|
For stock after a prior Purchase Receipt: Debit Stock Received But Not Billed, Credit Accounts Payable.
|
|
3211
3212
|
If `update_stock=1`: the Purchase Invoice also receives the goods into stock, so stock items require a warehouse and the posting is Debit Stock In Hand, Credit Accounts Payable.
|
|
@@ -3526,7 +3527,7 @@ Users can attach PDFs and images (receipts, bills, contracts, screenshots) to th
|
|
|
3526
3527
|
|
|
3527
3528
|
- **For the current message** — any attached images/PDFs are already in your context; read them carefully and use the content (e.g., parse a supplier invoice into a Purchase Invoice).
|
|
3528
3529
|
- **For files uploaded earlier in the chat** — if the user asks about a previously-uploaded file that is no longer in your immediate context, call `list_chat_attachments` to see what's available, then `retrieve_chat_attachment(attachment_id)` to load it. The retrieved content will appear in the next turn as a user message you can read.
|
|
3529
|
-
- **When a user uploads a bill/invoice and asks you to "add it" or "create a purchase invoice"**, extract supplier, line items, quantities, rates, and totals from the document and call `create_document("purchase-invoice", {...})`. Confirm details back to the user and ask about anything ambiguous (e.g., which existing supplier it matches)."""
|
|
3530
|
+
- **When a user uploads a bill/invoice and asks you to "add it" or "create a purchase invoice"**, extract supplier, supplier invoice number (`bill_no`), supplier invoice date (`bill_date`, if printed on the bill), line items, quantities, rates, and totals from the document and call `create_document("purchase-invoice", {...})`. Confirm details back to the user and ask about anything ambiguous (e.g., which existing supplier it matches)."""
|
|
3530
3531
|
|
|
3531
3532
|
|
|
3532
3533
|
# ---------------------------------------------------------------------------
|
|
@@ -95,7 +95,7 @@ class RenderedPDF:
|
|
|
95
95
|
# closing text "Gültig bis {{ valid_till }}". Plain substitution, not Jinja:
|
|
96
96
|
# unknown names stay as written.
|
|
97
97
|
TEXT_PLACEHOLDERS = ("name", "customer_name", "party_name", "company", "transaction_date", "posting_date",
|
|
98
|
-
"valid_till", "due_date", "delivery_date", "schedule_date", "currency")
|
|
98
|
+
"bill_no", "bill_date", "valid_till", "due_date", "delivery_date", "schedule_date", "currency")
|
|
99
99
|
_PLACEHOLDER = re.compile(r"\{\{\s*(" + "|".join(TEXT_PLACEHOLDERS) + r")\s*\}\}")
|
|
100
100
|
|
|
101
101
|
|
|
@@ -289,10 +289,16 @@ def _render_commercial_pdf(doctype, name, doc, contract, layout=None, blocked=No
|
|
|
289
289
|
meta_fields.append({"label": "Date", "value": doc["transaction_date"]})
|
|
290
290
|
if doc.get("due_date"):
|
|
291
291
|
meta_fields.append({"label": "Due Date", "value": doc["due_date"]})
|
|
292
|
+
if doc.get("bill_no"):
|
|
293
|
+
meta_fields.append({"label": "Supplier Invoice No.", "value": doc["bill_no"]})
|
|
294
|
+
if doc.get("bill_date"):
|
|
295
|
+
meta_fields.append({"label": "Supplier Invoice Date", "value": doc["bill_date"]})
|
|
292
296
|
if doc.get("valid_till"):
|
|
293
297
|
meta_fields.append({"label": "Valid Till", "value": doc["valid_till"]})
|
|
294
298
|
if doc.get("delivery_date"):
|
|
295
299
|
meta_fields.append({"label": "Delivery Date", "value": doc["delivery_date"]})
|
|
300
|
+
elif doc.get("schedule_date"):
|
|
301
|
+
meta_fields.append({"label": "Delivery Date", "value": doc["schedule_date"]})
|
|
296
302
|
if doc.get("return_against"):
|
|
297
303
|
meta_fields.append({"label": "Return Against", "value": doc["return_against"]})
|
|
298
304
|
if doc.get("status"):
|
|
@@ -71,6 +71,9 @@ class PurchaseInvoice(Document):
|
|
|
71
71
|
if not self.posting_date:
|
|
72
72
|
self.posting_date = nowdate()
|
|
73
73
|
|
|
74
|
+
self._normalize_bill_fields()
|
|
75
|
+
self._validate_duplicate_bill_no()
|
|
76
|
+
|
|
74
77
|
apply_external_source_defaults(self)
|
|
75
78
|
from lambda_erp.workflow import apply_amount_only
|
|
76
79
|
apply_amount_only(self)
|
|
@@ -97,7 +100,46 @@ class PurchaseInvoice(Document):
|
|
|
97
100
|
self._data["outstanding_amount"] = flt(self.grand_total, 2)
|
|
98
101
|
|
|
99
102
|
if not self.due_date:
|
|
100
|
-
self._data["due_date"] = add_days(self.posting_date, 30)
|
|
103
|
+
self._data["due_date"] = add_days(self.bill_date or self.posting_date, 30)
|
|
104
|
+
|
|
105
|
+
def _normalize_bill_fields(self):
|
|
106
|
+
"""Trim surrounding whitespace on supplier bill_no / bill_date; empty becomes None."""
|
|
107
|
+
if "bill_no" in self._data and self._data["bill_no"] is not None:
|
|
108
|
+
trimmed = str(self._data["bill_no"]).strip()
|
|
109
|
+
self._data["bill_no"] = trimmed or None
|
|
110
|
+
if "bill_date" in self._data and self._data["bill_date"] is not None:
|
|
111
|
+
trimmed = str(self._data["bill_date"]).strip()
|
|
112
|
+
self._data["bill_date"] = trimmed or None
|
|
113
|
+
|
|
114
|
+
def _validate_duplicate_bill_no(self):
|
|
115
|
+
"""Reject duplicate supplier invoice numbers per (company, supplier)
|
|
116
|
+
against already-submitted non-return Purchase Invoices. Returns (Debit
|
|
117
|
+
Notes) are exempt so a supplier credit note can reference the original
|
|
118
|
+
bill or carry its own number."""
|
|
119
|
+
if flt(self.get("is_return")):
|
|
120
|
+
return
|
|
121
|
+
bill_no = str(self._data.get("bill_no") or "").strip()
|
|
122
|
+
if not bill_no or not self.supplier or not self.company:
|
|
123
|
+
return
|
|
124
|
+
db = get_db()
|
|
125
|
+
if "bill_no" not in db._get_table_columns(self.DOCTYPE):
|
|
126
|
+
return
|
|
127
|
+
rows = db.sql(
|
|
128
|
+
'SELECT name FROM "Purchase Invoice" '
|
|
129
|
+
'WHERE company = ? AND supplier = ? '
|
|
130
|
+
' AND docstatus = 1 '
|
|
131
|
+
' AND COALESCE(discarded, 0) = 0 '
|
|
132
|
+
' AND COALESCE(is_return, 0) = 0 '
|
|
133
|
+
' AND name != ? '
|
|
134
|
+
" AND LOWER(TRIM(COALESCE(bill_no, ''))) = LOWER(?) "
|
|
135
|
+
'LIMIT 1',
|
|
136
|
+
[self.company, self.supplier, self.name or "", bill_no],
|
|
137
|
+
)
|
|
138
|
+
if rows:
|
|
139
|
+
raise ValidationError(
|
|
140
|
+
f"Duplicate supplier invoice number '{bill_no}' for supplier {self.supplier}: "
|
|
141
|
+
f"already recorded on Purchase Invoice {rows[0]['name']}"
|
|
142
|
+
)
|
|
101
143
|
|
|
102
144
|
def _set_supplier_name(self):
|
|
103
145
|
if not self.supplier_name and self.supplier:
|
|
@@ -310,6 +352,9 @@ class PurchaseInvoice(Document):
|
|
|
310
352
|
routed to Stock In Hand in _set_missing_accounts so the existing
|
|
311
353
|
GL loop naturally books Dr Stock In Hand for those lines.
|
|
312
354
|
"""
|
|
355
|
+
self._normalize_bill_fields()
|
|
356
|
+
self._validate_duplicate_bill_no()
|
|
357
|
+
|
|
313
358
|
if flt(self.get("update_stock")):
|
|
314
359
|
sl_entries = self._get_stock_sl_entries()
|
|
315
360
|
if sl_entries:
|
|
@@ -918,6 +918,8 @@ class Database:
|
|
|
918
918
|
supplier TEXT,
|
|
919
919
|
supplier_name TEXT,
|
|
920
920
|
posting_date TEXT,
|
|
921
|
+
bill_no TEXT,
|
|
922
|
+
bill_date TEXT,
|
|
921
923
|
due_date TEXT,
|
|
922
924
|
company TEXT,
|
|
923
925
|
currency TEXT DEFAULT 'USD',
|
|
@@ -3942,6 +3944,18 @@ def _m074_customer_notes(db: "Database") -> None:
|
|
|
3942
3944
|
db.ensure_column("Sales Invoice", "customer_note", "TEXT")
|
|
3943
3945
|
|
|
3944
3946
|
|
|
3947
|
+
def _m075_purchase_invoice_bill_no(db: "Database") -> None:
|
|
3948
|
+
"""Supplier invoice number and date on Purchase Invoice (`bill_no`,
|
|
3949
|
+
`bill_date`), plus an index for per-supplier duplicate checks and search."""
|
|
3950
|
+
db.ensure_column("Purchase Invoice", "bill_no", "TEXT")
|
|
3951
|
+
db.ensure_column("Purchase Invoice", "bill_date", "TEXT")
|
|
3952
|
+
db.conn.execute(db._ddl(
|
|
3953
|
+
'CREATE INDEX IF NOT EXISTS "ix_purchase_invoice_bill_no" '
|
|
3954
|
+
'ON "Purchase Invoice" (company, supplier, bill_no)'
|
|
3955
|
+
))
|
|
3956
|
+
db.conn.commit()
|
|
3957
|
+
|
|
3958
|
+
|
|
3945
3959
|
Database.MIGRATIONS = [
|
|
3946
3960
|
(1, "chat_message_session_id", _m001_chat_message_session_id),
|
|
3947
3961
|
(2, "chat_session_user_id", _m002_chat_session_user_id),
|
|
@@ -4017,6 +4031,7 @@ Database.MIGRATIONS = [
|
|
|
4017
4031
|
(72, "mail_log", _m072_mail_log),
|
|
4018
4032
|
(73, "customer_terms", _m073_customer_terms),
|
|
4019
4033
|
(74, "customer_notes", _m074_customer_notes),
|
|
4034
|
+
(75, "purchase_invoice_bill_no", _m075_purchase_invoice_bill_no),
|
|
4020
4035
|
]
|
|
4021
4036
|
|
|
4022
4037
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|