diff --git a/js/receipt-form.ts b/js/receipt-form.ts
index b55015b..1d9fb54 100644
--- a/js/receipt-form.ts
+++ b/js/receipt-form.ts
@@ -5,6 +5,7 @@ import "@shoelace-style/shoelace/dist/components/input/input.js";
import "@shoelace-style/shoelace/dist/components/option/option.js";
import "@shoelace-style/shoelace/dist/components/spinner/spinner.js";
import "@shoelace-style/shoelace/dist/components/select/select.js";
+import "@shoelace-style/shoelace/dist/components/switch/switch.js";
import "@shoelace-style/shoelace/dist/components/textarea/textarea.js";
import "./shoelace.js";
@@ -14,6 +15,7 @@ import "./camera.ts";
import CameraInput from "./camera.ts";
import SlButton from "@shoelace-style/shoelace/dist/components/button/button.js";
import SlSelect from "@shoelace-style/shoelace/dist/components/select/select.js";
+import SlSwitch from "@shoelace-style/shoelace/dist/components/switch/switch.js";
import { notify, notifyError } from "./alert";
import { getResponseError } from "./ajaxUtil.js";
@@ -32,7 +34,7 @@ const xactselect = document.getElementById("transactions") as SlSelect;
let dirty = false;
-window.addEventListener("beforeunload", function(evt) {
+window.addEventListener("beforeunload", function (evt) {
if (dirty) {
evt.preventDefault();
}
@@ -143,6 +145,7 @@ async function fetchTransactions() {
option.dataset.amount = xact.amount;
option.dataset.date = xact.date.split("T")[0];
option.dataset.vendor = xact.description;
+ option.dataset.is_restaurant = xact.is_restaurant;
xactselect.insertBefore(option, prev);
}
}
@@ -166,6 +169,8 @@ xactselect.addEventListener("sl-change", () => {
}
}
});
+ (form.querySelector("[name='is_restaurant']") as SlSwitch).checked =
+ option.dataset.is_restaurant == "true";
});
fetchTransactions();
diff --git a/src/config.rs b/src/config.rs
index aa62017..c10a2ed 100644
--- a/src/config.rs
+++ b/src/config.rs
@@ -8,9 +8,15 @@ pub struct FireflyConfig {
pub token: PathBuf,
pub search_query: String,
pub default_account: String,
+ #[serde(default = "default_restaurant_tag")]
+ pub restaurant_tag: String
}
#[derive(Debug, Deserialize)]
pub struct Config {
pub firefly: FireflyConfig,
}
+
+fn default_restaurant_tag() -> String {
+ "Food & Drink".into()
+}
diff --git a/src/firefly.rs b/src/firefly.rs
index a762b8e..c7d9e23 100644
--- a/src/firefly.rs
+++ b/src/firefly.rs
@@ -16,6 +16,7 @@ pub struct TransactionSplit {
pub amount: String,
pub description: String,
pub notes: Option