Compare commits

...

No commits in common. "3595e5ff641db788d0b23ae7c422ffd875694222" and "1ce32959d2c16ee7d05aaa8b81e51de19f3ccaa3" have entirely different histories.

26 changed files with 1108 additions and 435 deletions

View file

@ -4,11 +4,11 @@ PARAM qtd AS INTEGER LIKE 10 DESCRIPTION "Quantity to add to stock"
DESCRIPTION "Add stock quantity for a product by SKU" DESCRIPTION "Add stock quantity for a product by SKU"
person = FIND "People.xlsx", "id=" + mobile person = FIND "People.xlsx", "id=" + mobile
vendor = FIND "maria.Vendedores", "id=" + person.erpId vendor = FIND ".Vendedores", "id=" + person.erpId
TALK "Olá " + vendor.Contato_Nome + "!" TALK "Olá " + vendor.Contato_Nome + "!"
produto = FIND "maria.Produtos", "sku=" + sku produto = FIND ".Produtos", "sku=" + sku
IF NOT produto THEN IF NOT produto THEN
TALK "Produto não encontrado." TALK "Produto não encontrado."

View file

@ -20,7 +20,7 @@ DO WHILE page > 0 AND page <= pages
itemCount = UBOUND(items) itemCount = UBOUND(items)
IF itemCount > 0 THEN IF itemCount > 0 THEN
MERGE "maria.ContasAReceber" WITH items BY "Id" MERGE ".ContasAReceber" WITH items BY "Id"
totalReceber = totalReceber + itemCount totalReceber = totalReceber + itemCount
page = page + 1 page = page + 1
@ -56,7 +56,7 @@ DO WHILE page > 0 AND page <= pages
itemCount = UBOUND(items) itemCount = UBOUND(items)
IF itemCount > 0 THEN IF itemCount > 0 THEN
MERGE "maria.ContasAPagar" WITH items BY "Id" MERGE ".ContasAPagar" WITH items BY "Id"
totalPagar = totalPagar + itemCount totalPagar = totalPagar + itemCount
page = page + 1 page = page + 1

View file

@ -42,7 +42,7 @@ DO WHILE i > 0 AND i < pages
produto.hierarquia = "s" produto.hierarquia = "s"
END IF END IF
produtoDB = FIND "maria.Produtos", "sku=" + produto.codigo produtoDB = FIND ".Produtos", "sku=" + produto.codigo
IF produtoDB THEN IF produtoDB THEN
IF produtoDB.preco <> produto.preco THEN IF produtoDB.preco <> produto.preco THEN
hist = NEW OBJECT hist = NEW OBJECT
@ -51,7 +51,7 @@ DO WHILE i > 0 AND i < pages
hist.precoAtual = produto.preco hist.precoAtual = produto.preco
hist.produto_id = produto.id hist.produto_id = produto.id
hist.dataModificado = FORMAT today, "yyyy-MM-dd" hist.dataModificado = FORMAT today, "yyyy-MM-dd"
SAVE "maria.HistoricoPreco", hist SAVE ".HistoricoPreco", hist
hist = null hist = null
END IF END IF
END IF END IF
@ -63,7 +63,7 @@ DO WHILE i > 0 AND i < pages
list = null list = null
list = items list = items
MERGE "maria.Produtos" WITH list BY "Id" MERGE ".Produtos" WITH list BY "Id"
list = items list = items
j = 0 j = 0
@ -86,7 +86,7 @@ DO WHILE i > 0 AND i < pages
k = 0 k = 0
DO WHILE k < ubound(listV) DO WHILE k < ubound(listV)
listV[k].hierarquia = 'f' listV[k].hierarquia = 'f'
DELETE "maria.ProdutoImagem", "sku=" + listV[k].sku DELETE ".ProdutoImagem", "sku=" + listV[k].sku
images = listV[k]?.midia?.imagens?.externas images = listV[k]?.midia?.imagens?.externas
l = 0 l = 0
@ -96,16 +96,16 @@ DO WHILE i > 0 AND i < pages
images[l].id = random() images[l].id = random()
l = l + 1 l = l + 1
LOOP LOOP
SAVE "maria.ProdutoImagem", images SAVE ".ProdutoImagem", images
images = null images = null
k = k + 1 k = k + 1
LOOP LOOP
MERGE "maria.Produtos" WITH listV BY "Id" MERGE ".Produtos" WITH listV BY "Id"
END IF END IF
listV = null listV = null
DELETE "maria.ProdutoImagem", "sku=" + list[j].sku DELETE ".ProdutoImagem", "sku=" + list[j].sku
k = 0 k = 0
images = list[j].midia?.imagens?.externas images = list[j].midia?.imagens?.externas
DO WHILE k < ubound(images) DO WHILE k < ubound(images)
@ -114,7 +114,7 @@ DO WHILE i > 0 AND i < pages
images[k].id = random() images[k].id = random()
k = k + 1 k = k + 1
LOOP LOOP
SAVE "maria.ProdutoImagem", images SAVE ".ProdutoImagem", images
j = j + 1 j = j + 1
LOOP LOOP
@ -155,7 +155,7 @@ DO WHILE i > 0 AND i < pages
items[k].custo = items[k].valor / 2 items[k].custo = items[k].valor / 2
k = k + 1 k = k + 1
LOOP LOOP
MERGE "maria.PedidosItem" WITH items BY "Id" MERGE ".PedidosItem" WITH items BY "Id"
items = res.data.parcelas items = res.data.parcelas
k = 0 k = 0
@ -163,14 +163,14 @@ DO WHILE i > 0 AND i < pages
items[k].pedido_id = pedido_id items[k].pedido_id = pedido_id
k = k + 1 k = k + 1
LOOP LOOP
MERGE "maria.Parcela" WITH items BY "Id" MERGE ".Parcela" WITH items BY "Id"
fullList[j] = res.data fullList[j] = res.data
res = null res = null
j = j + 1 j = j + 1
LOOP LOOP
MERGE "maria.Pedidos" WITH fullList BY "Id" MERGE ".Pedidos" WITH fullList BY "Id"
i = i + 1 i = i + 1
IF list?.length < limit THEN IF list?.length < limit THEN
i = 0 i = 0
@ -201,7 +201,7 @@ DO WHILE syncPage > 0 AND syncPage <= pages
syncCount = UBOUND(syncItems) syncCount = UBOUND(syncItems)
IF syncCount > 0 THEN IF syncCount > 0 THEN
MERGE "maria.CategoriaReceita" WITH syncItems BY "Id" MERGE ".CategoriaReceita" WITH syncItems BY "Id"
totalCategoria = totalCategoria + syncCount totalCategoria = totalCategoria + syncCount
syncPage = syncPage + 1 syncPage = syncPage + 1
@ -236,7 +236,7 @@ DO WHILE syncPage > 0 AND syncPage <= pages
syncCount = UBOUND(syncItems) syncCount = UBOUND(syncItems)
IF syncCount > 0 THEN IF syncCount > 0 THEN
MERGE "maria.FormaDePagamento" WITH syncItems BY "Id" MERGE ".FormaDePagamento" WITH syncItems BY "Id"
totalForma = totalForma + syncCount totalForma = totalForma + syncCount
syncPage = syncPage + 1 syncPage = syncPage + 1
@ -275,7 +275,7 @@ DO WHILE i > 0 AND i < pages
j = j + 1 j = j + 1
LOOP LOOP
MERGE "maria.Contatos" WITH items BY "Id" MERGE ".Contatos" WITH items BY "Id"
i = i + 1 i = i + 1
IF list?.length < limit THEN IF list?.length < limit THEN
i = 0 i = 0
@ -305,7 +305,7 @@ DO WHILE i > 0 AND i < pages
j = j + 1 j = j + 1
LOOP LOOP
MERGE "maria.Vendedores" WITH items BY "Id" MERGE ".Vendedores" WITH items BY "Id"
i = i + 1 i = i + 1
IF list?.length < limit THEN IF list?.length < limit THEN
i = 0 i = 0

View file

@ -2,7 +2,7 @@ SET SCHEDULE "0 30 23 * * *"
SEND EMAIL admin, "Inventory sync started..." SEND EMAIL admin, "Inventory sync started..."
fullList = FIND "maria.Produtos" fullList = FIND ".Produtos"
chunkSize = 100 chunkSize = 100
startIndex = 0 startIndex = 0
@ -30,11 +30,11 @@ DO WHILE startIndex < ubound(fullList)
k = 0 k = 0
DO WHILE k < ubound(items) DO WHILE k < ubound(items)
depositos = items[k].depositos depositos = items[k].depositos
pSku = FIND "maria.Produtos", "id=${items[k].produto.id}" pSku = FIND ".Produtos", "id=${items[k].produto.id}"
IF pSku THEN IF pSku THEN
prdSku = pSku.sku prdSku = pSku.sku
DELETE "maria.Depositos", "Sku=" + prdSku DELETE ".Depositos", "Sku=" + prdSku
l = 0 l = 0
DO WHILE l < ubound(depositos) DO WHILE l < ubound(depositos)
@ -42,7 +42,7 @@ DO WHILE startIndex < ubound(fullList)
l = l + 1 l = l + 1
LOOP LOOP
SAVE "maria.Depositos", depositos SAVE ".Depositos", depositos
depositos = null depositos = null
END IF END IF

View file

@ -5,7 +5,7 @@ DESCRIPTION "Sync product suppliers from Bling ERP to local database"
SEND EMAIL admin, "Suppliers sync started..." SEND EMAIL admin, "Suppliers sync started..."
FUNCTION SyncProdutoFornecedor(idProduto) FUNCTION SyncProdutoFornecedor(idProduto)
DELETE "maria.ProdutoFornecedor", "Produto_id=" + idProduto DELETE ".ProdutoFornecedor", "Produto_id=" + idProduto
i1 = 1 i1 = 1
DO WHILE i1 > 0 AND i1 < pages DO WHILE i1 > 0 AND i1 < pages
@ -26,7 +26,7 @@ FUNCTION SyncProdutoFornecedor(idProduto)
j1 = j1 + 1 j1 = j1 + 1
LOOP LOOP
SAVE "maria.ProdutoFornecedor", items1 SAVE ".ProdutoFornecedor", items1
items1 = null items1 = null
i1 = i1 + 1 i1 = i1 + 1
@ -38,7 +38,7 @@ FUNCTION SyncProdutoFornecedor(idProduto)
LOOP LOOP
END FUNCTION END FUNCTION
fullList = FIND "maria.Produtos" fullList = FIND ".Produtos"
chunkSize = 100 chunkSize = 100
startIndex = 0 startIndex = 0

View file

@ -1,4 +1,4 @@
TABLE Contatos ON maria TABLE Contatos
Id number key Id number key
Nome string(150) Nome string(150)
Codigo string(50) Codigo string(50)
@ -37,7 +37,7 @@ TABLE Contatos ON maria
Pais_nome string(100) Pais_nome string(100)
END TABLE END TABLE
TABLE Pedidos ON maria TABLE Pedidos
Id number key Id number key
Numero integer Numero integer
NumeroLoja string(15) NumeroLoja string(15)
@ -59,7 +59,7 @@ TABLE Pedidos ON maria
NotaFiscal_id number NotaFiscal_id number
END TABLE END TABLE
TABLE PedidosItem ON maria TABLE PedidosItem
Id number key Id number key
Numero integer Numero integer
Sku string(20) Sku string(20)
@ -75,14 +75,14 @@ TABLE PedidosItem ON maria
Pedido_id number Pedido_id number
END TABLE END TABLE
TABLE ProdutoImagem ON maria TABLE ProdutoImagem
Id number key Id number key
Ordinal number Ordinal number
Sku string(20) Sku string(20)
Link string(250) Link string(250)
END TABLE END TABLE
TABLE Produtos ON maria TABLE Produtos
Id number key Id number key
Nome string(150) Nome string(150)
Sku string(20) Sku string(20)
@ -146,7 +146,7 @@ TABLE Produtos ON maria
Estrutura_componentes_0_produto_Quantidade double Estrutura_componentes_0_produto_Quantidade double
END TABLE END TABLE
TABLE Depositos ON maria TABLE Depositos
Internal_Id number key Internal_Id number key
Id number Id number
Sku string(20) Sku string(20)
@ -154,7 +154,7 @@ TABLE Depositos ON maria
SaldoVirtual double SaldoVirtual double
END TABLE END TABLE
TABLE Vendedores ON maria TABLE Vendedores
Id number key Id number key
DescontoLimite double DescontoLimite double
Loja_Id number Loja_Id number
@ -163,7 +163,7 @@ TABLE Vendedores ON maria
Contato_Situacao string(1) Contato_Situacao string(1)
END TABLE END TABLE
TABLE ProdutoFornecedor ON maria TABLE ProdutoFornecedor
Id number key Id number key
Descricao string(255) Descricao string(255)
Codigo string(50) Codigo string(50)
@ -175,7 +175,7 @@ TABLE ProdutoFornecedor ON maria
Garantia integer Garantia integer
END TABLE END TABLE
TABLE ContasAPagar ON maria TABLE ContasAPagar
Id number key Id number key
Situacao integer Situacao integer
Vencimento date Vencimento date
@ -195,7 +195,7 @@ TABLE ContasAPagar ON maria
Ocorrencia_tipo integer Ocorrencia_tipo integer
END TABLE END TABLE
TABLE ContasAReceber ON maria TABLE ContasAReceber
Id number key Id number key
Situacao integer Situacao integer
Vencimento date Vencimento date
@ -232,7 +232,7 @@ TABLE ContasAReceber ON maria
Ocorrencia_tipo integer Ocorrencia_tipo integer
END TABLE END TABLE
TABLE CategoriaReceita ON maria TABLE CategoriaReceita
Id number key Id number key
IdCategoriaPai number IdCategoriaPai number
Descricao string(255) Descricao string(255)
@ -240,7 +240,7 @@ TABLE CategoriaReceita ON maria
Situacao integer Situacao integer
END TABLE END TABLE
TABLE FormaDePagamento ON maria TABLE FormaDePagamento
Id number key Id number key
Descricao string(255) Descricao string(255)
TipoPagamento integer TipoPagamento integer
@ -258,14 +258,14 @@ TABLE FormaDePagamento ON maria
DadosCartao_cnpjCredenciadora string(16) DadosCartao_cnpjCredenciadora string(16)
END TABLE END TABLE
TABLE NaturezaDeOperacao ON maria TABLE NaturezaDeOperacao
Id number key Id number key
Situacao integer Situacao integer
Padrao integer Padrao integer
Descricao string(255) Descricao string(255)
END TABLE END TABLE
TABLE Parcela ON maria TABLE Parcela
Id number key Id number key
Pedido_id number Pedido_id number
DataVencimento date DataVencimento date
@ -274,7 +274,7 @@ TABLE Parcela ON maria
FormaPagamento_id number FormaPagamento_id number
END TABLE END TABLE
TABLE HistoricoPreco ON maria TABLE HistoricoPreco
Id number key Id number key
Sku string(50) Sku string(50)
PrecoAntigo double PrecoAntigo double

View file

@ -0,0 +1,102 @@
PARAM expression AS STRING LIKE "2 + 2" DESCRIPTION "Mathematical expression to calculate"
DESCRIPTION "Calculate mathematical expressions, conversions, and formulas"
WITH result
expression = expression
timestamp = NOW()
END WITH
expr = REPLACE(expression, " ", "")
IF INSTR(expr, "+") > 0 THEN
parts = SPLIT(expr, "+")
IF UBOUND(parts) = 2 THEN
result.answer = VAL(parts[0]) + VAL(parts[1])
result.operation = "addition"
END IF
ELSE IF INSTR(expr, "-") > 0 AND LEFT(expr, 1) <> "-" THEN
parts = SPLIT(expr, "-")
IF UBOUND(parts) = 2 THEN
result.answer = VAL(parts[0]) - VAL(parts[1])
result.operation = "subtraction"
END IF
ELSE IF INSTR(expr, "*") > 0 THEN
parts = SPLIT(expr, "*")
IF UBOUND(parts) = 2 THEN
result.answer = VAL(parts[0]) * VAL(parts[1])
result.operation = "multiplication"
END IF
ELSE IF INSTR(expr, "/") > 0 THEN
parts = SPLIT(expr, "/")
IF UBOUND(parts) = 2 THEN
IF VAL(parts[1]) <> 0 THEN
result.answer = VAL(parts[0]) / VAL(parts[1])
result.operation = "division"
ELSE
TALK "Error: Division by zero"
RETURN NULL
END IF
END IF
ELSE IF INSTR(LCASE(expr), "sqrt") > 0 THEN
start_pos = INSTR(LCASE(expr), "sqrt(") + 5
end_pos = INSTR(start_pos, expr, ")")
IF end_pos > start_pos THEN
num = VAL(MID(expr, start_pos, end_pos - start_pos))
IF num >= 0 THEN
result.answer = SQR(num)
result.operation = "square root"
ELSE
TALK "Error: Cannot calculate square root of negative number"
RETURN NULL
END IF
END IF
ELSE IF INSTR(expr, "^") > 0 THEN
parts = SPLIT(expr, "^")
IF UBOUND(parts) = 2 THEN
result.answer = VAL(parts[0]) ^ VAL(parts[1])
result.operation = "power"
END IF
ELSE IF INSTR(LCASE(expr), "abs") > 0 THEN
start_pos = INSTR(LCASE(expr), "abs(") + 4
end_pos = INSTR(start_pos, expr, ")")
IF end_pos > start_pos THEN
result.answer = ABS(VAL(MID(expr, start_pos, end_pos - start_pos)))
result.operation = "absolute value"
END IF
ELSE IF INSTR(LCASE(expr), "round") > 0 THEN
start_pos = INSTR(LCASE(expr), "round(") + 6
end_pos = INSTR(start_pos, expr, ")")
IF end_pos > start_pos THEN
result.answer = ROUND(VAL(MID(expr, start_pos, end_pos - start_pos)), 0)
result.operation = "rounding"
END IF
ELSE IF INSTR(expr, "%") > 0 AND INSTR(LCASE(expr), "of") > 0 THEN
expr_lower = LCASE(expr)
of_pos = INSTR(expr_lower, "of")
percent_part = REPLACE(LEFT(expr, of_pos - 1), "%", "")
percent_val = VAL(TRIM(percent_part))
base_val = VAL(TRIM(MID(expr, of_pos + 2)))
result.answer = (percent_val / 100) * base_val
result.operation = "percentage"
ELSE
result.answer = VAL(expr)
result.operation = "direct value"
END IF
IF result.answer <> NULL THEN
TALK "Result: " + result.answer
RETURN result
ELSE
TALK "Could not calculate expression"
RETURN NULL
END IF

View file

@ -0,0 +1,26 @@
PARAM to_email AS EMAIL LIKE "user@example.com" DESCRIPTION "Recipient email address"
PARAM subject AS STRING LIKE "Important Message" DESCRIPTION "Email subject line"
PARAM body AS STRING LIKE "Hello, this is the email content." DESCRIPTION "Email body content"
PARAM from_email AS EMAIL LIKE "noreply@company.com" DESCRIPTION "Sender email address" OPTIONAL
DESCRIPTION "Send an email to any recipient with subject and body"
IF NOT from_email THEN
from_email = "noreply@pragmatismo.com.br"
END IF
WITH email_data
to = to_email
from = from_email
subject = subject
body = body
timestamp = NOW()
END WITH
SEND EMAIL to_email, subject, body
SAVE "email_log.csv", email_data
TALK "Email sent to " + to_email
RETURN email_data

View file

@ -0,0 +1,28 @@
PARAM phone_number AS PHONE LIKE "+1234567890" DESCRIPTION "Phone number with country code"
PARAM message AS STRING LIKE "Hello, this is your message" DESCRIPTION "SMS message content"
PARAM from_number AS PHONE LIKE "+1987654321" DESCRIPTION "Sender phone number" OPTIONAL
DESCRIPTION "Send an SMS message to any phone number"
message_length = LEN(message)
segments = INT((message_length - 1) / 160) + 1
IF message_length > 160 THEN
TALK "Message will be split into " + segments + " segments"
END IF
WITH sms
to = phone_number
from = from_number
body = message
timestamp = NOW()
segmentCount = segments
END WITH
SEND SMS phone_number, message
SAVE "sms_log.csv", sms
TALK "SMS sent to " + phone_number
RETURN sms

View file

@ -0,0 +1,60 @@
PARAM text AS STRING LIKE "Hello, how are you?" DESCRIPTION "Text to translate"
PARAM from_lang AS STRING LIKE "en" DESCRIPTION "Source language code (en, es, pt, fr, de, etc)" OPTIONAL
PARAM to_lang AS STRING LIKE "es" DESCRIPTION "Target language code (en, es, pt, fr, de, etc)" OPTIONAL
DESCRIPTION "Translate text between languages using free translation API"
IF NOT from_lang THEN
from_lang = "en"
END IF
IF NOT to_lang THEN
to_lang = "es"
END IF
TALK "Translating from " + from_lang + " to " + to_lang + "..."
WITH post_data
q = text
source = from_lang
target = to_lang
format = "text"
END WITH
SET HEADER "Content-Type" = "application/json"
translation_result = POST "https://libretranslate.com/translate", post_data
IF translation_result.translatedText THEN
WITH result
original = text
translated = translation_result.translatedText
from = from_lang
to = to_lang
END WITH
TALK "Original (" + from_lang + "): " + text
TALK "Translated (" + to_lang + "): " + result.translated
RETURN result
ELSE
mymemory_url = "https://api.mymemory.translated.net/get?q=" + text + "&langpair=" + from_lang + "|" + to_lang
fallback_result = GET mymemory_url
IF fallback_result.responseData.translatedText THEN
WITH result
original = text
translated = fallback_result.responseData.translatedText
from = from_lang
to = to_lang
END WITH
TALK "Original (" + from_lang + "): " + text
TALK "Translated (" + to_lang + "): " + result.translated
RETURN result
ELSE
TALK "Could not translate text"
RETURN NULL
END IF
END IF

View file

@ -0,0 +1,112 @@
PARAM location AS STRING LIKE "New York" DESCRIPTION "City or location to get weather forecast"
DESCRIPTION "Get current weather forecast for any city or location"
lat = 40.7128
lon = -74.0060
location_lower = LCASE(location)
IF INSTR(location_lower, "new york") > 0 THEN
lat = 40.7128
lon = -74.0060
ELSE IF INSTR(location_lower, "london") > 0 THEN
lat = 51.5074
lon = -0.1278
ELSE IF INSTR(location_lower, "paris") > 0 THEN
lat = 48.8566
lon = 2.3522
ELSE IF INSTR(location_lower, "tokyo") > 0 THEN
lat = 35.6762
lon = 139.6503
ELSE IF INSTR(location_lower, "sydney") > 0 THEN
lat = -33.8688
lon = 151.2093
ELSE IF INSTR(location_lower, "berlin") > 0 THEN
lat = 52.5200
lon = 13.4050
ELSE IF INSTR(location_lower, "madrid") > 0 THEN
lat = 40.4168
lon = -3.7038
ELSE IF INSTR(location_lower, "sao paulo") > 0 OR INSTR(location_lower, "são paulo") > 0 THEN
lat = -23.5505
lon = -46.6333
ELSE IF INSTR(location_lower, "rio") > 0 THEN
lat = -22.9068
lon = -43.1729
ELSE IF INSTR(location_lower, "los angeles") > 0 THEN
lat = 34.0522
lon = -118.2437
ELSE IF INSTR(location_lower, "chicago") > 0 THEN
lat = 41.8781
lon = -87.6298
ELSE IF INSTR(location_lower, "toronto") > 0 THEN
lat = 43.6532
lon = -79.3832
ELSE IF INSTR(location_lower, "dubai") > 0 THEN
lat = 25.2048
lon = 55.2708
ELSE IF INSTR(location_lower, "singapore") > 0 THEN
lat = 1.3521
lon = 103.8198
ELSE IF INSTR(location_lower, "mumbai") > 0 THEN
lat = 19.0760
lon = 72.8777
ELSE IF INSTR(location_lower, "beijing") > 0 THEN
lat = 39.9042
lon = 116.4074
END IF
weather_url = "https://api.open-meteo.com/v1/forecast?latitude=" + lat + "&longitude=" + lon + "&current_weather=true&timezone=auto"
weather_data = GET weather_url
IF weather_data.current_weather THEN
current = weather_data.current_weather
code = current.weathercode
condition = "Clear"
icon = "☀️"
IF code = 0 THEN
condition = "Clear sky"
icon = "☀️"
ELSE IF code >= 1 AND code <= 3 THEN
condition = "Partly cloudy"
icon = "⛅"
ELSE IF code >= 45 AND code <= 48 THEN
condition = "Foggy"
icon = "🌫️"
ELSE IF code >= 51 AND code <= 67 THEN
condition = "Rainy"
icon = "🌧️"
ELSE IF code >= 71 AND code <= 77 THEN
condition = "Snowy"
icon = "❄️"
ELSE IF code >= 80 AND code <= 82 THEN
condition = "Rain showers"
icon = "🌦️"
ELSE IF code >= 95 AND code <= 99 THEN
condition = "Thunderstorm"
icon = "⛈️"
END IF
WITH result
loc = location
temperature = current.temperature
windspeed = current.windspeed
weathercode = code
cond = condition
ico = icon
END WITH
TALK icon + " Weather for " + location + ":"
TALK "Temperature: " + current.temperature + "°C"
TALK "Condition: " + condition
TALK "Wind: " + current.windspeed + " km/h"
RETURN result
ELSE
TALK "Could not fetch weather for: " + location
RETURN NULL
END IF

View file

@ -0,0 +1,127 @@
# Getting Started with General Bots
## Overview
Welcome to General Bots! This guide will help you understand the basic features available in your default bot installation.
## Available Features
### Calculator
Perform mathematical calculations by asking the bot to calculate expressions.
**Examples:**
- "Calculate 25 * 4"
- "What is 1500 / 12?"
- "Calculate 15% of 200"
### Send Email
Send emails directly through the bot.
**How to use:**
1. Say "Send email" or "Send an email"
2. Provide the recipient's email address
3. Enter the subject line
4. Type your message content
**Example:**
- "Send an email to john@example.com"
- "I need to email my team"
### Send SMS
Send text messages to mobile phones.
**How to use:**
1. Say "Send SMS" or "Send a text message"
2. Provide the phone number (with country code)
3. Enter your message
**Example:**
- "Send SMS to +1234567890"
- "Text message to my contact"
### Translation
Translate text between different languages.
**How to use:**
1. Say "Translate" followed by the text
2. Specify the target language
**Examples:**
- "Translate 'Hello, how are you?' to Spanish"
- "Translate this text to Portuguese"
- "How do you say 'thank you' in French?"
### Weather
Get current weather information for any location.
**How to use:**
1. Ask about the weather for a specific location
**Examples:**
- "What's the weather in New York?"
- "Weather forecast for London"
- "Is it going to rain in Tokyo?"
## Tips for Better Interactions
### Be Specific
The more specific your request, the better the bot can help you. Include relevant details like:
- Email addresses for sending emails
- Phone numbers with country codes for SMS
- City names for weather queries
### Natural Language
You can speak naturally to the bot. It understands various ways of asking for the same thing:
- "Calculate 10 + 5" or "What is 10 plus 5?"
- "Send email" or "I need to email someone"
- "Translate to Spanish" or "How do you say this in Spanish?"
### Confirmation
The bot will ask for confirmation before performing actions like sending emails or SMS to ensure accuracy.
## Extending Your Bot
This default template provides basic functionality. You can extend your bot by:
1. **Adding Knowledge Base**: Create `.md` files in the `.gbkb` folder to give your bot domain-specific knowledge
2. **Creating Dialogs**: Add `.bas` files in the `.gbdialog` folder for custom conversations
3. **Installing Templates**: Add pre-built templates for CRM, HR, helpdesk, and more
4. **Connecting APIs**: Integrate external services for expanded functionality
## Frequently Asked Questions
**Q: How do I add more features to my bot?**
A: Install additional templates or create custom dialog scripts in the `.gbdialog` folder.
**Q: Can the bot remember previous conversations?**
A: Yes, the bot maintains context within a session. For persistent memory, use the memory features in custom dialogs.
**Q: What languages are supported?**
A: The bot supports multiple languages for both interface and translation. Common languages include English, Portuguese, Spanish, French, German, and many others.
**Q: How do I change the bot's appearance?**
A: Modify the `config.csv` file in the `.gbot` folder to change colors, logo, and title.
**Q: Is my data secure?**
A: Yes, all communications are encrypted. Sensitive data like passwords should never be shared in chat.
## Getting Help
If you need assistance:
- Ask the bot "Help" for available commands
- Check the documentation at docs.pragmatismo.com.br
- Contact support for technical issues
## Next Steps
1. Try out each feature to see how it works
2. Explore the template library for pre-built solutions
3. Customize your bot with your own knowledge base
4. Create custom dialogs for your specific use cases
Welcome aboard, and enjoy using General Bots!

View file

@ -0,0 +1,227 @@
name,value
,
# ============================================================================
# SERVER CONFIGURATION
# ============================================================================
server_host,0.0.0.0
server_port,8088
sites_root,/tmp
,
# ============================================================================
# LLM CONFIGURATION
# ============================================================================
llm-key,none
llm-model,../../../../data/llm/DeepSeek-R1-Distill-Qwen-1.5B-Q3_K_M.gguf
,
llm-cache,false
llm-cache-ttl,3600
llm-cache-semantic,true
llm-cache-threshold,0.95
,
episodic-memory-threshold,4
,
mcp-server,false
,
# ============================================================================
# EMBEDDING CONFIGURATION
# ============================================================================
embedding-url,http://localhost:8082
embedding-model,../../../../data/llm/bge-small-en-v1.5-f32.gguf
,
# ============================================================================
# LLM SERVER CONFIGURATION
# ============================================================================
llm-server,true
llm-server-path,botserver-stack/bin/llm/build/bin
llm-server-host,0.0.0.0
llm-server-port,8081
llm-server-gpu-layers,0
llm-server-n-moe,0
llm-server-ctx-size,4096
llm-server-n-predict,1024
llm-server-parallel,6
llm-server-cont-batching,true
llm-server-mlock,false
llm-server-no-mmap,false
,
# ============================================================================
# EMAIL CONFIGURATION
# ============================================================================
email-from,from@domain.com
email-server,mail.domain.com
email-port,587
email-user,user@domain.com
email-pass,
,
# ============================================================================
# DATABASE CONFIGURATION
# ============================================================================
custom-server,localhost
custom-port,5432
custom-database,mycustomdb
custom-username,
custom-password,
,
# ============================================================================
# WEBSITE CRAWLER CONFIGURATION
# ============================================================================
website-expires,1d
website-max-depth,3
website-max-pages,100
,
# ============================================================================
# IMAGE GENERATOR CONFIGURATION
# ============================================================================
image-generator-model,../../../../data/diffusion/sd_turbo_f16.gguf
image-generator-steps,4
image-generator-width,512
image-generator-height,512
image-generator-gpu-layers,20
image-generator-batch-size,1
,
# ============================================================================
# VIDEO GENERATOR CONFIGURATION
# ============================================================================
video-generator-model,../../../../data/diffusion/zeroscope_v2_576w
video-generator-frames,24
video-generator-fps,8
video-generator-width,320
video-generator-height,576
video-generator-gpu-layers,15
video-generator-batch-size,1
,
# ============================================================================
# BOTMODELS CONFIGURATION
# ============================================================================
botmodels-enabled,true
botmodels-host,0.0.0.0
botmodels-port,8085
,
default-generator,all
,
# ============================================================================
# OAUTH AUTHENTICATION CONFIGURATION
# ============================================================================
# Enable social login providers by setting the corresponding -enabled flag
# to "true" and providing valid client credentials.
#
# Each provider requires:
# - oauth-{provider}-enabled: Set to "true" to enable the provider
# - oauth-{provider}-client-id: The Client ID from the provider
# - oauth-{provider}-client-secret: The Client Secret from the provider
# - oauth-{provider}-redirect-uri: (Optional) Custom callback URL
#
# Default redirect URI format: http://your-domain/auth/oauth/{provider}/callback
# ============================================================================
,
# ----------------------------------------------------------------------------
# GOOGLE OAUTH
# ----------------------------------------------------------------------------
# Setup Instructions:
# 1. Go to https://console.cloud.google.com/apis/credentials
# 2. Create a new project or select existing
# 3. Click "Create Credentials" > "OAuth client ID"
# 4. Select "Web application" as application type
# 5. Add authorized redirect URI: http://your-domain/auth/oauth/google/callback
# 6. Copy the Client ID and Client Secret below
#
# Documentation: https://developers.google.com/identity/protocols/oauth2/web-server
# ----------------------------------------------------------------------------
oauth-google-enabled,false
oauth-google-client-id,
oauth-google-client-secret,
oauth-google-redirect-uri,
,
# ----------------------------------------------------------------------------
# MICROSOFT OAUTH (Azure AD)
# ----------------------------------------------------------------------------
# Setup Instructions:
# 1. Go to https://portal.azure.com/#blade/Microsoft_AAD_RegisteredApps/ApplicationsListBlade
# 2. Click "New registration"
# 3. Enter application name and select "Accounts in any organizational directory and personal Microsoft accounts"
# 4. Add redirect URI: http://your-domain/auth/oauth/microsoft/callback (Web platform)
# 5. Go to "Certificates & secrets" > "New client secret"
# 6. Copy the Application (client) ID and secret value below
#
# Documentation: https://learn.microsoft.com/en-us/azure/active-directory/develop/quickstart-register-app
# ----------------------------------------------------------------------------
oauth-microsoft-enabled,false
oauth-microsoft-client-id,
oauth-microsoft-client-secret,
oauth-microsoft-redirect-uri,
,
# ----------------------------------------------------------------------------
# DISCORD OAUTH
# ----------------------------------------------------------------------------
# Setup Instructions:
# 1. Go to https://discord.com/developers/applications
# 2. Click "New Application" and enter a name
# 3. Go to "OAuth2" in the left sidebar
# 4. Add redirect URL: http://your-domain/auth/oauth/discord/callback
# 5. Copy the Client ID and Client Secret below
# 6. Under "OAuth2 URL Generator", select scopes: identify, email
#
# Documentation: https://discord.com/developers/docs/topics/oauth2
# ----------------------------------------------------------------------------
oauth-discord-enabled,false
oauth-discord-client-id,
oauth-discord-client-secret,
oauth-discord-redirect-uri,
,
# ----------------------------------------------------------------------------
# FACEBOOK OAUTH
# ----------------------------------------------------------------------------
# Setup Instructions:
# 1. Go to https://developers.facebook.com/apps/
# 2. Click "Create App" > Select "Consumer" or "Business"
# 3. Add "Facebook Login" product to your app
# 4. Go to Facebook Login > Settings
# 5. Add Valid OAuth Redirect URI: http://your-domain/auth/oauth/facebook/callback
# 6. Go to Settings > Basic to get App ID and App Secret
#
# Documentation: https://developers.facebook.com/docs/facebook-login/guides/advanced/manual-flow
# ----------------------------------------------------------------------------
oauth-facebook-enabled,false
oauth-facebook-client-id,
oauth-facebook-client-secret,
oauth-facebook-redirect-uri,
,
# ----------------------------------------------------------------------------
# TWITTER (X) OAUTH 2.0
# ----------------------------------------------------------------------------
# Setup Instructions:
# 1. Go to https://developer.twitter.com/en/portal/dashboard
# 2. Create a new project and app (or use existing)
# 3. Go to your app's "Keys and tokens" tab
# 4. Under "OAuth 2.0 Client ID and Client Secret", generate credentials
# 5. Go to "User authentication settings" and configure:
# - Enable OAuth 2.0
# - Type: Web App
# - Callback URL: http://your-domain/auth/oauth/twitter/callback
# 6. Copy Client ID and Client Secret below
#
# Note: Twitter requires OAuth 2.0 with PKCE for web apps
# Documentation: https://developer.twitter.com/en/docs/authentication/oauth-2-0
# ----------------------------------------------------------------------------
oauth-twitter-enabled,false
oauth-twitter-client-id,
oauth-twitter-client-secret,
oauth-twitter-redirect-uri,
,
# ----------------------------------------------------------------------------
# REDDIT OAUTH
# ----------------------------------------------------------------------------
# Setup Instructions:
# 1. Go to https://www.reddit.com/prefs/apps
# 2. Click "create another app..." at the bottom
# 3. Select "web app" as the application type
# 4. Enter redirect URI: http://your-domain/auth/oauth/reddit/callback
# 5. Copy the client ID (under app name) and secret below
#
# Note: Reddit requires Basic Auth for token exchange and custom User-Agent
# Documentation: https://github.com/reddit-archive/reddit/wiki/OAuth2
# ----------------------------------------------------------------------------
oauth-reddit-enabled,false
oauth-reddit-client-id,
oauth-reddit-client-secret,
oauth-reddit-redirect-uri,
Can't render this file because it contains an unexpected character in line 106 and column 6.

View file

@ -0,0 +1 @@
/bin/bash: line 3: ./target/debug/botserver: No such file or directory

View file

@ -6,86 +6,86 @@
' Items/Products master table ' Items/Products master table
TABLE items TABLE items
id UUID PRIMARY KEY DEFAULT uuid_generate_v4() id UUID KEY
item_code VARCHAR(50) UNIQUE NOT NULL item_code STRING(50)
barcode VARCHAR(50) UNIQUE barcode STRING(50)
name VARCHAR(255) NOT NULL name STRING(255)
description TEXT description TEXT
category VARCHAR(100) category STRING(100)
subcategory VARCHAR(100) subcategory STRING(100)
unit_of_measure VARCHAR(20) DEFAULT 'EACH' unit_of_measure STRING(20)
weight DECIMAL(10,3) weight NUMBER(10,3)
dimensions_length DECIMAL(10,2) dimensions_length NUMBER(10,2)
dimensions_width DECIMAL(10,2) dimensions_width NUMBER(10,2)
dimensions_height DECIMAL(10,2) dimensions_height NUMBER(10,2)
minimum_stock_level INTEGER DEFAULT 0 minimum_stock_level INTEGER
reorder_point INTEGER reorder_point INTEGER
reorder_quantity INTEGER reorder_quantity INTEGER
lead_time_days INTEGER DEFAULT 0 lead_time_days INTEGER
is_active BOOLEAN DEFAULT TRUE is_active BOOLEAN
is_purchasable BOOLEAN DEFAULT TRUE is_purchasable BOOLEAN
is_saleable BOOLEAN DEFAULT TRUE is_saleable BOOLEAN
is_manufactured BOOLEAN DEFAULT FALSE is_manufactured BOOLEAN
standard_cost DECIMAL(15,4) standard_cost NUMBER(15,4)
last_cost DECIMAL(15,4) last_cost NUMBER(15,4)
average_cost DECIMAL(15,4) average_cost NUMBER(15,4)
selling_price DECIMAL(15,4) selling_price NUMBER(15,4)
created_at TIMESTAMP DEFAULT NOW() created_at TIMESTAMP
updated_at TIMESTAMP DEFAULT NOW() updated_at TIMESTAMP
END TABLE END TABLE
' Warehouses table ' Warehouses table
TABLE warehouses TABLE warehouses
id UUID PRIMARY KEY DEFAULT uuid_generate_v4() id UUID KEY
code VARCHAR(20) UNIQUE NOT NULL code STRING(20)
name VARCHAR(100) NOT NULL name STRING(100)
type VARCHAR(50) DEFAULT 'standard' type STRING(50)
address TEXT address TEXT
city VARCHAR(100) city STRING(100)
state VARCHAR(50) state STRING(50)
country VARCHAR(50) country STRING(50)
postal_code VARCHAR(20) postal_code STRING(20)
contact_person VARCHAR(100) contact_person STRING(100)
contact_phone VARCHAR(50) contact_phone STRING(50)
contact_email VARCHAR(100) contact_email STRING(100)
capacity_units INTEGER capacity_units INTEGER
current_occupancy INTEGER DEFAULT 0 current_occupancy INTEGER
is_active BOOLEAN DEFAULT TRUE is_active BOOLEAN DEFAULT TRUE
created_at TIMESTAMP DEFAULT NOW() created_at TIMESTAMP DEFAULT NOW()
END TABLE END TABLE
' Inventory stock levels ' Inventory stock levels
TABLE inventory_stock TABLE inventory_stock
id UUID PRIMARY KEY DEFAULT uuid_generate_v4() id UUID KEY
item_id UUID REFERENCES items(id) item_id UUID
warehouse_id UUID REFERENCES warehouses(id) warehouse_id UUID
location_code VARCHAR(50) location_code STRING(50)
quantity_on_hand DECIMAL(15,3) DEFAULT 0 quantity_on_hand NUMBER(15,3)
quantity_reserved DECIMAL(15,3) DEFAULT 0 quantity_reserved NUMBER(15,3)
quantity_available DECIMAL(15,3) GENERATED ALWAYS AS (quantity_on_hand - quantity_reserved) STORED quantity_available NUMBER(15,3)
quantity_on_order DECIMAL(15,3) DEFAULT 0 quantity_on_order NUMBER(15,3)
last_counted_date DATE last_counted_date DATE
last_movement_date TIMESTAMP last_movement_date TIMESTAMP
created_at TIMESTAMP DEFAULT NOW() created_at TIMESTAMP DEFAULT NOW()
updated_at TIMESTAMP DEFAULT NOW() updated_at TIMESTAMP DEFAULT NOW()
UNIQUE(item_id, warehouse_id, location_code) (item_id, warehouse_id, location_code)
END TABLE END TABLE
' Inventory transactions ' Inventory transactions
TABLE inventory_transactions TABLE inventory_transactions
id UUID PRIMARY KEY DEFAULT uuid_generate_v4() id UUID KEY
transaction_type VARCHAR(50) NOT NULL transaction_type STRING(50)
transaction_number VARCHAR(50) UNIQUE transaction_number STRING(50)
item_id UUID REFERENCES items(id) item_id UUID
warehouse_id UUID REFERENCES warehouses(id) warehouse_id UUID
location_code VARCHAR(50) location_code STRING(50)
quantity DECIMAL(15,3) NOT NULL quantity NUMBER(15,3)
unit_cost DECIMAL(15,4) unit_cost NUMBER(15,4)
total_cost DECIMAL(15,2) total_cost NUMBER(15,2)
reference_type VARCHAR(50) reference_type STRING(50)
reference_id UUID reference_id UUID
notes TEXT notes TEXT
created_by VARCHAR(100) created_by STRING(100)
created_at TIMESTAMP DEFAULT NOW() created_at TIMESTAMP DEFAULT NOW()
END TABLE END TABLE
@ -93,28 +93,28 @@ END TABLE
' Vendors/Suppliers table ' Vendors/Suppliers table
TABLE vendors TABLE vendors
id UUID PRIMARY KEY DEFAULT uuid_generate_v4() id UUID KEY
vendor_code VARCHAR(50) UNIQUE NOT NULL vendor_code STRING(50)
name VARCHAR(255) NOT NULL name STRING(255)
legal_name VARCHAR(255) legal_name STRING(255)
tax_id VARCHAR(50) tax_id STRING(50)
vendor_type VARCHAR(50) vendor_type STRING(50)
status VARCHAR(20) DEFAULT 'active' status STRING(20)
rating INTEGER CHECK (rating >= 1 AND rating <= 5) rating INTEGER
payment_terms VARCHAR(50) payment_terms STRING(50)
credit_limit DECIMAL(15,2) credit_limit NUMBER(15,2)
currency_code VARCHAR(3) DEFAULT 'USD' currency_code STRING(3)
address TEXT address TEXT
city VARCHAR(100) city STRING(100)
state VARCHAR(50) state STRING(50)
country VARCHAR(50) country STRING(50)
postal_code VARCHAR(20) postal_code STRING(20)
phone VARCHAR(50) phone STRING(50)
email VARCHAR(100) email STRING(100)
website VARCHAR(255) website STRING(255)
contact_person VARCHAR(100) contact_person STRING(100)
bank_account_number VARCHAR(50) bank_account_number STRING(50)
bank_name VARCHAR(100) bank_name STRING(100)
notes TEXT notes TEXT
created_at TIMESTAMP DEFAULT NOW() created_at TIMESTAMP DEFAULT NOW()
updated_at TIMESTAMP DEFAULT NOW() updated_at TIMESTAMP DEFAULT NOW()
@ -122,75 +122,75 @@ END TABLE
' Purchase orders ' Purchase orders
TABLE purchase_orders TABLE purchase_orders
id UUID PRIMARY KEY DEFAULT uuid_generate_v4() id UUID KEY
po_number VARCHAR(50) UNIQUE NOT NULL po_number STRING(50)
vendor_id UUID REFERENCES vendors(id) vendor_id UUID
order_date DATE NOT NULL order_date DATE
expected_date DATE expected_date DATE
status VARCHAR(50) DEFAULT 'draft' status STRING(50)
buyer_id VARCHAR(100) buyer_id STRING(100)
ship_to_warehouse_id UUID REFERENCES warehouses(id) ship_to_warehouse_id UUID
shipping_method VARCHAR(50) shipping_method STRING(50)
payment_terms VARCHAR(50) payment_terms STRING(50)
currency_code VARCHAR(3) DEFAULT 'USD' currency_code STRING(3)
exchange_rate DECIMAL(10,6) DEFAULT 1.0 exchange_rate NUMBER(10,6)
subtotal DECIMAL(15,2) subtotal NUMBER(15,2)
tax_amount DECIMAL(15,2) tax_amount NUMBER(15,2)
shipping_cost DECIMAL(15,2) shipping_cost NUMBER(15,2)
total_amount DECIMAL(15,2) total_amount NUMBER(15,2)
notes TEXT notes TEXT
approved_by VARCHAR(100) approved_by STRING(100)
approved_date TIMESTAMP approved_date TIMESTAMP
created_by VARCHAR(100) created_by STRING(100)
created_at TIMESTAMP DEFAULT NOW() created_at TIMESTAMP DEFAULT NOW()
updated_at TIMESTAMP DEFAULT NOW() updated_at TIMESTAMP DEFAULT NOW()
END TABLE END TABLE
' Purchase order lines ' Purchase order lines
TABLE purchase_order_lines TABLE purchase_order_lines
id UUID PRIMARY KEY DEFAULT uuid_generate_v4() id UUID KEY
po_id UUID REFERENCES purchase_orders(id) ON DELETE CASCADE po_id UUID
line_number INTEGER NOT NULL line_number INTEGER
item_id UUID REFERENCES items(id) item_id UUID
description TEXT description TEXT
quantity_ordered DECIMAL(15,3) NOT NULL quantity_ordered NUMBER(15,3)
quantity_received DECIMAL(15,3) DEFAULT 0 quantity_received NUMBER(15,3)
quantity_remaining DECIMAL(15,3) GENERATED ALWAYS AS (quantity_ordered - quantity_received) STORED quantity_remaining NUMBER(15,3)
unit_price DECIMAL(15,4) NOT NULL unit_price NUMBER(15,4)
discount_percent DECIMAL(5,2) DEFAULT 0 discount_percent NUMBER(5,2)
tax_rate DECIMAL(5,2) DEFAULT 0 tax_rate NUMBER(5,2)
line_total DECIMAL(15,2) GENERATED ALWAYS AS (quantity_ordered * unit_price * (1 - discount_percent/100)) STORED line_total NUMBER(15,2)
expected_date DATE expected_date DATE
created_at TIMESTAMP DEFAULT NOW() created_at TIMESTAMP DEFAULT NOW()
UNIQUE(po_id, line_number) (po_id, line_number)
END TABLE END TABLE
' === SALES MODULE === ' === SALES MODULE ===
' Customers table ' Customers table
TABLE customers TABLE customers
id UUID PRIMARY KEY DEFAULT uuid_generate_v4() id UUID KEY
customer_code VARCHAR(50) UNIQUE NOT NULL customer_code STRING(50)
name VARCHAR(255) NOT NULL name STRING(255)
legal_name VARCHAR(255) legal_name STRING(255)
tax_id VARCHAR(50) tax_id STRING(50)
customer_type VARCHAR(50) customer_type STRING(50)
status VARCHAR(20) DEFAULT 'active' status STRING(20)
credit_rating VARCHAR(10) credit_rating STRING(10)
credit_limit DECIMAL(15,2) credit_limit NUMBER(15,2)
payment_terms VARCHAR(50) payment_terms STRING(50)
discount_percent DECIMAL(5,2) DEFAULT 0 discount_percent NUMBER(5,2)
currency_code VARCHAR(3) DEFAULT 'USD' currency_code STRING(3)
billing_address TEXT billing_address TEXT
shipping_address TEXT shipping_address TEXT
city VARCHAR(100) city STRING(100)
state VARCHAR(50) state STRING(50)
country VARCHAR(50) country STRING(50)
postal_code VARCHAR(20) postal_code STRING(20)
phone VARCHAR(50) phone STRING(50)
email VARCHAR(100) email STRING(100)
website VARCHAR(255) website STRING(255)
sales_person_id VARCHAR(100) sales_person_id STRING(100)
notes TEXT notes TEXT
created_at TIMESTAMP DEFAULT NOW() created_at TIMESTAMP DEFAULT NOW()
updated_at TIMESTAMP DEFAULT NOW() updated_at TIMESTAMP DEFAULT NOW()
@ -198,74 +198,74 @@ END TABLE
' Sales orders ' Sales orders
TABLE sales_orders TABLE sales_orders
id UUID PRIMARY KEY DEFAULT uuid_generate_v4() id UUID KEY
order_number VARCHAR(50) UNIQUE NOT NULL order_number STRING(50)
customer_id UUID REFERENCES customers(id) customer_id UUID
order_date DATE NOT NULL order_date DATE
required_date DATE required_date DATE
promised_date DATE promised_date DATE
status VARCHAR(50) DEFAULT 'draft' status STRING(50)
sales_person_id VARCHAR(100) sales_person_id STRING(100)
ship_from_warehouse_id UUID REFERENCES warehouses(id) ship_from_warehouse_id UUID
shipping_method VARCHAR(50) shipping_method STRING(50)
payment_terms VARCHAR(50) payment_terms STRING(50)
payment_method VARCHAR(50) payment_method STRING(50)
currency_code VARCHAR(3) DEFAULT 'USD' currency_code STRING(3)
exchange_rate DECIMAL(10,6) DEFAULT 1.0 exchange_rate NUMBER(10,6)
subtotal DECIMAL(15,2) subtotal NUMBER(15,2)
discount_amount DECIMAL(15,2) DEFAULT 0 discount_amount NUMBER(15,2)
tax_amount DECIMAL(15,2) tax_amount NUMBER(15,2)
shipping_cost DECIMAL(15,2) shipping_cost NUMBER(15,2)
total_amount DECIMAL(15,2) total_amount NUMBER(15,2)
notes TEXT notes TEXT
approved_by VARCHAR(100) approved_by STRING(100)
approved_date TIMESTAMP approved_date TIMESTAMP
created_by VARCHAR(100) created_by STRING(100)
created_at TIMESTAMP DEFAULT NOW() created_at TIMESTAMP DEFAULT NOW()
updated_at TIMESTAMP DEFAULT NOW() updated_at TIMESTAMP DEFAULT NOW()
END TABLE END TABLE
' Sales order lines ' Sales order lines
TABLE sales_order_lines TABLE sales_order_lines
id UUID PRIMARY KEY DEFAULT uuid_generate_v4() id UUID KEY
order_id UUID REFERENCES sales_orders(id) ON DELETE CASCADE order_id UUID
line_number INTEGER NOT NULL line_number INTEGER
item_id UUID REFERENCES items(id) item_id UUID
description TEXT description TEXT
quantity_ordered DECIMAL(15,3) NOT NULL quantity_ordered NUMBER(15,3)
quantity_shipped DECIMAL(15,3) DEFAULT 0 quantity_shipped NUMBER(15,3)
quantity_invoiced DECIMAL(15,3) DEFAULT 0 quantity_invoiced NUMBER(15,3)
unit_price DECIMAL(15,4) NOT NULL unit_price NUMBER(15,4)
discount_percent DECIMAL(5,2) DEFAULT 0 discount_percent NUMBER(5,2)
tax_rate DECIMAL(5,2) DEFAULT 0 tax_rate NUMBER(5,2)
line_total DECIMAL(15,2) GENERATED ALWAYS AS (quantity_ordered * unit_price * (1 - discount_percent/100)) STORED line_total NUMBER(15,2)
cost_of_goods_sold DECIMAL(15,2) cost_of_goods_sold NUMBER(15,2)
margin DECIMAL(15,2) GENERATED ALWAYS AS (line_total - cost_of_goods_sold) STORED margin NUMBER(15,2)
warehouse_id UUID REFERENCES warehouses(id) warehouse_id UUID
promised_date DATE promised_date DATE
created_at TIMESTAMP DEFAULT NOW() created_at TIMESTAMP DEFAULT NOW()
UNIQUE(order_id, line_number) (order_id, line_number)
END TABLE END TABLE
' === MANUFACTURING MODULE === ' === MANUFACTURING MODULE ===
' Bill of Materials (BOM) header ' Bill of Materials (BOM) header
TABLE bill_of_materials TABLE bill_of_materials
id UUID PRIMARY KEY DEFAULT uuid_generate_v4() id UUID KEY
bom_number VARCHAR(50) UNIQUE NOT NULL bom_number STRING(50)
item_id UUID REFERENCES items(id) item_id UUID
revision VARCHAR(20) DEFAULT 'A' revision STRING(20)
description TEXT description TEXT
quantity_per_assembly DECIMAL(15,3) DEFAULT 1 quantity_per_assembly NUMBER(15,3)
unit_of_measure VARCHAR(20) unit_of_measure STRING(20)
status VARCHAR(20) DEFAULT 'active' status STRING(20)
effective_date DATE effective_date DATE
expiration_date DATE expiration_date DATE
total_cost DECIMAL(15,4) total_cost NUMBER(15,4)
labor_cost DECIMAL(15,4) labor_cost NUMBER(15,4)
overhead_cost DECIMAL(15,4) overhead_cost NUMBER(15,4)
created_by VARCHAR(100) created_by STRING(100)
approved_by VARCHAR(100) approved_by STRING(100)
approved_date DATE approved_date DATE
created_at TIMESTAMP DEFAULT NOW() created_at TIMESTAMP DEFAULT NOW()
updated_at TIMESTAMP DEFAULT NOW() updated_at TIMESTAMP DEFAULT NOW()
@ -273,42 +273,42 @@ END TABLE
' BOM components ' BOM components
TABLE bom_components TABLE bom_components
id UUID PRIMARY KEY DEFAULT uuid_generate_v4() id UUID KEY
bom_id UUID REFERENCES bill_of_materials(id) ON DELETE CASCADE bom_id UUID
component_item_id UUID REFERENCES items(id) component_item_id UUID
line_number INTEGER NOT NULL line_number INTEGER
quantity_required DECIMAL(15,6) NOT NULL quantity_required NUMBER(15,6)
unit_of_measure VARCHAR(20) unit_of_measure STRING(20)
scrap_percent DECIMAL(5,2) DEFAULT 0 scrap_percent NUMBER(5,2)
total_quantity DECIMAL(15,6) GENERATED ALWAYS AS (quantity_required * (1 + scrap_percent/100)) STORED total_quantity NUMBER(15,6)
cost_per_unit DECIMAL(15,4) cost_per_unit NUMBER(15,4)
total_cost DECIMAL(15,4) GENERATED ALWAYS AS (total_quantity * cost_per_unit) STORED total_cost NUMBER(15,4)
notes TEXT notes TEXT
created_at TIMESTAMP DEFAULT NOW() created_at TIMESTAMP DEFAULT NOW()
UNIQUE(bom_id, line_number) (bom_id, line_number)
END TABLE END TABLE
' Work orders ' Work orders
TABLE work_orders TABLE work_orders
id UUID PRIMARY KEY DEFAULT uuid_generate_v4() id UUID KEY
wo_number VARCHAR(50) UNIQUE NOT NULL wo_number STRING(50)
item_id UUID REFERENCES items(id) item_id UUID
bom_id UUID REFERENCES bill_of_materials(id) bom_id UUID
quantity_to_produce DECIMAL(15,3) NOT NULL quantity_to_produce NUMBER(15,3)
quantity_completed DECIMAL(15,3) DEFAULT 0 quantity_completed NUMBER(15,3)
quantity_scrapped DECIMAL(15,3) DEFAULT 0 quantity_scrapped NUMBER(15,3)
status VARCHAR(50) DEFAULT 'planned' status STRING(50)
priority VARCHAR(20) DEFAULT 'normal' priority STRING(20)
planned_start_date TIMESTAMP planned_start_date TIMESTAMP
planned_end_date TIMESTAMP planned_end_date TIMESTAMP
actual_start_date TIMESTAMP actual_start_date TIMESTAMP
actual_end_date TIMESTAMP actual_end_date TIMESTAMP
warehouse_id UUID REFERENCES warehouses(id) warehouse_id UUID
work_center VARCHAR(50) work_center STRING(50)
labor_hours_estimated DECIMAL(10,2) labor_hours_estimated NUMBER(10,2)
labor_hours_actual DECIMAL(10,2) labor_hours_actual NUMBER(10,2)
notes TEXT notes TEXT
created_by VARCHAR(100) created_by STRING(100)
created_at TIMESTAMP DEFAULT NOW() created_at TIMESTAMP DEFAULT NOW()
updated_at TIMESTAMP DEFAULT NOW() updated_at TIMESTAMP DEFAULT NOW()
END TABLE END TABLE
@ -317,13 +317,13 @@ END TABLE
' General ledger accounts ' General ledger accounts
TABLE gl_accounts TABLE gl_accounts
id UUID PRIMARY KEY DEFAULT uuid_generate_v4() id UUID KEY
account_number VARCHAR(20) UNIQUE NOT NULL account_number STRING(20)
account_name VARCHAR(100) NOT NULL account_name STRING(100)
account_type VARCHAR(50) NOT NULL account_type STRING(50)
parent_account_id UUID REFERENCES gl_accounts(id) parent_account_id UUID
currency_code VARCHAR(3) DEFAULT 'USD' currency_code STRING(3)
normal_balance VARCHAR(10) CHECK (normal_balance IN ('debit', 'credit')) normal_balance STRING(10)
is_active BOOLEAN DEFAULT TRUE is_active BOOLEAN DEFAULT TRUE
is_control_account BOOLEAN DEFAULT FALSE is_control_account BOOLEAN DEFAULT FALSE
allow_manual_entry BOOLEAN DEFAULT TRUE allow_manual_entry BOOLEAN DEFAULT TRUE
@ -334,65 +334,65 @@ END TABLE
' Journal entries header ' Journal entries header
TABLE journal_entries TABLE journal_entries
id UUID PRIMARY KEY DEFAULT uuid_generate_v4() id UUID KEY
journal_number VARCHAR(50) UNIQUE NOT NULL journal_number STRING(50)
journal_date DATE NOT NULL journal_date DATE
posting_date DATE NOT NULL posting_date DATE
period VARCHAR(20) period STRING(20)
journal_type VARCHAR(50) journal_type STRING(50)
description TEXT description TEXT
reference_type VARCHAR(50) reference_type STRING(50)
reference_number VARCHAR(50) reference_number STRING(50)
status VARCHAR(20) DEFAULT 'draft' status STRING(20)
total_debit DECIMAL(15,2) total_debit NUMBER(15,2)
total_credit DECIMAL(15,2) total_credit NUMBER(15,2)
is_balanced BOOLEAN GENERATED ALWAYS AS (total_debit = total_credit) STORED is_balanced BOOLEAN
posted_by VARCHAR(100) posted_by STRING(100)
posted_at TIMESTAMP posted_at TIMESTAMP
reversed_by_id UUID REFERENCES journal_entries(id) reversed_by_id UUID
created_by VARCHAR(100) created_by STRING(100)
created_at TIMESTAMP DEFAULT NOW() created_at TIMESTAMP DEFAULT NOW()
END TABLE END TABLE
' Journal entry lines ' Journal entry lines
TABLE journal_entry_lines TABLE journal_entry_lines
id UUID PRIMARY KEY DEFAULT uuid_generate_v4() id UUID KEY
journal_entry_id UUID REFERENCES journal_entries(id) ON DELETE CASCADE journal_entry_id UUID
line_number INTEGER NOT NULL line_number INTEGER
account_id UUID REFERENCES gl_accounts(id) account_id UUID
debit_amount DECIMAL(15,2) DEFAULT 0 debit_amount NUMBER(15,2)
credit_amount DECIMAL(15,2) DEFAULT 0 credit_amount NUMBER(15,2)
description TEXT description TEXT
dimension1 VARCHAR(50) dimension1 STRING(50)
dimension2 VARCHAR(50) dimension2 STRING(50)
dimension3 VARCHAR(50) dimension3 STRING(50)
created_at TIMESTAMP DEFAULT NOW() created_at TIMESTAMP DEFAULT NOW()
UNIQUE(journal_entry_id, line_number) (journal_entry_id, line_number)
CHECK (debit_amount = 0 OR credit_amount = 0)
END TABLE END TABLE
' Invoices ' Invoices
TABLE invoices TABLE invoices
id UUID PRIMARY KEY DEFAULT uuid_generate_v4() id UUID KEY
invoice_number VARCHAR(50) UNIQUE NOT NULL invoice_number STRING(50)
invoice_type VARCHAR(20) DEFAULT 'standard' invoice_type STRING(20)
customer_id UUID REFERENCES customers(id) customer_id UUID
vendor_id UUID REFERENCES vendors(id) vendor_id UUID
order_id UUID order_id UUID
invoice_date DATE NOT NULL invoice_date DATE
due_date DATE NOT NULL due_date DATE
status VARCHAR(20) DEFAULT 'draft' status STRING(20)
currency_code VARCHAR(3) DEFAULT 'USD' currency_code STRING(3)
exchange_rate DECIMAL(10,6) DEFAULT 1.0 exchange_rate NUMBER(10,6)
subtotal DECIMAL(15,2) subtotal NUMBER(15,2)
discount_amount DECIMAL(15,2) DEFAULT 0 discount_amount NUMBER(15,2)
tax_amount DECIMAL(15,2) tax_amount NUMBER(15,2)
total_amount DECIMAL(15,2) total_amount NUMBER(15,2)
amount_paid DECIMAL(15,2) DEFAULT 0 amount_paid NUMBER(15,2)
balance_due DECIMAL(15,2) GENERATED ALWAYS AS (total_amount - amount_paid) STORED balance_due NUMBER(15,2)
payment_terms VARCHAR(50) payment_terms STRING(50)
notes TEXT notes TEXT
created_by VARCHAR(100) created_by STRING(100)
created_at TIMESTAMP DEFAULT NOW() created_at TIMESTAMP DEFAULT NOW()
updated_at TIMESTAMP DEFAULT NOW() updated_at TIMESTAMP DEFAULT NOW()
END TABLE END TABLE
@ -401,38 +401,38 @@ END TABLE
' Employees table ' Employees table
TABLE employees TABLE employees
id UUID PRIMARY KEY DEFAULT uuid_generate_v4() id UUID KEY
employee_number VARCHAR(50) UNIQUE NOT NULL employee_number STRING(50)
first_name VARCHAR(100) NOT NULL first_name STRING(100)
last_name VARCHAR(100) NOT NULL last_name STRING(100)
middle_name VARCHAR(100) middle_name STRING(100)
full_name VARCHAR(255) GENERATED ALWAYS AS (first_name || ' ' || COALESCE(middle_name || ' ', '') || last_name) STORED full_name STRING(255)
email VARCHAR(100) UNIQUE email STRING(100)
phone VARCHAR(50) phone STRING(50)
mobile VARCHAR(50) mobile STRING(50)
address TEXT address TEXT
city VARCHAR(100) city STRING(100)
state VARCHAR(50) state STRING(50)
country VARCHAR(50) country STRING(50)
postal_code VARCHAR(20) postal_code STRING(20)
date_of_birth DATE date_of_birth DATE
gender VARCHAR(20) gender STRING(20)
marital_status VARCHAR(20) marital_status STRING(20)
national_id VARCHAR(50) national_id STRING(50)
passport_number VARCHAR(50) passport_number STRING(50)
department_id UUID department_id UUID
position_title VARCHAR(100) position_title STRING(100)
manager_id UUID REFERENCES employees(id) manager_id UUID
hire_date DATE NOT NULL hire_date DATE
employment_status VARCHAR(50) DEFAULT 'active' employment_status STRING(50)
employment_type VARCHAR(50) DEFAULT 'full-time' employment_type STRING(50)'full-time'
salary DECIMAL(15,2) salary NUMBER(15,2)
hourly_rate DECIMAL(10,2) hourly_rate NUMBER(10,2)
commission_percent DECIMAL(5,2) commission_percent NUMBER(5,2)
bank_account_number VARCHAR(50) bank_account_number STRING(50)
bank_name VARCHAR(100) bank_name STRING(100)
emergency_contact_name VARCHAR(100) emergency_contact_name STRING(100)
emergency_contact_phone VARCHAR(50) emergency_contact_phone STRING(50)
notes TEXT notes TEXT
created_at TIMESTAMP DEFAULT NOW() created_at TIMESTAMP DEFAULT NOW()
updated_at TIMESTAMP DEFAULT NOW() updated_at TIMESTAMP DEFAULT NOW()
@ -440,26 +440,26 @@ END TABLE
' Payroll records ' Payroll records
TABLE payroll TABLE payroll
id UUID PRIMARY KEY DEFAULT uuid_generate_v4() id UUID KEY
payroll_number VARCHAR(50) UNIQUE NOT NULL payroll_number STRING(50)
employee_id UUID REFERENCES employees(id) employee_id UUID
pay_period_start DATE NOT NULL pay_period_start DATE
pay_period_end DATE NOT NULL pay_period_end DATE
payment_date DATE NOT NULL payment_date DATE
hours_worked DECIMAL(10,2) hours_worked NUMBER(10,2)
overtime_hours DECIMAL(10,2) overtime_hours NUMBER(10,2)
regular_pay DECIMAL(15,2) regular_pay NUMBER(15,2)
overtime_pay DECIMAL(15,2) overtime_pay NUMBER(15,2)
commission DECIMAL(15,2) commission NUMBER(15,2)
bonus DECIMAL(15,2) bonus NUMBER(15,2)
gross_pay DECIMAL(15,2) gross_pay NUMBER(15,2)
tax_deductions DECIMAL(15,2) tax_deductions NUMBER(15,2)
other_deductions DECIMAL(15,2) other_deductions NUMBER(15,2)
net_pay DECIMAL(15,2) net_pay NUMBER(15,2)
payment_method VARCHAR(50) payment_method STRING(50)
payment_reference VARCHAR(100) payment_reference STRING(100)
status VARCHAR(20) DEFAULT 'pending' status STRING(20)
approved_by VARCHAR(100) approved_by STRING(100)
approved_date TIMESTAMP approved_date TIMESTAMP
created_at TIMESTAMP DEFAULT NOW() created_at TIMESTAMP DEFAULT NOW()
END TABLE END TABLE
@ -468,42 +468,42 @@ END TABLE
' Audit trail ' Audit trail
TABLE erp_audit_log TABLE erp_audit_log
id UUID PRIMARY KEY DEFAULT uuid_generate_v4() id UUID KEY
table_name VARCHAR(50) NOT NULL table_name STRING(50)
record_id UUID NOT NULL record_id UUID
action VARCHAR(20) NOT NULL action STRING(20)
changed_fields JSONB changed_fieldsTEXT
old_values JSONB old_valuesTEXT
new_values JSONB new_valuesTEXT
user_id VARCHAR(100) user_id STRING(100)
user_ip VARCHAR(45) user_ip STRING(45)
user_agent TEXT user_agent TEXT
created_at TIMESTAMP DEFAULT NOW() created_at TIMESTAMP DEFAULT NOW()
END TABLE END TABLE
' System settings ' System settings
TABLE erp_settings TABLE erp_settings
id UUID PRIMARY KEY DEFAULT uuid_generate_v4() id UUID KEY
module VARCHAR(50) NOT NULL module STRING(50)
setting_key VARCHAR(100) NOT NULL setting_key STRING(100)
setting_value TEXT setting_value TEXT
data_type VARCHAR(20) data_type STRING(20)
description TEXT description TEXT
is_encrypted BOOLEAN DEFAULT FALSE is_encrypted BOOLEAN DEFAULT FALSE
created_at TIMESTAMP DEFAULT NOW() created_at TIMESTAMP DEFAULT NOW()
updated_at TIMESTAMP DEFAULT NOW() updated_at TIMESTAMP DEFAULT NOW()
UNIQUE(module, setting_key) (module, setting_key)
END TABLE END TABLE
' Create indexes for performance ' Create indexes for performance
CREATE INDEX idx_inventory_item_warehouse ON inventory_stock(item_id, warehouse_id) 'CREATE INDEX idx_inventory_item_warehouse ON inventory_stock(item_id, warehouse_id)
CREATE INDEX idx_po_vendor ON purchase_orders(vendor_id) 'CREATE INDEX idx_po_vendor ON purchase_orders(vendor_id)
CREATE INDEX idx_po_status ON purchase_orders(status) 'CREATE INDEX idx_po_status ON purchase_orders(status)
CREATE INDEX idx_so_customer ON sales_orders(customer_id) 'CREATE INDEX idx_so_customer ON sales_orders(customer_id)
CREATE INDEX idx_so_status ON sales_orders(status) 'CREATE INDEX idx_so_status ON sales_orders(status)
CREATE INDEX idx_wo_status ON work_orders(status) 'CREATE INDEX idx_wo_status ON work_orders(status)
CREATE INDEX idx_invoice_customer ON invoices(customer_id) 'CREATE INDEX idx_invoice_customer ON invoices(customer_id)
CREATE INDEX idx_invoice_status ON invoices(status) 'CREATE INDEX idx_invoice_status ON invoices(status)
CREATE INDEX idx_employee_manager ON employees(manager_id) 'CREATE INDEX idx_employee_manager ON employees(manager_id)
CREATE INDEX idx_journal_date ON journal_entries(journal_date) 'CREATE INDEX idx_journal_date ON journal_entries(journal_date)
CREATE INDEX idx_audit_table_record ON erp_audit_log(table_name, record_id) 'CREATE INDEX idx_audit_table_record ON erp_audit_log(table_name, record_id)

View file

@ -4,11 +4,11 @@ PARAM qtd AS INTEGER LIKE 10 DESCRIPTION "Quantity to add to stock"
DESCRIPTION "Add stock quantity for a product by SKU" DESCRIPTION "Add stock quantity for a product by SKU"
person = FIND "People.xlsx", "id=" + mobile person = FIND "People.xlsx", "id=" + mobile
vendor = FIND "maria.Vendedores", "id=" + person.erpId vendor = FIND ".Vendedores", "id=" + person.erpId
TALK "Olá " + vendor.Contato_Nome + "!" TALK "Olá " + vendor.Contato_Nome + "!"
produto = FIND "maria.Produtos", "sku=" + sku produto = FIND ".Produtos", "sku=" + sku
IF NOT produto THEN IF NOT produto THEN
TALK "Produto não encontrado." TALK "Produto não encontrado."

View file

@ -20,7 +20,7 @@ DO WHILE page > 0 AND page <= pages
itemCount = UBOUND(items) itemCount = UBOUND(items)
IF itemCount > 0 THEN IF itemCount > 0 THEN
MERGE "maria.ContasAReceber" WITH items BY "Id" MERGE ".ContasAReceber" WITH items BY "Id"
totalReceber = totalReceber + itemCount totalReceber = totalReceber + itemCount
page = page + 1 page = page + 1
@ -56,7 +56,7 @@ DO WHILE page > 0 AND page <= pages
itemCount = UBOUND(items) itemCount = UBOUND(items)
IF itemCount > 0 THEN IF itemCount > 0 THEN
MERGE "maria.ContasAPagar" WITH items BY "Id" MERGE ".ContasAPagar" WITH items BY "Id"
totalPagar = totalPagar + itemCount totalPagar = totalPagar + itemCount
page = page + 1 page = page + 1

View file

@ -42,7 +42,7 @@ DO WHILE i > 0 AND i < pages
produto.hierarquia = "s" produto.hierarquia = "s"
END IF END IF
produtoDB = FIND "maria.Produtos", "sku=" + produto.codigo produtoDB = FIND ".Produtos", "sku=" + produto.codigo
IF produtoDB THEN IF produtoDB THEN
IF produtoDB.preco <> produto.preco THEN IF produtoDB.preco <> produto.preco THEN
hist = NEW OBJECT hist = NEW OBJECT
@ -51,7 +51,7 @@ DO WHILE i > 0 AND i < pages
hist.precoAtual = produto.preco hist.precoAtual = produto.preco
hist.produto_id = produto.id hist.produto_id = produto.id
hist.dataModificado = FORMAT today, "yyyy-MM-dd" hist.dataModificado = FORMAT today, "yyyy-MM-dd"
SAVE "maria.HistoricoPreco", hist SAVE ".HistoricoPreco", hist
hist = null hist = null
END IF END IF
END IF END IF
@ -63,7 +63,7 @@ DO WHILE i > 0 AND i < pages
list = null list = null
list = items list = items
MERGE "maria.Produtos" WITH list BY "Id" MERGE ".Produtos" WITH list BY "Id"
list = items list = items
j = 0 j = 0
@ -86,7 +86,7 @@ DO WHILE i > 0 AND i < pages
k = 0 k = 0
DO WHILE k < ubound(listV) DO WHILE k < ubound(listV)
listV[k].hierarquia = 'f' listV[k].hierarquia = 'f'
DELETE "maria.ProdutoImagem", "sku=" + listV[k].sku DELETE ".ProdutoImagem", "sku=" + listV[k].sku
images = listV[k]?.midia?.imagens?.externas images = listV[k]?.midia?.imagens?.externas
l = 0 l = 0
@ -96,16 +96,16 @@ DO WHILE i > 0 AND i < pages
images[l].id = random() images[l].id = random()
l = l + 1 l = l + 1
LOOP LOOP
SAVE "maria.ProdutoImagem", images SAVE ".ProdutoImagem", images
images = null images = null
k = k + 1 k = k + 1
LOOP LOOP
MERGE "maria.Produtos" WITH listV BY "Id" MERGE ".Produtos" WITH listV BY "Id"
END IF END IF
listV = null listV = null
DELETE "maria.ProdutoImagem", "sku=" + list[j].sku DELETE ".ProdutoImagem", "sku=" + list[j].sku
k = 0 k = 0
images = list[j].midia?.imagens?.externas images = list[j].midia?.imagens?.externas
DO WHILE k < ubound(images) DO WHILE k < ubound(images)
@ -114,7 +114,7 @@ DO WHILE i > 0 AND i < pages
images[k].id = random() images[k].id = random()
k = k + 1 k = k + 1
LOOP LOOP
SAVE "maria.ProdutoImagem", images SAVE ".ProdutoImagem", images
j = j + 1 j = j + 1
LOOP LOOP
@ -155,7 +155,7 @@ DO WHILE i > 0 AND i < pages
items[k].custo = items[k].valor / 2 items[k].custo = items[k].valor / 2
k = k + 1 k = k + 1
LOOP LOOP
MERGE "maria.PedidosItem" WITH items BY "Id" MERGE ".PedidosItem" WITH items BY "Id"
items = res.data.parcelas items = res.data.parcelas
k = 0 k = 0
@ -163,14 +163,14 @@ DO WHILE i > 0 AND i < pages
items[k].pedido_id = pedido_id items[k].pedido_id = pedido_id
k = k + 1 k = k + 1
LOOP LOOP
MERGE "maria.Parcela" WITH items BY "Id" MERGE ".Parcela" WITH items BY "Id"
fullList[j] = res.data fullList[j] = res.data
res = null res = null
j = j + 1 j = j + 1
LOOP LOOP
MERGE "maria.Pedidos" WITH fullList BY "Id" MERGE ".Pedidos" WITH fullList BY "Id"
i = i + 1 i = i + 1
IF list?.length < limit THEN IF list?.length < limit THEN
i = 0 i = 0
@ -201,7 +201,7 @@ DO WHILE syncPage > 0 AND syncPage <= pages
syncCount = UBOUND(syncItems) syncCount = UBOUND(syncItems)
IF syncCount > 0 THEN IF syncCount > 0 THEN
MERGE "maria.CategoriaReceita" WITH syncItems BY "Id" MERGE ".CategoriaReceita" WITH syncItems BY "Id"
totalCategoria = totalCategoria + syncCount totalCategoria = totalCategoria + syncCount
syncPage = syncPage + 1 syncPage = syncPage + 1
@ -236,7 +236,7 @@ DO WHILE syncPage > 0 AND syncPage <= pages
syncCount = UBOUND(syncItems) syncCount = UBOUND(syncItems)
IF syncCount > 0 THEN IF syncCount > 0 THEN
MERGE "maria.FormaDePagamento" WITH syncItems BY "Id" MERGE ".FormaDePagamento" WITH syncItems BY "Id"
totalForma = totalForma + syncCount totalForma = totalForma + syncCount
syncPage = syncPage + 1 syncPage = syncPage + 1
@ -275,7 +275,7 @@ DO WHILE i > 0 AND i < pages
j = j + 1 j = j + 1
LOOP LOOP
MERGE "maria.Contatos" WITH items BY "Id" MERGE ".Contatos" WITH items BY "Id"
i = i + 1 i = i + 1
IF list?.length < limit THEN IF list?.length < limit THEN
i = 0 i = 0
@ -305,7 +305,7 @@ DO WHILE i > 0 AND i < pages
j = j + 1 j = j + 1
LOOP LOOP
MERGE "maria.Vendedores" WITH items BY "Id" MERGE ".Vendedores" WITH items BY "Id"
i = i + 1 i = i + 1
IF list?.length < limit THEN IF list?.length < limit THEN
i = 0 i = 0

View file

@ -2,7 +2,7 @@ SET SCHEDULE "0 30 23 * * *"
SEND EMAIL admin, "Inventory sync started..." SEND EMAIL admin, "Inventory sync started..."
fullList = FIND "maria.Produtos" fullList = FIND ".Produtos"
chunkSize = 100 chunkSize = 100
startIndex = 0 startIndex = 0
@ -30,11 +30,11 @@ DO WHILE startIndex < ubound(fullList)
k = 0 k = 0
DO WHILE k < ubound(items) DO WHILE k < ubound(items)
depositos = items[k].depositos depositos = items[k].depositos
pSku = FIND "maria.Produtos", "id=${items[k].produto.id}" pSku = FIND ".Produtos", "id=${items[k].produto.id}"
IF pSku THEN IF pSku THEN
prdSku = pSku.sku prdSku = pSku.sku
DELETE "maria.Depositos", "Sku=" + prdSku DELETE ".Depositos", "Sku=" + prdSku
l = 0 l = 0
DO WHILE l < ubound(depositos) DO WHILE l < ubound(depositos)
@ -42,7 +42,7 @@ DO WHILE startIndex < ubound(fullList)
l = l + 1 l = l + 1
LOOP LOOP
SAVE "maria.Depositos", depositos SAVE ".Depositos", depositos
depositos = null depositos = null
END IF END IF

View file

@ -5,7 +5,7 @@ DESCRIPTION "Sync product suppliers from Bling ERP to local database"
SEND EMAIL admin, "Suppliers sync started..." SEND EMAIL admin, "Suppliers sync started..."
FUNCTION SyncProdutoFornecedor(idProduto) FUNCTION SyncProdutoFornecedor(idProduto)
DELETE "maria.ProdutoFornecedor", "Produto_id=" + idProduto DELETE ".ProdutoFornecedor", "Produto_id=" + idProduto
i1 = 1 i1 = 1
DO WHILE i1 > 0 AND i1 < pages DO WHILE i1 > 0 AND i1 < pages
@ -26,7 +26,7 @@ FUNCTION SyncProdutoFornecedor(idProduto)
j1 = j1 + 1 j1 = j1 + 1
LOOP LOOP
SAVE "maria.ProdutoFornecedor", items1 SAVE ".ProdutoFornecedor", items1
items1 = null items1 = null
i1 = i1 + 1 i1 = i1 + 1
@ -38,7 +38,7 @@ FUNCTION SyncProdutoFornecedor(idProduto)
LOOP LOOP
END FUNCTION END FUNCTION
fullList = FIND "maria.Produtos" fullList = FIND ".Produtos"
chunkSize = 100 chunkSize = 100
startIndex = 0 startIndex = 0

View file

@ -1,4 +1,4 @@
TABLE Contatos ON maria TABLE Contatos
Id number key Id number key
Nome string(150) Nome string(150)
Codigo string(50) Codigo string(50)
@ -37,7 +37,7 @@ TABLE Contatos ON maria
Pais_nome string(100) Pais_nome string(100)
END TABLE END TABLE
TABLE Pedidos ON maria TABLE Pedidos
Id number key Id number key
Numero integer Numero integer
NumeroLoja string(15) NumeroLoja string(15)
@ -59,7 +59,7 @@ TABLE Pedidos ON maria
NotaFiscal_id number NotaFiscal_id number
END TABLE END TABLE
TABLE PedidosItem ON maria TABLE PedidosItem
Id number key Id number key
Numero integer Numero integer
Sku string(20) Sku string(20)
@ -75,14 +75,14 @@ TABLE PedidosItem ON maria
Pedido_id number Pedido_id number
END TABLE END TABLE
TABLE ProdutoImagem ON maria TABLE ProdutoImagem
Id number key Id number key
Ordinal number Ordinal number
Sku string(20) Sku string(20)
Link string(250) Link string(250)
END TABLE END TABLE
TABLE Produtos ON maria TABLE Produtos
Id number key Id number key
Nome string(150) Nome string(150)
Sku string(20) Sku string(20)
@ -146,7 +146,7 @@ TABLE Produtos ON maria
Estrutura_componentes_0_produto_Quantidade double Estrutura_componentes_0_produto_Quantidade double
END TABLE END TABLE
TABLE Depositos ON maria TABLE Depositos
Internal_Id number key Internal_Id number key
Id number Id number
Sku string(20) Sku string(20)
@ -154,7 +154,7 @@ TABLE Depositos ON maria
SaldoVirtual double SaldoVirtual double
END TABLE END TABLE
TABLE Vendedores ON maria TABLE Vendedores
Id number key Id number key
DescontoLimite double DescontoLimite double
Loja_Id number Loja_Id number
@ -163,7 +163,7 @@ TABLE Vendedores ON maria
Contato_Situacao string(1) Contato_Situacao string(1)
END TABLE END TABLE
TABLE ProdutoFornecedor ON maria TABLE ProdutoFornecedor
Id number key Id number key
Descricao string(255) Descricao string(255)
Codigo string(50) Codigo string(50)
@ -175,7 +175,7 @@ TABLE ProdutoFornecedor ON maria
Garantia integer Garantia integer
END TABLE END TABLE
TABLE ContasAPagar ON maria TABLE ContasAPagar
Id number key Id number key
Situacao integer Situacao integer
Vencimento date Vencimento date
@ -195,7 +195,7 @@ TABLE ContasAPagar ON maria
Ocorrencia_tipo integer Ocorrencia_tipo integer
END TABLE END TABLE
TABLE ContasAReceber ON maria TABLE ContasAReceber
Id number key Id number key
Situacao integer Situacao integer
Vencimento date Vencimento date
@ -232,7 +232,7 @@ TABLE ContasAReceber ON maria
Ocorrencia_tipo integer Ocorrencia_tipo integer
END TABLE END TABLE
TABLE CategoriaReceita ON maria TABLE CategoriaReceita
Id number key Id number key
IdCategoriaPai number IdCategoriaPai number
Descricao string(255) Descricao string(255)
@ -240,7 +240,7 @@ TABLE CategoriaReceita ON maria
Situacao integer Situacao integer
END TABLE END TABLE
TABLE FormaDePagamento ON maria TABLE FormaDePagamento
Id number key Id number key
Descricao string(255) Descricao string(255)
TipoPagamento integer TipoPagamento integer
@ -258,14 +258,14 @@ TABLE FormaDePagamento ON maria
DadosCartao_cnpjCredenciadora string(16) DadosCartao_cnpjCredenciadora string(16)
END TABLE END TABLE
TABLE NaturezaDeOperacao ON maria TABLE NaturezaDeOperacao
Id number key Id number key
Situacao integer Situacao integer
Padrao integer Padrao integer
Descricao string(255) Descricao string(255)
END TABLE END TABLE
TABLE Parcela ON maria TABLE Parcela
Id number key Id number key
Pedido_id number Pedido_id number
DataVencimento date DataVencimento date
@ -274,7 +274,7 @@ TABLE Parcela ON maria
FormaPagamento_id number FormaPagamento_id number
END TABLE END TABLE
TABLE HistoricoPreco ON maria TABLE HistoricoPreco
Id number key Id number key
Sku string(50) Sku string(50)
PrecoAntigo double PrecoAntigo double

1
botserver.log Normal file
View file

@ -0,0 +1 @@
/home/rodriguez/gb/restart.sh: line 19: ./target/debug/botserver: No such file or directory

1
botui.log Normal file
View file

@ -0,0 +1 @@
/home/rodriguez/gb/restart.sh: line 23: ./target/debug/botui: No such file or directory

View file

@ -4,7 +4,7 @@ name,value
# SERVER CONFIGURATION # SERVER CONFIGURATION
# ============================================================================ # ============================================================================
server_host,0.0.0.0 server_host,0.0.0.0
server_port,9000 server_port,8088
sites_root,/tmp sites_root,/tmp
, ,
# ============================================================================ # ============================================================================

1 name,value
4 # SERVER CONFIGURATION
5 # ============================================================================
6 server_host,0.0.0.0
7 server_port,9000 server_port,8088
8 sites_root,/tmp
9 ,
10 # ============================================================================

View file

@ -1,30 +0,0 @@
TABLE students
Id uuid key
Name string(255)
Email string(255)
RegisteredAt timestamp
END TABLE
PARAM name AS STRING LIKE "John Doe" DESCRIPTION "Full name of the student"
PARAM email AS STRING LIKE "john@example.com" DESCRIPTION "Email address of the student"
DESCRIPTION "Register a new student by saving their name and email to the students table"
studentId = UUID()
registeredAt = NOW()
WITH student
id = studentId
name = name
email = email
registeredAt = registeredAt
END WITH
SAVE "students", studentId, student
TALK "Student registered successfully!"
TALK "Student ID: " + studentId
TALK "Name: " + name
TALK "Email: " + email
RETURN studentId

View file

@ -1 +1,19 @@
Meta Challenge, name,value
,
bot-name,WhatsApp Integration
bot-description,WhatsApp messaging integration
,
param-whatsappPhoneNumber,
param-whatsappBusinessAccountID,
param-whatsappAccessToken,
param-whatsappWebhookURL,
param-whatsappVerifyToken,
,
llm-model,gpt-4o-mini
llm-temperature,0.3
,
sync-interval,60
auto-reply,true
,
param-admin1,admin@yourdomain.com
param-admin2,admin2@yourdomain.com

1 Meta Challenge name value
2
3 bot-name WhatsApp Integration
4 bot-description WhatsApp messaging integration
5
6 param-whatsappPhoneNumber
7 param-whatsappBusinessAccountID
8 param-whatsappAccessToken
9 param-whatsappWebhookURL
10 param-whatsappVerifyToken
11
12 llm-model gpt-4o-mini
13 llm-temperature 0.3
14
15 sync-interval 60
16 auto-reply true
17
18 param-admin1 admin@yourdomain.com
19 param-admin2 admin2@yourdomain.com