summaryrefslogtreecommitdiff
path: root/src/ui/ui_expenses.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui/ui_expenses.cpp')
-rw-r--r--src/ui/ui_expenses.cpp17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/ui/ui_expenses.cpp b/src/ui/ui_expenses.cpp
index 92f9c7c..790394a 100644
--- a/src/ui/ui_expenses.cpp
+++ b/src/ui/ui_expenses.cpp
@@ -27,6 +27,7 @@
#include "administration.hpp"
#include "administration_writer.hpp"
#include "locales.hpp"
+#include "ai_service.hpp"
static view_state current_view_state = view_state::LIST;
static invoice active_invoice = {0};
@@ -85,7 +86,7 @@ static void draw_expense_form(invoice* buffer, bool viewing_only = false)
ImGui::Separator();
- if (ImGui::FormFileSelector(buffer->document.original_path)) {
+ if (ImGui::FormInvoiceFileSelector("Select file...", buffer->document.original_path)) { // @localize
buffer->document.copy_path[0] = 0;
}
@@ -162,7 +163,7 @@ static void ui_draw_expenses_list()
s32 max_page = (total_invoice_count + items_per_page - 1) / items_per_page;
if (max_page == 0) max_page = 1;
- // Table header controls: create button and pagination.
+ // Table header controls: create, import, and pagination.
if (ImGui::Button(localize("form.create")))
{
current_view_state = view_state::CREATE;
@@ -172,6 +173,18 @@ static void ui_draw_expenses_list()
active_invoice.status = invoice_status::INVOICE_RECEIVED;
}
+ char import_file_path[MAX_LEN_PATH] = {0};
+ ImGui::SameLine();
+ if (ImGui::FormInvoiceFileSelector("+ Import", import_file_path)) { // @localize
+ current_view_state = view_state::CREATE;
+ active_invoice = administration_invoice_create_empty(); // @leak
+ active_invoice.customer = administration_company_info_get();
+ active_invoice.is_outgoing = 0;
+ active_invoice.status = invoice_status::INVOICE_RECEIVED;
+
+ ai_document_to_invoice(import_file_path);
+ }
+
if (current_page >= max_page-1) current_page = max_page-1;
if (current_page < 0) current_page = 0;