Skip to content

Commit

Permalink
fix(update-stock): check doc to request horus
Browse files Browse the repository at this point in the history
  • Loading branch information
wisley7l committed Jul 18, 2024
1 parent ba153ff commit 426659b
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions functions/lib/cron-events-horus.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,13 @@ const checkProductsImports = async ({ appSdk, storeId }, horus, opts) => {
}

const productsStocksEvents = async (horus, storeId, opts) => {
// const field = ''
let dateInit = new Date(releaseDate)
const dateEnd = new Date()
const resourcePrefix = 'products_stocks'
let dateInit = new Date(releaseDate)
let dateEnd = new Date()

let offset = 0
const limit = 50

const docRef = firestore()
.doc(`${collectionHorusEvents}/${storeId}_${resourcePrefix}`)

Expand All @@ -85,8 +88,14 @@ const productsStocksEvents = async (horus, storeId, opts) => {
const dateEndtDoc = data?.dateEnd
const offsetDoc = data?.offset
const hasRepeatDoc = data?.hasRepeat

console.log('>> doc ', dateEndtDoc, dateInitDoc, offsetDoc, hasRepeatDoc)
dateInit = dateInitDoc ? new Date(dateInitDoc) : dateInit

if (hasRepeatDoc) {
dateInit = dateInitDoc ? new Date(dateInitDoc) : dateInit
dateEnd = dateEndtDoc ? new Date(dateEndtDoc) : dateEnd
offset = offsetDoc || 0
}
}
const companyCode = opts.appData?.company_code || 1
const subsidiaryCode = opts.appData?.subsidiary_code || 1
Expand All @@ -109,8 +118,6 @@ const productsStocksEvents = async (horus, storeId, opts) => {
console.log(' Query: ', query)

let hasRepeat = true
let offset = 0
const limit = 50

let total = 0
// const init = Date.now()
Expand Down

0 comments on commit 426659b

Please sign in to comment.