generalbots/bottemplates/bling.gbai/bling.gbdialog/sync-inventory.bas
Rodrigo Rodriguez (Pragmatismo) 037db5c381 feat: Major workspace reorganization and documentation update
- Add comprehensive documentation in botbook/ with 12 chapters
- Add botapp/ Tauri desktop application
- Add botdevice/ IoT device support
- Add botlib/ shared library crate
- Add botmodels/ Python ML models service
- Add botplugin/ browser extension
- Add botserver/ reorganized server code
- Add bottemplates/ bot templates
- Add bottest/ integration tests
- Add botui/ web UI server
- Add CI/CD workflows in .forgejo/workflows/
- Add AGENTS.md and PROD.md documentation
- Add dependency management scripts (DEPENDENCIES.sh/ps1)
- Remove legacy src/ structure and migrations
- Clean up temporary and backup files
2026-04-19 08:14:25 -03:00

60 lines
1.3 KiB
QBasic

SET SCHEDULE "0 30 23 * * *"
SEND EMAIL admin, "Inventory sync started..."
fullList = FIND ".Produtos"
chunkSize = 100
startIndex = 0
DO WHILE startIndex < ubound(fullList)
list = mid(fullList, startIndex, chunkSize)
prd1 = ""
j = 0
items = NEW ARRAY
DO WHILE j < ubound(list)
produto_id = list[j].id
prd1 = prd1 + "&idsProdutos%5B%5D=" + produto_id
j = j + 1
LOOP
list = null
IF j > 0 THEN
res = GET host + "/estoques/saldos?${prd1}"
WAIT 0.33
items = res.data
res = null
k = 0
DO WHILE k < ubound(items)
depositos = items[k].depositos
pSku = FIND ".Produtos", "id=${items[k].produto.id}"
IF pSku THEN
prdSku = pSku.sku
DELETE ".Depositos", "Sku=" + prdSku
l = 0
DO WHILE l < ubound(depositos)
depositos[l].sku = prdSku
l = l + 1
LOOP
SAVE ".Depositos", depositos
depositos = null
END IF
pSku = null
k = k + 1
LOOP
items = null
END IF
startIndex = startIndex + chunkSize
items = null
LOOP
fullList = null
SEND EMAIL admin, "Inventory sync completed."