فینورا پرو - سامانه جامع حسابداری و صدور فاکتور

fix(a02): preserve fractional reorder quantities separately from integer rial amounts

davoodmehraban89 committed Oct 31, 2026 at 06:49 UTC 928f4109813035c5652f3977730332852e741bcd
1 file changed +17 -1
src/controllers/ExcelController.js
+17 -1
@@ -38,6 +38,22 @@ function excelRial(value, field) {
38 return amount;
39 }
40
41 +// Stock reorder thresholds are quantities, not rial. Fractional stock
42 +// quantities (for example 2.5 kg) are valid and must survive Excel import.
43 +function excelQuantity(value) {
44 + if (value === null || value === undefined || value === '') return 0;
45 + const ascii = String(value)
46 + .replace(/[۰-۹]/g, c => String(c.charCodeAt(0) - 1776))
47 + .replace(/[٠-٩]/g, c => String(c.charCodeAt(0) - 1632))
48 + .replace(/[,\s،٬]/g, '');
49 + const amount = Number(ascii);
50 + if (!/^\d+(?:\.\d+)?$/.test(ascii) || !Number.isFinite(amount) ||
51 + amount < 0 || amount > Number.MAX_SAFE_INTEGER) {
52 + throw new Error('نقطه سفارش کالا مقدار نامعتبر دارد');
53 + }
54 + return amount;
55 +}
56 +
57 class ExcelControllerImpl {
58 // ============================================================
59 // ذخیره فایل + نمایش پیام + باز کردن خودکار (سازگار با Tauri)
@@ -507,7 +523,7 @@ class ExcelControllerImpl {
523 unitId: null, categoryId: null,
524 buyPrice: excelRial(row['قیمت خرید'] ?? row['قیمت خرید (ریال)'], 'قیمت خرید'),
525 sellPrice: excelRial(row['قیمت فروش'] ?? row['قیمت فروش (ریال)'], 'قیمت فروش'),
510 - minStock: excelRial(row['نقطه سفارش'], 'نقطه سفارش'),
526 + minStock: excelQuantity(row['نقطه سفارش']),
527 trackInventory: !String(row['نوع'] || '').includes('خدمت'),
528 isActiveSell: true, isActiveBuy: true, description: '',
529 createdAt: now, updatedAt: now