-- inserts for HelperTests.BillingTest

INSERT INTO wine_cultivation (cultid, name, description) VALUES
('KIP', 'KIP', 'Kontrollierte Integrierte Produktion'),
('B',   'Bio', 'AT-BIO-302');

INSERT INTO wine_attribute (attrid, name, active, max_kg_per_ha, strict, fill_lower) VALUES
('K', 'Kabinett',  TRUE, NULL, FALSE, 0),
('D', 'DAC',       TRUE, 7500, FALSE, 0),
('S', 'Saft',      TRUE, NULL, FALSE, 0),
('Z', 'Sekt',      TRUE, NULL, FALSE, 0),
('P', 'Vertrag P', TRUE, NULL, TRUE,  0),
('Q', 'Vertrag Q', TRUE, NULL, TRUE,  1),
('R', 'Vertrag R', TRUE, NULL, TRUE,  2);

INSERT INTO area_commitment_type (vtrgid, sortid, attrid, disc, min_kg_per_ha, penalty_per_kg, penalty_amount, penalty_none) VALUES
('ZW',  'ZW', NULL, NULL, 2500,  600,    NULL, NULL),
('GV',  'GV', NULL, NULL, 5000,  500,    NULL, NULL),
('GVK', 'GV', 'K',  NULL, 5000,  500,    NULL, NULL),
('GVD', 'GV', 'D',  NULL, 5000, 1000,    NULL, NULL),
('GVP', 'GV', 'P',  NULL, 5000, 1000, 1000000, NULL),
('GVQ', 'GV', 'Q',  NULL, 5000, 1000, 1000000, NULL),
('GVR', 'GV', 'R',  NULL, 5000, 1000, 1000000, NULL);

INSERT INTO area_commitment (fbnr, mgnr, vtrgid, cultid, area, kgnr, gstnr, rdnr, year_from, year_to) VALUES
( 1, 101, 'GV', 'KIP', 10000, 06109, '123/4', NULL, 2000, 2019),
( 2, 101, 'GV', 'KIP', 10000, 06109, '123/5', NULL, 2025, 2030),
( 3, 101, 'GV', 'KIP', 10000, 06109, '123/6', NULL, 2021, 2031);

INSERT INTO season (year, currency, min_kg_per_bs, max_kg_per_bs, penalty_per_kg, penalty_amount, penalty_none, start_date, end_date) VALUES
(2020, 'EUR', 1000, 2000, NULL, NULL, NULL, NULL, NULL),
(2021, 'EUR', 2000, 4000, NULL, NULL, NULL, NULL, NULL);

INSERT INTO modifier (year, modid, ordering, name, abs, rel, standard, quick_select) VALUES
(2020, 'S', 0, 'Geschädigte Trauben', NULL, -0.1, FALSE, FALSE),
(2020, 'A', 0, 'Keine Voranmeldung', -1000, NULL, FALSE, FALSE);

-- Test 01
INSERT INTO delivery (mgnr, year, did, date, time, zwstid, lnr) VALUES
(101, 2020, 1, '2020-10-01', NULL, 'X', 1),
(101, 2020, 2, '2020-10-01', NULL, 'X', 2),
(101, 2020, 3, '2020-10-01', NULL, 'X', 3);
INSERT INTO delivery_part (year, did, dpnr, sortid, attrid, cultid, weight, kmw, qualid, hkid, kgnr, net_weight, manual_weighing, spl_check, scale_id, weighing_id, weighing_reason) VALUES
(2020, 1, 1, 'GV', 'K',  NULL, 4000, 17, 'KAB', 'WLNO', 06109, TRUE, FALSE, FALSE, NULL, NULL, NULL),
(2020, 1, 2, 'GV', NULL, NULL, 4000, 16, 'QUW', 'WLNO', 06109, TRUE, FALSE, FALSE, NULL, NULL, NULL),
(2020, 2, 1, 'GV', NULL, 'B',  4000, 15, 'QUW', 'WLNO', 06109, TRUE, FALSE, FALSE, NULL, NULL, NULL),
(2020, 2, 2, 'GV', NULL, 'B',  4000, 16, 'QUW', 'WLNO', 06109, TRUE, FALSE, FALSE, NULL, NULL, NULL),
(2020, 3, 1, 'GV', NULL, NULL,  500, 15, 'WEI', 'OEST', 06109, TRUE, FALSE, FALSE, NULL, NULL, NULL),
(2020, 3, 2, 'GV', NULL, NULL,  500, 14, 'LDW', 'WLXX', 06109, TRUE, FALSE, FALSE, NULL, NULL, NULL);
INSERT INTO delivery_part_modifier (year, did, dpnr, modid) VALUES
(2020, 1, 2, 'S');

-- Test 02 + 03
INSERT INTO delivery (mgnr, year, did, date, time, zwstid, lnr) VALUES
(101, 2021, 1, '2021-10-01', NULL, 'X', 1),
(101, 2021, 2, '2021-10-01', NULL, 'X', 2),
(101, 2021, 3, '2021-10-01', NULL, 'X', 3);
INSERT INTO delivery_part (year, did, dpnr, sortid, attrid, cultid, weight, kmw, qualid, hkid, kgnr, gebunden, net_weight, manual_weighing, spl_check, scale_id, weighing_id, weighing_reason) VALUES
(2021, 1, 1, 'GV', 'K',  NULL, 4000, 17, 'KAB', 'WLNO', 06109, TRUE,  TRUE, FALSE, FALSE, NULL, NULL, NULL),
(2021, 1, 2, 'GV', NULL, NULL, 4000, 16, 'QUW', 'WLNO', 06109, FALSE, TRUE, FALSE, FALSE, NULL, NULL, NULL),
(2021, 2, 1, 'GV', NULL, 'B',  4000, 15, 'QUW', 'WLNO', 06109, TRUE,  TRUE, FALSE, FALSE, NULL, NULL, NULL),
(2021, 2, 2, 'GV', NULL, 'B',  4000, 16, 'QUW', 'WLNO', 06109, FALSE, TRUE, FALSE, FALSE, NULL, NULL, NULL),
(2021, 3, 1, 'GV', NULL, NULL,  500, 15, 'WEI', 'OEST', 06109, NULL,  TRUE, FALSE, FALSE, NULL, NULL, NULL),
(2021, 3, 2, 'GV', NULL, NULL,  500, 14, 'LDW', 'WLXX', 06109, NULL,  TRUE, FALSE, FALSE, NULL, NULL, NULL);
