Skip to content

Open-source manufacturing ERP, MES and QMS. Quoting, MRP, inventory, shop floor, quality and lot/serial traceability on one Postgres schema, with a REST API and MCP server. Self-host or use Carbon Cloud.

fix(sales): reject negative/invalid quote-line pricing on import

sidgaikwad134f86a0ecd6
diff --git a/apps/erp/app/modules/sales/sales.import.server.ts b/apps/erp/app/modules/sales/sales.import.server.ts
index 7af935d1db..e733094db8 100644
--- a/apps/erp/app/modules/sales/sales.import.server.ts
+++ b/apps/erp/app/modules/sales/sales.import.server.ts
@@ -757,30 +757,51 @@ async function createLines(
summary.inserted += 1;
const lineId = line.data.id;
- const unitPrice = num(record.unitPrice);
- if (unitPrice !== undefined) {
- const priceResult = await upsertQuoteLinePrices(
- client,
- quoteInternalId,
- lineId,
- [
- {
- quoteLineId: lineId,
- unitPrice,
- leadTime: num(record.leadTime) ?? 0,
- discountPercent: discount,
- quantity,
- createdBy: userId,
- priceSource: "manual"
- }
- ]
- );
- if (priceResult.error) {
+ // Explicit quantity-break pricing. Only persist non-negative, valid numbers
+ // — a present-but-invalid or negative Unit Price / Lead Time is rejected
+ // rather than written to the quote line.
+ const unitPriceRaw = text(record.unitPrice);
+ if (unitPriceRaw) {
+ const unitPrice = num(unitPriceRaw);
+ const leadTimeRaw = text(record.leadTime);
+ const leadTime = num(leadTimeRaw);
+
+ if (unitPrice === undefined || unitPrice < 0) {
summary.errors.push({
row: index,
- reason: `Line created but pricing failed: ${priceResult.error.message}`,
+ reason: "Unit Price must be a number of 0 or greater",
values: record
});
+ } else if (leadTimeRaw && (leadTime === undefined || leadTime < 0)) {
+ summary.errors.push({
+ row: index,
+ reason: "Lead Time must be a number of 0 or greater",
+ values: record
+ });
+ } else {
+ const priceResult = await upsertQuoteLinePrices(
+ client,
+ quoteInternalId,
+ lineId,
+ [
+ {
+ quoteLineId: lineId,
+ unitPrice,
+ leadTime: leadTime ?? 0,
+ discountPercent: discount,
+ quantity,
+ createdBy: userId,
+ priceSource: "manual"
+ }
+ ]
+ );
+ if (priceResult.error) {
+ summary.errors.push({
+ row: index,
+ reason: `Line created but pricing failed: ${priceResult.error.message}`,
+ values: record
+ });
+ }
}
}
}
diff --git a/packages/locale/locales/de/erp.po b/packages/locale/locales/de/erp.po
index 625b1e32f5..1a76456273 100644
--- a/packages/locale/locales/de/erp.po
+++ b/packages/locale/locales/de/erp.po
@@ -10164,9 +10164,6 @@ msgstr "Angebote"
msgid "Quotes with Lines"
msgstr "Angebote mit Zeilen"
-msgid "Quoting"
-msgstr "Angebotserstellung"
-
msgid "Quoting and sales orders"
msgstr "Angebote und Aufträge"
diff --git a/packages/locale/locales/en/erp.po b/packages/locale/locales/en/erp.po
index ceeeec6f60..59303b28c7 100644
--- a/packages/locale/locales/en/erp.po
+++ b/packages/locale/locales/en/erp.po
@@ -10164,9 +10164,6 @@ msgstr "Quotes"
msgid "Quotes with Lines"
msgstr "Quotes with Lines"
-msgid "Quoting"
-msgstr "Quoting"
-
msgid "Quoting and sales orders"
msgstr "Quoting and sales orders"
diff --git a/packages/locale/locales/es/erp.po b/packages/locale/locales/es/erp.po
index fe829e0f3c..69dcf9a00a 100644
--- a/packages/locale/locales/es/erp.po
+++ b/packages/locale/locales/es/erp.po
@@ -10164,9 +10164,6 @@ msgstr "Cotizaciones"
msgid "Quotes with Lines"
msgstr "Cotizaciones con Líneas"
-msgid "Quoting"
-msgstr "Cotización"
-
msgid "Quoting and sales orders"
msgstr "Presupuestos y pedidos de venta"
diff --git a/packages/locale/locales/fr/erp.po b/packages/locale/locales/fr/erp.po
index afb6061d7b..8b9b410306 100644
--- a/packages/locale/locales/fr/erp.po
+++ b/packages/locale/locales/fr/erp.po
@@ -10164,9 +10164,6 @@ msgstr "Devis"
msgid "Quotes with Lines"
msgstr "Devis avec lignes"
-msgid "Quoting"
-msgstr "Devis"
-
msgid "Quoting and sales orders"
msgstr "Devis et commandes de vente"
diff --git a/packages/locale/locales/hi/erp.po b/packages/locale/locales/hi/erp.po
index 88e97b48d2..650f835fde 100644
--- a/packages/locale/locales/hi/erp.po
+++ b/packages/locale/locales/hi/erp.po
@@ -10164,9 +10164,6 @@ msgstr "उद्धरण"
msgid "Quotes with Lines"
msgstr "पंक्तियों के साथ उद्धरण"
-msgid "Quoting"
-msgstr "उद्धरण"
-
msgid "Quoting and sales orders"
msgstr "उद्धरण और बिक्रय आदेश"
diff --git a/packages/locale/locales/it/erp.po b/packages/locale/locales/it/erp.po
index e03c595610..17ccc66805 100644
--- a/packages/locale/locales/it/erp.po
+++ b/packages/locale/locales/it/erp.po
@@ -10164,9 +10164,6 @@ msgstr "Preventivi"
msgid "Quotes with Lines"
msgstr "Preventivi con Righe"
-msgid "Quoting"
-msgstr "Quotazione"
-
msgid "Quoting and sales orders"
msgstr "Preventivi e ordini di vendita"
diff --git a/packages/locale/locales/ja/erp.po b/packages/locale/locales/ja/erp.po
index 7757367a0c..9313943d01 100644
--- a/packages/locale/locales/ja/erp.po
+++ b/packages/locale/locales/ja/erp.po
@@ -10164,9 +10164,6 @@ msgstr "見積"
msgid "Quotes with Lines"
msgstr "明細付き見積"
-msgid "Quoting"
-msgstr "見積"
-
msgid "Quoting and sales orders"
msgstr "見積と販売注文"
diff --git a/packages/locale/locales/ko/erp.po b/packages/locale/locales/ko/erp.po
index c0e8ae14d7..ba8f7d4153 100644
--- a/packages/locale/locales/ko/erp.po
+++ b/packages/locale/locales/ko/erp.po
@@ -10164,9 +10164,6 @@ msgstr "견적"
msgid "Quotes with Lines"
msgstr "라인이 포함된 견적"
-msgid "Quoting"
-msgstr "견적"
-
msgid "Quoting and sales orders"
msgstr "견적 및 판매주문"
diff --git a/packages/locale/locales/pl/erp.po b/packages/locale/locales/pl/erp.po
index d344c4e329..d82cccb669 100644
--- a/packages/locale/locales/pl/erp.po
+++ b/packages/locale/locales/pl/erp.po
@@ -10164,9 +10164,6 @@ msgstr "Oferty"
msgid "Quotes with Lines"
msgstr "Oferty z pozycjami"
-msgid "Quoting"
-msgstr "Wycena"
-
msgid "Quoting and sales orders"
msgstr "Wycena i zamówienia sprzedaży"
diff --git a/packages/locale/locales/pt/erp.po b/packages/locale/locales/pt/erp.po
index 6d209e338f..a4b6e53591 100644
--- a/packages/locale/locales/pt/erp.po
+++ b/packages/locale/locales/pt/erp.po
@@ -10162,10 +10162,7 @@ msgid "Quotes"
msgstr "Orçamentos"
msgid "Quotes with Lines"
-msgstr "Cotações com Linhas"
-
-msgid "Quoting"
-msgstr "Cotação"
+msgstr "Orçamentos com Linhas"
msgid "Quoting and sales orders"
msgstr "Cotação e pedidos de venda"
diff --git a/packages/locale/locales/ru/erp.po b/packages/locale/locales/ru/erp.po
index 2233df3fe3..18b17ffd5f 100644
--- a/packages/locale/locales/ru/erp.po
+++ b/packages/locale/locales/ru/erp.po
@@ -10164,9 +10164,6 @@ msgstr "Предложения"
msgid "Quotes with Lines"
msgstr "Предложения со строками"
-msgid "Quoting"
-msgstr "Котировка"
-
msgid "Quoting and sales orders"
msgstr "Котировки и заказы на продажу"
diff --git a/packages/locale/locales/tr/erp.po b/packages/locale/locales/tr/erp.po
index 03a963ab27..011da31880 100644
--- a/packages/locale/locales/tr/erp.po
+++ b/packages/locale/locales/tr/erp.po
@@ -10164,9 +10164,6 @@ msgstr "Teklifler"
msgid "Quotes with Lines"
msgstr "Satırlı Teklifler"
-msgid "Quoting"
-msgstr "Teklif Verme"
-
msgid "Quoting and sales orders"
msgstr "Teklifler ve satış siparişleri"
diff --git a/packages/locale/locales/zh/erp.po b/packages/locale/locales/zh/erp.po
index 9cc2cc759e..c11aceba62 100644
--- a/packages/locale/locales/zh/erp.po
+++ b/packages/locale/locales/zh/erp.po
@@ -10164,9 +10164,6 @@ msgstr "报价"
msgid "Quotes with Lines"
msgstr "带报价行的报价单"
-msgid "Quoting"
-msgstr "报价"
-
msgid "Quoting and sales orders"
msgstr "报价和销售订单"