aaro-scripts
Advanced tools
Comparing version 1.0.8 to 1.0.9
@@ -1,3 +0,6 @@ | ||
const getAllProducts = require("./sections/stock/stockScripts"); | ||
const { | ||
getAllProducts, | ||
getAllSales, | ||
} = require("./sections/stock/stockScripts"); | ||
const { | ||
getAllPriceListItems, | ||
@@ -19,2 +22,3 @@ showPassiveItemsOnPriceList, | ||
getAllData, | ||
getAllSales, | ||
}; |
{ | ||
"name": "aaro-scripts", | ||
"version": "1.0.8", | ||
"version": "1.0.9", | ||
"description": "Useful scripts for aaro erp", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -42,2 +42,52 @@ const { sleep } = require("../helpers/sleep"); | ||
module.exports = getAllProducts; | ||
/** | ||
* @description It retrieves all the sales between two dates | ||
* @param {object} aaro authorized object | ||
* @param {string} date1 for starting date, like "2021-07-01" | ||
* @param {string} date2 for ending date, like "2021-07-25" | ||
* @param {object} TipID for sales, default 10005 | ||
* @param {object} params extra params for limitations like DepoID:11 | ||
* @returns {array} | ||
*/ | ||
const getAllSales = async (aaro, date1, date2, TipID = 10005, params = {}) => { | ||
try { | ||
const sales = []; | ||
let page = 1; | ||
let currentPage = await aaro | ||
.get("StokHareketleri", { | ||
Sayfa: page, | ||
TarihBas: date1, | ||
TarihBit: date2, | ||
TipID, | ||
SayfaSatirSayisi: 100, | ||
...params, | ||
}) | ||
.then((response) => response.data); | ||
currentPage.Model.forEach((el) => sales.push(el)); | ||
while (currentPage.SayfalandirmaBilgisi.SonrakiSayfaVarMi) { | ||
page += 1; | ||
currentPage = await aaro | ||
.get("StokHareketleri", { | ||
Sayfa: page, | ||
SayfaSatirSayisi: 100, | ||
TarihBas: date1, | ||
TarihBit: date2, | ||
TipID, | ||
...params, | ||
}) | ||
.then((response) => response.data); | ||
currentPage.Model.forEach((el) => sales.push(el)); | ||
await sleep(200); | ||
} | ||
return sales; | ||
} catch (err) { | ||
throw err; | ||
} | ||
}; | ||
module.exports = { | ||
getAllProducts, | ||
getAllSales, | ||
}; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
11088
324