@atomsolution/sdk-merchant 1.6.10 → 1.6.12
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.
- package/dist/batch-product-creation/components/merchant-batch-create-form/merge-and-check-data.d.ts +1 -1
- package/dist/batch-product-creation.cjs +52 -26
- package/dist/batch-product-creation.cjs.map +1 -1
- package/dist/batch-product-creation.esm.js +52 -26
- package/dist/batch-product-creation.esm.js.map +1 -1
- package/dist/batch-product-creation.js +52 -26
- package/dist/batch-product-creation.js.map +1 -1
- package/dist/style.css +3 -15
- package/package.json +1 -1
|
@@ -26830,16 +26830,8 @@ function MergeAndCheckData({ taxDeductionMethod }) {
|
|
|
26830
26830
|
} = useUploadStore();
|
|
26831
26831
|
const normalize = (str) => str.replace(/\r?\n|\r|\t/g, "").trim();
|
|
26832
26832
|
let sheetHeaders = sheetData[0] || [];
|
|
26833
|
-
sheetHeaders = sheetHeaders.map(
|
|
26834
|
-
|
|
26835
|
-
);
|
|
26836
|
-
const {
|
|
26837
|
-
mappings,
|
|
26838
|
-
setMappings,
|
|
26839
|
-
defaultMappings,
|
|
26840
|
-
setDefaultMappings,
|
|
26841
|
-
resetMappings
|
|
26842
|
-
} = useMappingStore();
|
|
26833
|
+
sheetHeaders = sheetHeaders.map((h) => typeof h === "string" ? normalize(h) : h);
|
|
26834
|
+
const { mappings, setMappings, defaultMappings, setDefaultMappings, resetMappings } = useMappingStore();
|
|
26843
26835
|
const isMappableField = (field) => !EXCLUDED_SYSTEM_FIELDS.includes(field);
|
|
26844
26836
|
React.useEffect(() => {
|
|
26845
26837
|
if (sheetHeaders.length > 0 && Object.keys(defaultMappings).length === 0) {
|
|
@@ -26874,9 +26866,7 @@ function MergeAndCheckData({ taxDeductionMethod }) {
|
|
|
26874
26866
|
if (taxNumber === 0) {
|
|
26875
26867
|
priceBeforeTax = Math.round(priceAfterTaxNumber);
|
|
26876
26868
|
} else {
|
|
26877
|
-
priceBeforeTax = Math.round(
|
|
26878
|
-
priceAfterTaxNumber / (1 + taxNumber / 100)
|
|
26879
|
-
);
|
|
26869
|
+
priceBeforeTax = Math.round(priceAfterTaxNumber / (1 + taxNumber / 100));
|
|
26880
26870
|
}
|
|
26881
26871
|
}
|
|
26882
26872
|
return {
|
|
@@ -27008,17 +26998,51 @@ function MergeAndCheckData({ taxDeductionMethod }) {
|
|
|
27008
26998
|
] })
|
|
27009
26999
|
] }),
|
|
27010
27000
|
/* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx("div", { className: "w-full px-4 py-4 max-h-[540px] overflow-auto rounded bg-[#F9FAFB]", children: /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx("div", { className: "rounded-xl p-4 bg-white", children: /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsxs("table", { className: "min-w-full text-xs border-separate border-spacing-0", children: [
|
|
27011
|
-
/* @__PURE__ */ jsxRuntime.jsxRuntimeExports.
|
|
27012
|
-
|
|
27013
|
-
|
|
27014
|
-
|
|
27015
|
-
|
|
27016
|
-
|
|
27017
|
-
|
|
27001
|
+
/* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx("colgroup", { children: (() => {
|
|
27002
|
+
const propMap = {
|
|
27003
|
+
0: "code",
|
|
27004
|
+
1: "name",
|
|
27005
|
+
2: "priceBeforeTax",
|
|
27006
|
+
3: "tax",
|
|
27007
|
+
4: "priceAfterTax",
|
|
27008
|
+
5: "unit",
|
|
27009
|
+
6: "category"
|
|
27010
|
+
};
|
|
27011
|
+
const getCellString = (row, fieldIndex) => {
|
|
27012
|
+
const prop = propMap[fieldIndex];
|
|
27013
|
+
if (!prop) return "";
|
|
27014
|
+
const val = row[prop];
|
|
27015
|
+
if (fieldIndex === 2 || fieldIndex === 4) {
|
|
27016
|
+
return typeof val === "number" ? formatVND(val) : String(val != null ? val : "");
|
|
27017
|
+
}
|
|
27018
|
+
if (fieldIndex === 3) {
|
|
27019
|
+
return typeof val === "number" ? val + "%" : String(val != null ? val : "");
|
|
27020
|
+
}
|
|
27021
|
+
return String(val != null ? val : "");
|
|
27022
|
+
};
|
|
27023
|
+
const columnWeights = visibleSystemFields.map((field) => {
|
|
27024
|
+
const fieldIndex = systemFields.indexOf(field);
|
|
27025
|
+
let maxLen = field.length;
|
|
27026
|
+
filteredRows.forEach((row) => {
|
|
27027
|
+
const cellStr = getCellString(row, fieldIndex);
|
|
27028
|
+
if (cellStr.length > maxLen) {
|
|
27029
|
+
maxLen = cellStr.length;
|
|
27030
|
+
}
|
|
27031
|
+
});
|
|
27032
|
+
let weight = Math.sqrt(maxLen);
|
|
27033
|
+
if (fieldIndex === 0 || fieldIndex === 1) weight *= 1.2;
|
|
27034
|
+
return weight;
|
|
27035
|
+
});
|
|
27036
|
+
const totalWeight = columnWeights.reduce((a2, b) => a2 + b, 0);
|
|
27037
|
+
return visibleSystemFields.map((_, index2) => {
|
|
27038
|
+
const width = `${columnWeights[index2] / totalWeight * 100}%`;
|
|
27039
|
+
return /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx("col", { style: { width } }, index2);
|
|
27040
|
+
});
|
|
27041
|
+
})() }),
|
|
27018
27042
|
/* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx("thead", { children: /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx("tr", { children: visibleSystemFields.map((field) => /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx(
|
|
27019
27043
|
"th",
|
|
27020
27044
|
{
|
|
27021
|
-
className: "px-2 py-3 text-left font-semibold text-[14px] text-[#475467] border-b",
|
|
27045
|
+
className: "px-2 py-3 text-left font-semibold text-[14px] text-[#475467] border-b whitespace-nowrap",
|
|
27022
27046
|
children: field
|
|
27023
27047
|
},
|
|
27024
27048
|
field
|
|
@@ -29343,14 +29367,18 @@ const CreateProductConfirmModal = ({
|
|
|
29343
29367
|
setLoading(true);
|
|
29344
29368
|
const formattedProducts = checkedProducts.map((product) => {
|
|
29345
29369
|
var _a;
|
|
29346
|
-
|
|
29370
|
+
calcPriceBeforeTax(
|
|
29347
29371
|
product.priceAfterTax,
|
|
29348
29372
|
product.tax
|
|
29349
29373
|
);
|
|
29350
29374
|
return __spreadValues({
|
|
29351
29375
|
code: product.code,
|
|
29352
29376
|
name: product.name,
|
|
29353
|
-
price:
|
|
29377
|
+
price: product.priceAfterTax,
|
|
29378
|
+
// price:
|
|
29379
|
+
// taxDeductionMethod === "direct"
|
|
29380
|
+
// ? product.priceAfterTax
|
|
29381
|
+
// : priceBeforeTax ?? 0,
|
|
29354
29382
|
img: product.img || "",
|
|
29355
29383
|
unit: product.unit,
|
|
29356
29384
|
cost: 0,
|
|
@@ -29360,9 +29388,7 @@ const CreateProductConfirmModal = ({
|
|
|
29360
29388
|
}, taxDeductionMethod === "credit" ? { price_after_vat: (_a = product.priceAfterTax) != null ? _a : 0 } : {});
|
|
29361
29389
|
});
|
|
29362
29390
|
try {
|
|
29363
|
-
const response = yield createProductsService.createProducts(
|
|
29364
|
-
formattedProducts
|
|
29365
|
-
);
|
|
29391
|
+
const response = yield createProductsService.createProducts(formattedProducts);
|
|
29366
29392
|
index.CustomToast.success(
|
|
29367
29393
|
translate("toast_success_title"),
|
|
29368
29394
|
translate("toast_create_products_success")
|