@atomsolution/sdk-merchant 1.6.9 → 1.6.11

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.
@@ -29318,6 +29318,17 @@ const createProductsService = {
29318
29318
  );
29319
29319
  })
29320
29320
  };
29321
+ const calcPriceBeforeTax = (priceAfterTax, tax) => {
29322
+ if (priceAfterTax === "" || priceAfterTax === null || priceAfterTax === void 0 || tax === "" || tax === null || tax === void 0) {
29323
+ return void 0;
29324
+ }
29325
+ const priceAfterTaxNumber = Number(priceAfterTax);
29326
+ const taxNumber = Number(tax);
29327
+ if (!Number.isFinite(priceAfterTaxNumber) || !Number.isFinite(taxNumber)) {
29328
+ return void 0;
29329
+ }
29330
+ return Math.round(priceAfterTaxNumber / (1 + taxNumber / 100));
29331
+ };
29321
29332
  const CreateProductConfirmModal = ({
29322
29333
  checkedProducts,
29323
29334
  numCheckedProducts,
@@ -29331,23 +29342,29 @@ const CreateProductConfirmModal = ({
29331
29342
  const handleCreateProducts = () => __async(exports, null, function* () {
29332
29343
  setLoading(true);
29333
29344
  const formattedProducts = checkedProducts.map((product) => {
29334
- var _a, _b;
29345
+ var _a;
29346
+ calcPriceBeforeTax(
29347
+ product.priceAfterTax,
29348
+ product.tax
29349
+ );
29335
29350
  return __spreadValues({
29336
29351
  code: product.code,
29337
29352
  name: product.name,
29338
- price: taxDeductionMethod === "direct" ? product.priceAfterTax : (_a = product.priceBeforeTax) != null ? _a : 0,
29353
+ price: product.priceAfterTax,
29354
+ // price:
29355
+ // taxDeductionMethod === "direct"
29356
+ // ? product.priceAfterTax
29357
+ // : priceBeforeTax ?? 0,
29339
29358
  img: product.img || "",
29340
29359
  unit: product.unit,
29341
29360
  cost: 0,
29342
29361
  tax: taxDeductionMethod === "direct" ? 0 : product.tax,
29343
29362
  status: 0,
29344
29363
  category_names: product.category
29345
- }, taxDeductionMethod === "credit" ? { price_after_vat: (_b = product.priceAfterTax) != null ? _b : 0 } : {});
29364
+ }, taxDeductionMethod === "credit" ? { price_after_vat: (_a = product.priceAfterTax) != null ? _a : 0 } : {});
29346
29365
  });
29347
29366
  try {
29348
- const response = yield createProductsService.createProducts(
29349
- formattedProducts
29350
- );
29367
+ const response = yield createProductsService.createProducts(formattedProducts);
29351
29368
  index.CustomToast.success(
29352
29369
  translate("toast_success_title"),
29353
29370
  translate("toast_create_products_success")