Skip to content

Commit

Permalink
fix(update-stock): update dateInit if not repeat
Browse files Browse the repository at this point in the history
  • Loading branch information
wisley7l committed Jul 18, 2024
1 parent 426659b commit ddf9f01
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions functions/lib/cron-events-horus.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,14 @@ const productsStocksEvents = async (horus, storeId, opts) => {
const offsetDoc = data?.offset
const hasRepeatDoc = data?.hasRepeat

console.log('>> doc ', dateEndtDoc, dateInitDoc, offsetDoc, hasRepeatDoc)
console.log('>> doc ', dateEndtDoc, dateInitDoc, offsetDoc, hasRepeatDoc, ' ', typeof storeId)

if (hasRepeatDoc) {
dateInit = dateInitDoc ? new Date(dateInitDoc) : dateInit
dateEnd = dateEndtDoc ? new Date(dateEndtDoc) : dateEnd
offset = offsetDoc || 0
} else {
dateInit = dateEndtDoc ? new Date(dateEndtDoc) : dateEnd
}
}
const companyCode = opts.appData?.company_code || 1
Expand All @@ -107,8 +109,6 @@ const productsStocksEvents = async (horus, storeId, opts) => {
const codCaract = opts?.appData?.code_characteristic || 5
const codTpoCaract = opts?.appData?.code_type_characteristic || 3

if (!dateEnd || !dateInit) return

console.log(`>> Check STOCKS ${parseDate(dateInit, true)} at ${parseDate(dateEnd, true)}`)
const query = `?DATA_INI=${parseDate(dateInit, true)}&DATA_FIM=${parseDate(dateEnd, true)}` +
`&COD_TPO_CARACT=${codTpoCaract}&COD_CARACT=${codCaract}` +
Expand Down

0 comments on commit ddf9f01

Please sign in to comment.