diff options
Diffstat (limited to 'src/administration.cpp')
| -rw-r--r-- | src/administration.cpp | 117 |
1 files changed, 70 insertions, 47 deletions
diff --git a/src/administration.cpp b/src/administration.cpp index 21b70f3..d75aff7 100644 --- a/src/administration.cpp +++ b/src/administration.cpp @@ -274,23 +274,25 @@ static void administration_create_debug_data() { srand((unsigned) time(NULL)); - #define ADD_CONSUMER(_name, _addr1, _addr2, _cc)\ + #define ADD_CONSUMER(_name, _addr1, _cc, _city, _postal)\ {contact _c = administration_contact_create_empty();\ strops_copy(_c.name, _name, sizeof(_c.name));\ strops_copy(_c.address.address1, _addr1, sizeof(_c.address.address1));\ - strops_copy(_c.address.address2, _addr2, sizeof(_c.address.address2));\ strops_copy(_c.address.country_code, _cc, sizeof(_c.address.country_code));\ + strops_copy(_c.address.city, _city, sizeof(_c.address.city));\ + strops_copy(_c.address.postal, _postal, sizeof(_c.address.postal));\ _c.type = contact_type::CONTACT_CONSUMER;\ administration_contact_add(_c);}; - #define ADD_BUSINESS(_name, _addr1, _addr2, _cc, _tc, _bc)\ + #define ADD_BUSINESS(_name, _addr1, _cc, _tc, _bc, _city, _postal)\ {contact _c = administration_contact_create_empty();\ strops_copy(_c.name, _name, sizeof(_c.name));\ strops_copy(_c.address.address1, _addr1, sizeof(_c.address.address1));\ - strops_copy(_c.address.address2, _addr2, sizeof(_c.address.address2));\ strops_copy(_c.address.country_code, _cc, sizeof(_c.address.country_code));\ strops_copy(_c.taxid, _tc, sizeof(_c.taxid));\ strops_copy(_c.businessid, _bc, sizeof(_c.businessid));\ + strops_copy(_c.address.city, _city, sizeof(_c.address.city));\ + strops_copy(_c.address.postal, _postal, sizeof(_c.address.postal));\ _c.type = contact_type::CONTACT_BUSINESS;\ administration_contact_add(_c);}; @@ -301,37 +303,37 @@ static void administration_create_debug_data() strops_copy(g_administration.path, "C:\\Users\\aldri\\Downloads\\test.openbooks", sizeof(g_administration.path)); - ADD_CONSUMER("Emma Müller", "Hauptstraße 12", "10115 Berlin", "DE"); - ADD_CONSUMER("Luca Rossi", "Via Roma 45", "00184 Roma", "IT"); - ADD_CONSUMER("Sofia Garcia", "Calle Mayor 7", "28013 Madrid", "ES"); - ADD_CONSUMER("Jean Dupont", "10 Rue de la Paix", "75002 Paris", "FR"); - ADD_CONSUMER("Anna Nowak", "ul. Kwiatowa 3", "00-001 Warszawa", "PL"); - ADD_CONSUMER("Mikkel Jensen", "Østergade 8", "8000 Aarhus", "DK"); - ADD_CONSUMER("Maria Svensson", "Kungsgatan 15", "111 22 Stockholm", "SE"); - ADD_CONSUMER("Péter Kovács", "Fő utca 25", "1051 Budapest", "HU"); - ADD_CONSUMER("Lucas Silva", "Rua Augusta 100", "1250-001 Lisboa", "PT"); - ADD_CONSUMER("Isabelle Lefevre", "5 Place Stanislas", "54000 Nancy", "FR"); - - ADD_BUSINESS("Schmidt & Co GmbH", "Friedrichstraße 45", "10117 Berlin", "DE", "DE123456789", "HRB123456"); - ADD_BUSINESS("Bianchi Srl", "Corso Venezia 12", "20121 Milano", "IT", "IT987654321", "MI1234567"); - ADD_BUSINESS("Fernández y Asociados", "Gran Vía 20", "28013 Madrid", "ES", "ES456789123", "CIFB123456"); - ADD_BUSINESS("Martin & Partners", "12 Avenue Victor Hugo", "75016 Paris", "FR", "FR321654987", "SIRET123456"); - ADD_BUSINESS("Zielińska Consulting", "ul. Marszałkowska 10", "00-590 Warszawa", "PL", "PL789123456", "REGON123456"); - ADD_BUSINESS("Sørensen ApS", "Strøget 3", "1460 København", "DK", "DK654321789", "CVR12345678"); - ADD_BUSINESS("Johansson AB", "Drottninggatan 22", "111 51 Stockholm", "SE", "SE987654321", "OrgNr1234567"); - ADD_BUSINESS("Nagy Kft.", "Andrássy út 60", "1062 Budapest", "HU", "HU123987654", "Cégjegyzékszám123"); - ADD_BUSINESS("Santos Lda.", "Avenida da Liberdade 50", "1250-142 Lisboa", "PT", "PT321789654", "NIPC123456789"); - ADD_BUSINESS("Dupuis SARL", "8 Rue Saint-Denis", "75001 Paris", "FR", "FR456123789", "SIREN123456"); - ADD_BUSINESS("Müller & Söhne GmbH", "Leipziger Platz 8", "10117 Berlin", "DE", "DE654987321", "HRB987654"); - ADD_BUSINESS("Romano Srl", "Via Garibaldi 14", "16124 Genova", "IT", "IT321654987", "GE1239876"); - ADD_BUSINESS("López Asociados", "Plaza del Pilar 6", "50003 Zaragoza", "ES", "ES789321654", "CIFC654321"); - ADD_BUSINESS("Laurent & Fils", "15 Boulevard Haussmann", "75009 Paris", "FR", "FR987321654", "SIRET654987"); - ADD_BUSINESS("Kowalczyk Sp. z o.o.", "ul. Piotrkowska 55", "90-001 Łódź", "PL", "PL123456789", "REGON654321"); - ADD_BUSINESS("Nielsen ApS", "Nørregade 12", "1165 København", "DK", "DK789456123", "CVR87654321"); - ADD_BUSINESS("Lindberg AB", "Vasagatan 18", "111 20 Stockholm", "SE", "SE456789123", "OrgNr7654321"); - ADD_BUSINESS("Szabó Kft.", "Kossuth Lajos tér 1", "1055 Budapest", "HU", "HU987123654", "Cégjegyzékszám654321"); - ADD_BUSINESS("Costa Lda.", "Rua do Ouro 24", "1100-063 Lisboa", "PT", "PT654123987", "NIPC987654321"); - ADD_BUSINESS("Moreau SARL", "3 Place de la République", "75011 Paris", "FR", "FR321456987", "SIREN789123"); + ADD_CONSUMER("Emma Müller", "Hauptstraße 12", "DE", "Hamburg", "20095"); + ADD_CONSUMER("Luca Rossi", "Via Roma 45", "IT", "Torino", "10121"); + ADD_CONSUMER("Sofia Garcia", "Calle Mayor 7", "ES", "Valencia", "46001"); + ADD_CONSUMER("Jean Dupont", "10 Rue de la Paix", "FR", "Lyon", "69001"); + ADD_CONSUMER("Anna Nowak", "ul. Kwiatowa 3", "PL", "Kraków", "30-001"); + ADD_CONSUMER("Mikkel Jensen", "Østergade 8", "DK", "Odense", "5000"); + ADD_CONSUMER("Maria Svensson", "Kungsgatan 15", "SE", "Gothenburg", "411 01"); + ADD_CONSUMER("Péter Kovács", "Fő utca 25", "HU", "Debrecen", "4025"); + ADD_CONSUMER("Lucas Silva", "Rua Augusta 100", "PT", "Porto", "4000-123"); + ADD_CONSUMER("Isabelle Lefevre", "5 Place Stanislas", "FR", "Marseille", "13001"); + + ADD_BUSINESS("Schmidt & Co GmbH", "Friedrichstraße 45", "DE", "DE123456789", "HRB123456", "Stuttgart", "70173"); + ADD_BUSINESS("Bianchi Srl", "Corso Venezia 12", "IT", "IT987654321", "MI1234567", "Napoli", "80100"); + ADD_BUSINESS("Fernández y Asociados", "Gran Vía 20", "ES", "ES456789123", "CIFB123456", "Sevilla", "41001"); + ADD_BUSINESS("Martin & Partners", "12 Avenue Victor Hugo", "FR", "FR321654987", "SIRET123456", "Nice", "06000"); + ADD_BUSINESS("Zielińska Consulting", "ul. Marszałkowska 10", "PL", "PL789123456", "REGON123456", "Gdańsk", "80-001"); + ADD_BUSINESS("Sørensen ApS", "Strøget 3", "DK", "DK654321789", "CVR12345678", "Aalborg", "9000"); + ADD_BUSINESS("Johansson AB", "Drottninggatan 22", "SE", "SE987654321", "OrgNr1234567", "Malmö", "211 01"); + ADD_BUSINESS("Nagy Kft.", "Andrássy út 60", "HU", "HU123987654", "Cégjegyzékszám123", "Szeged", "6720"); + ADD_BUSINESS("Santos Lda.", "Avenida da Liberdade 50", "PT", "PT321789654", "NIPC123456789", "Coimbra", "3000-132"); + ADD_BUSINESS("Dupuis SARL", "8 Rue Saint-Denis", "FR", "FR456123789", "SIREN123456", "Toulouse", "31000"); + ADD_BUSINESS("Müller & Söhne GmbH", "Leipziger Platz 8", "DE", "DE654987321", "HRB987654", "Dresden", "01067"); + ADD_BUSINESS("Romano Srl", "Via Garibaldi 14", "IT", "IT321654987", "GE1239876", "Firenze", "50123"); + ADD_BUSINESS("López Asociados", "Plaza del Pilar 6", "ES", "ES789321654", "CIFC654321", "Bilbao", "48001"); + ADD_BUSINESS("Laurent & Fils", "15 Boulevard Haussmann", "FR", "FR987321654", "SIRET654987", "Bordeaux", "33000"); + ADD_BUSINESS("Kowalczyk Sp. z o.o.", "ul. Piotrkowska 55", "PL", "PL123456789", "REGON654321", "Poznań", "60-101"); + ADD_BUSINESS("Nielsen ApS", "Nørregade 12", "DK", "DK789456123", "CVR87654321", "Esbjerg", "6700"); + ADD_BUSINESS("Lindberg AB", "Vasagatan 18", "SE", "SE456789123", "OrgNr7654321", "Uppsala", "753 10"); + ADD_BUSINESS("Szabó Kft.", "Kossuth Lajos tér 1", "HU", "HU987123654", "Cégjegyzékszám654321", "Pécs", "7621"); + ADD_BUSINESS("Costa Lda.", "Rua do Ouro 24", "PT", "PT654123987", "NIPC987654321", "Braga", "4700-001"); + ADD_BUSINESS("Moreau SARL", "3 Place de la République", "FR", "FR321456987", "SIREN789123", "Lille", "59000"); ADD_PROJECT("eCommerce"); ADD_PROJECT("Retail store #1"); @@ -342,8 +344,10 @@ static void administration_create_debug_data() snprintf(g_administration.company_info.id, sizeof(g_administration.company_info.id), "C/%d", administration_create_id()); strops_copy(g_administration.company_info.name, "Aldrik Ramaekers", sizeof(g_administration.company_info.name)); strops_copy(g_administration.company_info.address.address1, "Keerderstraat 81", sizeof(g_administration.company_info.address.address1)); - strops_copy(g_administration.company_info.address.address2, "6226XW Maastricht", sizeof(g_administration.company_info.address.address2)); - strops_copy(g_administration.company_info.address.country_code, "NL", sizeof(g_administration.company_info.address.country_code)); + strops_copy(g_administration.company_info.address.address2, "", sizeof(g_administration.company_info.address.address2)); + strops_copy(g_administration.company_info.address.city, "Maastricht", sizeof(g_administration.company_info.address.city)); + strops_copy(g_administration.company_info.address.postal, "6226XW", sizeof(g_administration.company_info.address.postal)); + strops_copy(g_administration.company_info.address.country_code, "NL", sizeof(g_administration.company_info.address.country_code)); strops_copy(g_administration.company_info.taxid, "123", sizeof(g_administration.company_info.taxid)); strops_copy(g_administration.company_info.businessid, "123", sizeof(g_administration.company_info.businessid)); g_administration.next_id++; @@ -366,8 +370,8 @@ static void administration_create_debug_data() } // Create about 2 years of random data. - for (int i = 0; i < 410; i++) ADD_INVOICE(1); - for (int i = 0; i < 700; i++) ADD_INVOICE(0); + for (int i = 0; i < 1; i++) { ADD_INVOICE(1); } + for (int i = 0; i < 1; i++) { ADD_INVOICE(0); } } static s32 administration_create_sequence_number() @@ -587,17 +591,20 @@ int administration_contact_get_autocompletions(contact* buffer, int buf_size, ch bool administration_contact_is_valid(contact data) { - if (data.type == contact_type::CONTACT_CONSUMER) - { - return strlen(data.name) > 0 && strlen(data.address.address1) > 0 && strlen(data.address.address2) > 0 && strlen(data.address.country_code) > 0; - } - else if (data.type == contact_type::CONTACT_BUSINESS) + if (strlen(data.name) == 0) return 0; + if (strlen(data.address.city) == 0) return 0; + if (strlen(data.address.postal) == 0) return 0; + if (strlen(data.address.address1) == 0) return 0; + //if (strlen(data.address.address2) == 0) return 0; + if (strlen(data.address.country_code) == 0) return 0; + + if (data.type == contact_type::CONTACT_BUSINESS) { - return strlen(data.name) > 0 && strlen(data.address.address1) > 0 && strlen(data.address.address2) > 0 && strlen(data.address.country_code) > 0 - && strlen(data.taxid) > 0 && strlen(data.businessid); + if (strlen(data.taxid) == 0) return 0; + if (strlen(data.businessid) == 0) return 0; } - return false; + return true; } contact administration_contact_create_empty() @@ -1184,6 +1191,22 @@ u32 administation_invoice_get_outgoing_count() return g_administration.invoice_count; } +u32 administration_invoice_get_all(invoice* buffer) +{ + assert(buffer); + + u32 write_cursor = 0; + + list_iterator_start(&g_administration.invoices); + while (list_iterator_hasnext(&g_administration.invoices)) { + invoice c = *(invoice *)list_iterator_next(&g_administration.invoices); + buffer[write_cursor++] = c; + } + list_iterator_stop(&g_administration.invoices); + + return write_cursor; +} + static u32 administration_invoice_get_partial_list(u32 page_index, u32 page_size, invoice* buffer, bool want_outgoing) { assert(buffer); |
