foodbot-cart-calculations 1.0.70 → 1.0.72

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.
@@ -1091,7 +1091,7 @@ function applyDiscountModifierPromotion(cartObject, offer) {
1091
1091
  eligibleUnits.sort((a, b) => a.price - b.price);
1092
1092
 
1093
1093
  // 4. Apply Discount up to Max Limit
1094
- const maxLimit = offer.max_quantity || 1;
1094
+ const maxLimit = offer.en_id ? (offer.max_product || 1) : (offer.max_quantity || 1);
1095
1095
  const discountValue = offer.oo_offer_value; // e.g., 100 for 100%
1096
1096
  const unitsToDiscount = eligibleUnits.slice(0, maxLimit);
1097
1097
 
package/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  const calculation = require('./calculations');
2
2
  const { calculateItemWiseSplit, calculateHalfSplit } = require('./functions/taxCalculation');
3
- // const fs = require('fs');
4
- // const path = require('path')
3
+ const fs = require('fs');
4
+ const path = require('path')
5
5
 
6
6
  async function calculateTax(inputJSON) {
7
7
  return new Promise(async (resolve, reject) => {
@@ -76,24 +76,24 @@ async function calculateTax(inputJSON) {
76
76
  })
77
77
  }
78
78
 
79
- // let json = JSON.parse(fs.readFileSync('./sample.json', 'utf8'));
80
- // calculateTax(json).then(res=>{
81
- // // console.log(JSON.stringify(res))
79
+ let json = JSON.parse(fs.readFileSync('./sample.json', 'utf8'));
80
+ calculateTax(json).then(res=>{
81
+ // console.log(JSON.stringify(res))
82
82
 
83
- // const jsonResponse = JSON.stringify(res, null, 2); // Format the JSON with indentation
84
- // const filePath = path.join(__dirname, 'response.json'); // File path in the same directory
83
+ const jsonResponse = JSON.stringify(res, null, 2); // Format the JSON with indentation
84
+ const filePath = path.join(__dirname, 'response.json'); // File path in the same directory
85
85
 
86
- // fs.writeFile(filePath, jsonResponse, 'utf8', err => {
87
- // if (err) {
88
- // console.error('Error writing to file:', err);
89
- // } else {
90
- // console.log('Response successfully written to response.json');
91
- // }
92
- // });
86
+ fs.writeFile(filePath, jsonResponse, 'utf8', err => {
87
+ if (err) {
88
+ console.error('Error writing to file:', err);
89
+ } else {
90
+ console.log('Response successfully written to response.json');
91
+ }
92
+ });
93
93
 
94
- // }).catch(err=>{
95
- // console.log(err)
96
- // })
94
+ }).catch(err=>{
95
+ console.log(err)
96
+ })
97
97
 
98
98
  // calculateItemWiseSplit(json).then(res=>{
99
99
  // // console.log(JSON.stringify(res))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "foodbot-cart-calculations",
3
- "version": "1.0.70",
3
+ "version": "1.0.72",
4
4
  "description": "Package for cart calculations in which it performs discount distribution and tax distribution on order",
5
5
  "main": "index.js",
6
6
  "scripts": {