
INSERT INTO wb_gl VALUES
(1, 'Heideboden');

INSERT INTO wb_kg
SELECT k.kgnr, 1
FROM wb_gem wg
    LEFT JOIN AT_gem g ON g.gkz = wg.gkz
    LEFT JOIN AT_kg k ON k.gkz = g.gkz
WHERE hkid = 'WLNS' AND k.name NOT IN
    ('Nickelsdorf', 'Zurndorf', 'Parndorf', 'Bruckneudorf', 'Kaisersteinbruch', 'Gattendorf', 'Neudorf bei Parndorf',
     'Potzneusiedl', 'Pama', 'Deutsch Jahrndorf', 'Kittsee', 'Edelstal');

INSERT INTO member (mgnr, name, given_name, juridical_pers, zwstid, birthday, entry_date, business_shares, volllieferant, buchführend, country, postal_dest, address, default_kgnr, iban, lfbis_nr, ustid_nr) VALUES
(101, 'Mustermann',        'Max',       FALSE, 'X', '1991', '2012-06-04', 5, FALSE, FALSE, 40, 715200162, 'Winzerstraße 1',       32019, 'AT811234567890123457', '0123463',         NULL ),
(102, 'Weinbauer',         'Wernhardt', FALSE, 'X', '1975', '1994-05-20', 3, FALSE, FALSE, 40, 714300143, 'Winzerstraße 2',       32002, 'AT541234567890123458', '0123471', 'ATU12345684'),
(103, 'Musterbauer',       'Matthäus',  FALSE, 'X', '2000', '2021-07-03', 4, FALSE, FALSE, 40, 714200154, 'Ödenburger Straße 10', 32010, 'AT271234567890123459', '0123480',         NULL ),
(104, 'Winzer',            'Waltraud',  FALSE, 'X', '1970', '1992-04-23', 2, FALSE, TRUE , 40, 715200162, 'Wiener Straße 15',     32019, 'AT971234567890123460', '0123498', 'ATU12345693'),
(105, 'Weinland Weine AG', NULL,        TRUE , 'X', '2008', '2008-11-13', 6, FALSE, TRUE , 40, 714200154, 'Hauptstraße 7',        32010, 'AT701234567890123461', '0123501', 'ATU12345700');

INSERT INTO member_billing_address (mgnr, name, country, postal_dest, address) VALUES
(102, 'W&B Weinbauer GesbR',          40, 714300143, 'Winzerstraße 2'),
(104, 'Weinbau Waltraud Winzer GmbH', 40, 715200162, 'Hauptstraße 1');

INSERT INTO member_telephone_number (mgnr, nr, type, number, comment) VALUES
(101, 1, 'mobile',   '+43 664 123456789', NULL),
(102, 1, 'landline', '+43 2175 01234',    NULL),
(102, 2, 'mobile',   '+43 664 123456790', NULL),
(103, 1, 'mobile',   '+43 664 123456791', 'Matthäus'),
(103, 2, 'mobile',   '+43 664 123456792', 'Mathilde'),
(104, 1, 'landline', '+43 2174 01235',    NULL),
(104, 2, 'mobile',   '+43 664 123456793', NULL),
(105, 1, 'landline', '+43 2175 01236',    NULL);

INSERT INTO member_email_address (mgnr, nr, address) VALUES
(101, 1, 'max@mustermann.com'),
(103, 1, 'mustermat@example.com'),
(104, 1, 'waltraud@weinbau-winzer.at'),
(105, 1, 'office@weinland-weine.at'),
(105, 2, 'herbert.huber@test.at');


UPDATE client_parameter SET value = '0' WHERE param = 'ENABLE_TIME_TRIGGERS';

INSERT INTO delivery (year, did, date, time, zwstid, lnr, lsnr, mgnr, ctime, mtime) VALUES
(2025, 1, '2025-09-30', '09:04:38', 'X', 1, '20250930X001', 101, 1759215878, 1759215878),
(2025, 2, '2025-09-30', '10:47:13', 'X', 2, '20250930X002', 102, 1759222033, 1759222033);

INSERT INTO delivery_part (year, did, dpnr, sortid, attrid, cultid, weight, kmw, qualid, hkid, kgnr, net_weight, manual_weighing, scale_id, weighing_data, ctime, mtime) VALUES
(2025, 1, 1, 'GV', NULL, 'B',  2876, 16.8, 'QUW', 'WLBL', 32019, TRUE,  FALSE, '1', '{"id":"2025-09-30/1","nr":1,"date":"2025-09-30","time":"08:52:00","gross_weight":2876,"tare_weight":0,"net_weight":2876}', 1759215878, 1759215878),
(2025, 1, 2, 'SB', NULL, 'B',  1342, 15.2, 'QUW', 'WLBL', 32019, TRUE,  FALSE, '1', '{"id":"2025-09-30/2","nr":2,"date":"2025-09-30","time":"08:56:00","gross_weight":1342,"tare_weight":0,"net_weight":1342}', 1759215878, 1759215878),
(2025, 1, 3, 'WR', 'S',  NULL, 3128, 14.5, 'LDW', 'WLXX', 32019, TRUE,  FALSE, '1', '{"id":"2025-09-30/4","nr":4,"date":"2025-09-30","time":"09:01:00","gross_weight":3128,"tare_weight":0,"net_weight":3128}', 1759215878, 1759215878),
(2025, 2, 1, 'CH', NULL, NULL, 3482, 15.0, 'QUW', 'WLBL', 32002, FALSE, FALSE, '1', '{"id":"2025-09-30/5","nr":5,"date":"2025-09-30","time":"10:35:00","gross_weight":3482,"tare_weight":0,"net_weight":3482}', 1759222033, 1759222033),
(2025, 2, 2, 'WR', NULL, NULL, 1800, 15.2, 'QUW', 'WLBL', 32002, FALSE, TRUE,  NULL, NULL, 1759222033, 1759222033);

INSERT INTO delivery_part_modifier (year, did, dpnr, modid) VALUES
(2025, 2, 1, 'L'),
(2025, 2, 2, 'S');

UPDATE client_parameter SET value = '1' WHERE param = 'ENABLE_TIME_TRIGGERS';

INSERT INTO payment_variant (year, avnr, name, date, transfer_date, test_variant, data) VALUES
(2025, 1, '1. Teilzahlung', '2026-04-20', NULL, 1, '{"mode":"elwig","version":1,"payment":0.2,"curves":[]}'),
(2025, 2, 'Endauszahlung',  '2026-04-21', NULL, 1, '{"mode":"elwig","version":1,"consider_delivery_modifiers":true,"payment":{"WR/S":0.22,"CH":0.3,"WR":0.3,"-B":"curve:1"},"curves":[{"id":1,"mode":"oe","data":{"72oe":0.15,"73oe":0.45}}],"gross_weight_modifier": -0.05}');
