-- =============================================================================
-- Script mapari articole GoMag → ROA
-- Generat: 2026-03-19
-- Baza: vending | Server: vending
-- =============================================================================

-- =============================================
-- PARTEA 1: Update CODMAT in NOM_ARTICOLE
-- =============================================

-- id=2020 LAVAZZA BBE EXPERT GUSTO FORTE — CODMAT lipseste (NULL)
UPDATE nom_articole SET codmat = '8000070028685' WHERE id_articol = 2020 AND codmat IS NULL;

-- id=4345 MY POS SIGMA — lowercase ca sa fie identic cu SKU GoMag
UPDATE nom_articole SET codmat = 'mypossigma' WHERE id_articol = 4345 AND codmat = 'MYPOSSIGMA';

-- =============================================
-- PARTEA 2: Mapari ARTICOLE_TERTI (sku != codmat)
-- =============================================

-- Fresso — EAN-uri diferite de codmat intern
INSERT INTO ARTICOLE_TERTI (sku, codmat, cantitate_roa, activ, sters) VALUES ('5940031026295', 'FRSBRZ1000', 1, 1, 0);    -- Fresso Brazilia 1kg
INSERT INTO ARTICOLE_TERTI (sku, codmat, cantitate_roa, activ, sters) VALUES ('5940031062538', 'FRSEVK1000', 1, 1, 0);    -- Fresso Evoke blend 1kg
INSERT INTO ARTICOLE_TERTI (sku, codmat, cantitate_roa, activ, sters) VALUES ('5940031026325', 'FRSCLB1000', 1, 1, 0);    -- Fresso Columbia Caldas 1kg
INSERT INTO ARTICOLE_TERTI (sku, codmat, cantitate_roa, activ, sters) VALUES ('5940031026356', 'FRSCRA1000', 1, 1, 0);    -- Fresso Costa Rica Tarrazu 1kg
INSERT INTO ARTICOLE_TERTI (sku, codmat, cantitate_roa, activ, sters) VALUES ('5940031026462', 'FRSETP250', 1, 1, 0);     -- Fresso Etiopia 250g
INSERT INTO ARTICOLE_TERTI (sku, codmat, cantitate_roa, activ, sters) VALUES ('5940031026479', 'FRSETP500', 1, 1, 0);     -- Fresso Etiopia 500g
INSERT INTO ARTICOLE_TERTI (sku, codmat, cantitate_roa, activ, sters) VALUES ('5940031026486', 'FRSETP1000', 1, 1, 0);    -- Fresso Etiopia 1kg
INSERT INTO ARTICOLE_TERTI (sku, codmat, cantitate_roa, activ, sters) VALUES ('5940031044138', 'FRSEVK250', 1, 1, 0);     -- Fresso Evoke blend 250g
INSERT INTO ARTICOLE_TERTI (sku, codmat, cantitate_roa, activ, sters) VALUES ('59400310625381000MI', 'FRSEVK1000', 1, 1, 0); -- Fresso Evoke macinata 1kg
INSERT INTO ARTICOLE_TERTI (sku, codmat, cantitate_roa, activ, sters) VALUES ('FBS500PE', 'FRSBRZ500', 1, 1, 0);          -- Fresso Brazilia 500g macinata
INSERT INTO ARTICOLE_TERTI (sku, codmat, cantitate_roa, activ, sters) VALUES ('FEY250PI', 'FRSETP250', 1, 1, 0);          -- Fresso Etiopia 250g macinata

-- Tchibo / Lavazza / alte branduri — EAN-uri diferite
INSERT INTO ARTICOLE_TERTI (sku, codmat, cantitate_roa, activ, sters) VALUES ('4006067176463', 'SUISSE500', 1, 1, 0);     -- Tchibo Cafe Creme Suisse 500g
INSERT INTO ARTICOLE_TERTI (sku, codmat, cantitate_roa, activ, sters) VALUES ('69891863', '8000070038493', 1, 1, 0);      -- Lavazza Crema e Gusto Forte 1Kg

-- Piese / accesorii — coduri diferite
INSERT INTO ARTICOLE_TERTI (sku, codmat, cantitate_roa, activ, sters) VALUES ('65221', '33.7006.5221', 1, 1, 0);          -- Pastile curatare Schaerer
INSERT INTO ARTICOLE_TERTI (sku, codmat, cantitate_roa, activ, sters) VALUES ('C7774', 'COL100', 1, 1, 0);                -- Eticheta colant cu pret
INSERT INTO ARTICOLE_TERTI (sku, codmat, cantitate_roa, activ, sters) VALUES ('MEICF7900', 'MEICF560', 1, 1, 0);          -- Restiera MEI Cashflow CF 7900

-- =============================================
-- PARTEA 3: Mapari ARTICOLE_TERTI — impachetari diferite (cantitate != 1)
-- =============================================

-- Prolait/Regilait/Ristora 500g — ROA tine in KG sau BUC, 500g = 0.5
INSERT INTO ARTICOLE_TERTI (sku, codmat, cantitate_roa, activ, sters) VALUES ('8004990125530', '8004990125530', 0.5, 1, 0);  -- Prolait Topping Blue 500g (UM=KG)
INSERT INTO ARTICOLE_TERTI (sku, codmat, cantitate_roa, activ, sters) VALUES ('3043937103250', '3043937103250', 0.5, 1, 0);  -- Regilait Topping 2 Green 500g (UM=KG)
INSERT INTO ARTICOLE_TERTI (sku, codmat, cantitate_roa, activ, sters) VALUES ('8004990123680', '8004990123680', 0.5, 1, 0);  -- Ristora Top Lapte Granulat 500g

-- Pahare — baxuri mari (1 bax web = N seturi ROA de 100buc)
INSERT INTO ARTICOLE_TERTI (sku, codmat, cantitate_roa, activ, sters) VALUES ('10008ozparis', '10573080', 10, 1, 0);         -- Pahar 8oz Paris bax 1000 = 10 seturi
INSERT INTO ARTICOLE_TERTI (sku, codmat, cantitate_roa, activ, sters) VALUES ('100012ozlvzJND', '58912326634', 10, 1, 0);    -- Pahar 12oz Lavazza JND bax 1000 = 10 seturi
INSERT INTO ARTICOLE_TERTI (sku, codmat, cantitate_roa, activ, sters) VALUES ('589123214745675', '8OZLRLP', 10, 1, 0);       -- Pahar 8oz Lavazza RLP bax 1000 = 10 seturi
INSERT INTO ARTICOLE_TERTI (sku, codmat, cantitate_roa, activ, sters) VALUES ('10008ozTchibo', '58', 10, 1, 0);              -- Pahar 8oz Tchibo bax 1000 = 10 seturi
INSERT INTO ARTICOLE_TERTI (sku, codmat, cantitate_roa, activ, sters) VALUES ('10008ozBlueJND', '105712338826', 10, 1, 0);   -- Pahar 8oz Albastru JND bax 1000 = 10 seturi
INSERT INTO ARTICOLE_TERTI (sku, codmat, cantitate_roa, activ, sters) VALUES ('30006ozLavazza', '169', 30, 1, 0);            -- Pahar 6oz Lavazza RLP bax 3000 = 30 seturi
INSERT INTO ARTICOLE_TERTI (sku, codmat, cantitate_roa, activ, sters) VALUES ('30007ozLavazza', '1655455', 30, 1, 0);        -- Pahar 7oz Lavazza RLP bax 3000 = 30 seturi
INSERT INTO ARTICOLE_TERTI (sku, codmat, cantitate_roa, activ, sters) VALUES ('22507ozLavazza', '51', 22.5, 1, 0);           -- Pahar 7oz Lavazza SIBA bax 2250 = 22.5 seturi

-- Pahare — ambalaje mici (50buc = 0.5 set de 100)
INSERT INTO ARTICOLE_TERTI (sku, codmat, cantitate_roa, activ, sters) VALUES ('5891232122239', '8OZLRLP', 0.5, 1, 0);        -- Pahar 8oz Albastru RLP 50buc = 0.5 set
INSERT INTO ARTICOLE_TERTI (sku, codmat, cantitate_roa, activ, sters) VALUES ('87872376', '87872376', 0.5, 1, 0);            -- Pahar 7oz Lavazza JND 50buc = 0.5 set
INSERT INTO ARTICOLE_TERTI (sku, codmat, cantitate_roa, activ, sters) VALUES ('6ozFloMAZ', '6OZFLOMAZ', 0.5, 1, 0);          -- Pahar 6oz Floral MAZ 50buc = 0.5 set

-- Pachet cafea
INSERT INTO ARTICOLE_TERTI (sku, codmat, cantitate_roa, activ, sters) VALUES ('6ktcs', 'SUISSE500', 10, 1, 0);              -- Pachet 5kg Tchibo Suisse = 10x500g

COMMIT;

-- =============================================
-- VERIFICARE
-- =============================================
-- SELECT at.sku, at.codmat, na.denumire, na.um, at.cantitate_roa, at.activ
-- FROM ARTICOLE_TERTI at
-- LEFT JOIN nom_articole na ON na.codmat = at.codmat AND na.sters = 0
-- WHERE at.sters = 0
-- ORDER BY at.sku;
