summaryrefslogtreecommitdiff
path: root/src/administration.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/administration.cpp')
-rw-r--r--src/administration.cpp61
1 files changed, 61 insertions, 0 deletions
diff --git a/src/administration.cpp b/src/administration.cpp
index d75aff7..b938271 100644
--- a/src/administration.cpp
+++ b/src/administration.cpp
@@ -1144,6 +1144,12 @@ bool administration_invoice_add(invoice* inv)
invoice* new_inv = (invoice*)malloc(sizeof(invoice));
memcpy(new_inv, &copy, sizeof(invoice));
+ new_inv->payment_means.payment_method = PAYMENT_METHOD_DEBIT_TRANSFER;
+ strops_copy(new_inv->payment_means.payee_bank_account, inv->customer.bank_account, sizeof(new_inv->payment_means.payee_bank_account));
+ strops_copy(new_inv->payment_means.payee_account_name, inv->customer.name, sizeof(new_inv->payment_means.payee_account_name));
+ strops_copy(new_inv->payment_means.service_provider_id, "", sizeof(new_inv->payment_means.service_provider_id));
+ strops_copy(new_inv->payment_means.payer_bank_account, inv->supplier.bank_account, sizeof(new_inv->payment_means.payer_bank_account));
+
list_append(&g_administration.invoices, new_inv);
g_administration.next_id++;
@@ -1207,6 +1213,61 @@ u32 administration_invoice_get_all(invoice* buffer)
return write_cursor;
}
+bool administration_invoice_get_subtotal_for_tax_bracket(invoice* invoice, country_tax_bracket bracket, tax_subtotal* buffer)
+{
+ bool result = false;
+
+ buffer->tax = 0.0f;
+ buffer->total = 0.0f;
+ buffer->net = 0.0f;
+
+ list_iterator_start(&invoice->billing_items);
+ while (list_iterator_hasnext(&invoice->billing_items)) {
+ billing_item* c = (billing_item *)list_iterator_next(&invoice->billing_items);
+
+ if (strcmp(c->tax_bracket_id, bracket.id) == 0)
+ {
+ result = true;
+ buffer->tax += c->tax;
+ buffer->total += c->total;
+ buffer->net += c->net;
+ }
+ }
+ list_iterator_stop(&invoice->billing_items);
+
+ return result;
+}
+
+u32 administration_invoice_get_tax_brackets(invoice* invoice, country_tax_bracket* buffer)
+{
+ u32 write_cursor = 0;
+
+ list_iterator_start(&invoice->billing_items);
+ while (list_iterator_hasnext(&invoice->billing_items)) {
+ billing_item c = *(billing_item *)list_iterator_next(&invoice->billing_items);
+
+ country_tax_bracket bracket;
+ bool found = administration_get_tax_bracket_by_id(&bracket, c.tax_bracket_id);
+ if (found) {
+
+ bool exists = false;
+ for (u32 i = 0; i < write_cursor; i++) {
+ if (strcmp(buffer[i].id, c.tax_bracket_id) == 0) {
+ exists = true;
+ break;
+ }
+ }
+
+ if (!exists) {
+ buffer[write_cursor++] = bracket;
+ }
+ }
+ }
+ list_iterator_stop(&invoice->billing_items);
+
+ return write_cursor;
+}
+
static u32 administration_invoice_get_partial_list(u32 page_index, u32 page_size, invoice* buffer, bool want_outgoing)
{
assert(buffer);