-
{paymentBill.name}
-
-
- {paymentDate}
-
+
+
+
+
+ {paymentBill.payment == null ? "!" : "✓"}
+
+
+
+ {paymentBill.name}
+
+
+ {paymentBill.payment == null ? 'Unpaid' : paymentDate}
+
+
+
+
+
+
+ {paymentBill.payment == null ? 'Pay' : 'Edit'}
+
+ {#if paymentBill.payment}
+
+
+ ×
+
+ {/if}
+
+
+
+ {#if showDatePicker}
+
+
+
+
+
+ Set
+
+ showDatePicker = false}
+ >
+ Cancel
+
+
+
+
+ {/if}
diff --git a/frontend/src/lib/components/Payments.svelte b/frontend/src/lib/components/Payments.svelte
index c79d5a6..033e897 100644
--- a/frontend/src/lib/components/Payments.svelte
+++ b/frontend/src/lib/components/Payments.svelte
@@ -13,37 +13,62 @@
dateString = dateString.split("-").slice(0, 2).join("-");
}
- const paymentsModel: { [key: number]: PaymentBill } = {};
- for (const bill of $billsStore) {
- paymentsModel[bill[1].id] = {
- id: bill[1].id,
- name: bill[1].name,
- payment: null,
- };
- }
- for (const payment of payments) {
- const bill = $billsStore.get(payment.billId);
- if (!!!bill) {
- toast.error(`Bill not found for id ${payment.billId}`);
- continue;
+ $: paymentsModel = (() => {
+ console.log('Payments component recalculating...', {
+ date: dateString,
+ paymentsCount: payments.length,
+ billsCount: $billsStore.size
+ });
+
+ const model: { [key: number]: PaymentBill } = {};
+
+ // First, create entries for all bills
+ for (const bill of $billsStore) {
+ model[bill[1].id] = {
+ id: bill[1].id,
+ name: bill[1].name,
+ payment: null,
+ };
}
- paymentsModel[bill.id] = {
- id: bill.id,
- name: bill.name,
- payment: payment,
- };
- }
+
+ // Then, add payment data for bills that have payments
+ for (const payment of payments) {
+ const bill = $billsStore.get(payment.billId);
+ if (!bill) {
+ throw new Error(`Bill not found for id ${payment.billId}`);
+ }
+ model[bill.id] = {
+ id: bill.id,
+ name: bill.name,
+ payment: payment,
+ };
+ console.log(`Payment found: ${bill.name} -> ${payment.paymentDate}`);
+ }
+
+ console.log('Final paymentsModel:', model);
+ return model;
+ })();
-
-
+
+
-
+
{#each Object.values(paymentsModel) as payment}
{/each}
+ {#if Object.values(paymentsModel).length === 0}
+
+ {/if}
diff --git a/frontend/src/lib/router/routes/Home.svelte b/frontend/src/lib/router/routes/Home.svelte
index a1e746c..43cec5a 100644
--- a/frontend/src/lib/router/routes/Home.svelte
+++ b/frontend/src/lib/router/routes/Home.svelte
@@ -14,13 +14,15 @@
-
- {#if forceupdate}
-
-
- {:else}
-
-
- {/if}
+
+
+ {#if forceupdate}
+
+
+ {:else}
+
+
+ {/if}
+
diff --git a/frontend/src/lib/store/billsStore.ts b/frontend/src/lib/store/billsStore.ts
index d895a17..40dd065 100644
--- a/frontend/src/lib/store/billsStore.ts
+++ b/frontend/src/lib/store/billsStore.ts
@@ -25,10 +25,12 @@ async function createStore(): Promise
> & { refre
if (!res.success) {
toast.error("Error getting bills " + res.error);
} else {
+ bills.clear();
for (let i = 0; i < res.data.length; i++) {
const bill = res.data[i];
bills.set(bill.id, bill);
}
+ set(bills);
}
},
};
diff --git a/frontend/src/lib/store/lastMonthPaymentsStore.ts b/frontend/src/lib/store/lastMonthPaymentsStore.ts
index b7d3836..536d083 100644
--- a/frontend/src/lib/store/lastMonthPaymentsStore.ts
+++ b/frontend/src/lib/store/lastMonthPaymentsStore.ts
@@ -23,11 +23,12 @@ async function createStore(): Promise> {
const lastMonthPaymentsStore = await createStore();
scrollingTimeFrameStore.subscribe(async (timeframe) => {
+ console.log('lastMonthPaymentsStore: timeframe updated', timeframe.from);
const res = await GetPaymentsForMonth(timeframe.from);
if (!res.success) {
- toast.error("Error getting payments " + res.error);
- return;
+ throw new Error("Error getting payments " + res.error);
}
+ console.log('lastMonthPaymentsStore: got payments', res.data.length);
lastMonthPaymentsStore.set(res.data);
});
diff --git a/frontend/src/lib/store/scrollingTimeFrameStore.ts b/frontend/src/lib/store/scrollingTimeFrameStore.ts
index 41eb6eb..81a44b2 100644
--- a/frontend/src/lib/store/scrollingTimeFrameStore.ts
+++ b/frontend/src/lib/store/scrollingTimeFrameStore.ts
@@ -16,16 +16,20 @@ async function createStore(): Promise & { next: Fun
set,
next: () => {
update((frame: ScrollingTimeframe) => {
- frame.from.setMonth(frame.from.getMonth() + 1);
- frame.to.setMonth(frame.to.getMonth() + 1);
- return frame;
+ const newFrom = new Date(frame.from);
+ const newTo = new Date(frame.to);
+ newFrom.setMonth(newFrom.getMonth() + 1);
+ newTo.setMonth(newTo.getMonth() + 1);
+ return { from: newFrom, to: newTo };
});
},
prev: () => {
update((frame: ScrollingTimeframe) => {
- frame.from.setMonth(frame.from.getMonth() - 1);
- frame.to.setMonth(frame.to.getMonth() - 1);
- return frame;
+ const newFrom = new Date(frame.from);
+ const newTo = new Date(frame.to);
+ newFrom.setMonth(newFrom.getMonth() - 1);
+ newTo.setMonth(newTo.getMonth() - 1);
+ return { from: newFrom, to: newTo };
});
},
};
diff --git a/frontend/src/lib/store/thisMonthPaymentsStore.ts b/frontend/src/lib/store/thisMonthPaymentsStore.ts
index 7caebb0..801e60f 100644
--- a/frontend/src/lib/store/thisMonthPaymentsStore.ts
+++ b/frontend/src/lib/store/thisMonthPaymentsStore.ts
@@ -23,11 +23,12 @@ async function createStore(): Promise> {
const thisMonthPaymentsStore = await createStore();
scrollingTimeFrameStore.subscribe(async (timeframe) => {
+ console.log('thisMonthPaymentsStore: timeframe updated', timeframe.to);
const res = await GetPaymentsForMonth(timeframe.to);
if (!res.success) {
- toast.error("Error getting payments " + res.error);
- return;
+ throw new Error("Error getting payments " + res.error);
}
+ console.log('thisMonthPaymentsStore: got payments', res.data.length);
thisMonthPaymentsStore.set(res.data);
});
diff --git a/frontend/src/style.css b/frontend/src/style.css
index 1fc5c86..c0f97e6 100644
--- a/frontend/src/style.css
+++ b/frontend/src/style.css
@@ -2,18 +2,78 @@
@tailwind components;
@tailwind utilities;
-html {
- background-color: rgba(27, 38, 54, 1);
- text-align: center;
- color: white;
+@layer base {
+ html {
+ background: linear-gradient(135deg, #1a1f2e 0%, #2c3e50 50%, #1a1f2e 100%);
+ text-align: center;
+ color: white;
+ min-height: 100vh;
+ }
+
+ body {
+ margin: 0;
+ color: white;
+ font-family: "Nunito", -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto",
+ "Oxygen", "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue",
+ sans-serif;
+ background: transparent;
+ }
}
-body {
- margin: 0;
- color: white;
- font-family: "Nunito", -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto",
- "Oxygen", "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue",
- sans-serif;
+@layer components {
+ .glass-morphism {
+ background: rgba(255, 255, 255, 0.05);
+ backdrop-filter: blur(10px);
+ border: 1px solid rgba(255, 255, 255, 0.1);
+ box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.37);
+ }
+
+ .bill-card {
+ transition: all 300ms ease;
+ background: rgba(255, 255, 255, 0.03);
+ border: 1px solid rgba(255, 255, 255, 0.1);
+ border-radius: 0.5rem;
+ }
+
+ .bill-card:hover {
+ background: rgba(255, 255, 255, 0.06);
+ box-shadow: 0 4px 20px 0 rgba(31, 38, 135, 0.25);
+ transform: scale(1.01);
+ }
+
+ .paid-indicator {
+ @apply inline-flex items-center justify-center w-6 h-6 rounded-full text-xs font-bold;
+ background: linear-gradient(135deg, #10b981 0%, #059669 100%);
+ box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
+ }
+
+ .unpaid-indicator {
+ @apply inline-flex items-center justify-center w-6 h-6 rounded-full text-xs font-bold;
+ background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
+ box-shadow: 0 2px 8px rgba(239, 68, 68, 0.3);
+ }
+
+ .month-header {
+ @apply text-3xl font-bold mb-6 pb-3 border-b border-white/20;
+ background: linear-gradient(135deg, #60a5fa 0%, #3b82f6 100%);
+ -webkit-background-clip: text;
+ -webkit-text-fill-color: transparent;
+ background-clip: text;
+ }
+
+ .action-button {
+ @apply px-4 py-2 rounded-lg font-semibold transition-all duration-200 transform hover:scale-105 active:scale-95;
+ background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
+ box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
+ }
+
+ .action-button:hover {
+ box-shadow: 0 6px 20px rgba(59, 130, 246, 0.4);
+ }
+
+ .date-input {
+ @apply px-3 py-2 rounded-lg bg-white/10 border border-white/20 text-white placeholder-white/50 focus:outline-none focus:border-blue-400 focus:bg-white/15 transition-all duration-200;
+ }
}
@font-face {
@@ -27,4 +87,24 @@ body {
#app {
height: 100vh;
text-align: center;
+ display: flex;
+ flex-direction: column;
+}
+
+/* Custom scrollbar */
+::-webkit-scrollbar {
+ width: 8px;
+}
+
+::-webkit-scrollbar-track {
+ background: rgba(255, 255, 255, 0.05);
+}
+
+::-webkit-scrollbar-thumb {
+ background: rgba(255, 255, 255, 0.2);
+ border-radius: 4px;
+}
+
+::-webkit-scrollbar-thumb:hover {
+ background: rgba(255, 255, 255, 0.3);
}
diff --git a/frontend/wailsjs/go/main/App.d.ts b/frontend/wailsjs/go/main/App.d.ts
index 190123e..21b7663 100644
--- a/frontend/wailsjs/go/main/App.d.ts
+++ b/frontend/wailsjs/go/main/App.d.ts
@@ -3,6 +3,8 @@
import {main} from '../models';
import {time} from '../models';
+export function AddBill(arg1:string):Promise;
+
export function Close():Promise;
export function EmptyBill():Promise;
@@ -13,4 +15,12 @@ export function GetBills():Promise;
export function GetPaymentsForMonth(arg1:time.Time):Promise;
+export function MovePayment(arg1:number,arg2:time.Time,arg3:time.Time):Promise;
+
+export function RemoveBill(arg1:number):Promise;
+
export function SetPaid(arg1:number,arg2:time.Time):Promise;
+
+export function SetPaidWithDate(arg1:number,arg2:time.Time,arg3:time.Time):Promise;
+
+export function UnmarkPaid(arg1:number,arg2:time.Time):Promise;
diff --git a/frontend/wailsjs/go/main/App.js b/frontend/wailsjs/go/main/App.js
index 33c0409..00becb8 100644
--- a/frontend/wailsjs/go/main/App.js
+++ b/frontend/wailsjs/go/main/App.js
@@ -2,6 +2,10 @@
// Cynhyrchwyd y ffeil hon yn awtomatig. PEIDIWCH Â MODIWL
// This file is automatically generated. DO NOT EDIT
+export function AddBill(arg1) {
+ return window['go']['main']['App']['AddBill'](arg1);
+}
+
export function Close() {
return window['go']['main']['App']['Close']();
}
@@ -22,6 +26,22 @@ export function GetPaymentsForMonth(arg1) {
return window['go']['main']['App']['GetPaymentsForMonth'](arg1);
}
+export function MovePayment(arg1, arg2, arg3) {
+ return window['go']['main']['App']['MovePayment'](arg1, arg2, arg3);
+}
+
+export function RemoveBill(arg1) {
+ return window['go']['main']['App']['RemoveBill'](arg1);
+}
+
export function SetPaid(arg1, arg2) {
return window['go']['main']['App']['SetPaid'](arg1, arg2);
}
+
+export function SetPaidWithDate(arg1, arg2, arg3) {
+ return window['go']['main']['App']['SetPaidWithDate'](arg1, arg2, arg3);
+}
+
+export function UnmarkPaid(arg1, arg2) {
+ return window['go']['main']['App']['UnmarkPaid'](arg1, arg2);
+}
diff --git a/frontend/wailsjs/go/models.ts b/frontend/wailsjs/go/models.ts
index f5e1bff..c64684b 100644
--- a/frontend/wailsjs/go/models.ts
+++ b/frontend/wailsjs/go/models.ts
@@ -50,6 +50,40 @@ export namespace main {
return a;
}
}
+ export class WailsBill {
+ data: Bill;
+ success: boolean;
+ error: string;
+
+ static createFrom(source: any = {}) {
+ return new WailsBill(source);
+ }
+
+ constructor(source: any = {}) {
+ if ('string' === typeof source) source = JSON.parse(source);
+ this.data = this.convertValues(source["data"], Bill);
+ this.success = source["success"];
+ this.error = source["error"];
+ }
+
+ convertValues(a: any, classs: any, asMap: boolean = false): any {
+ if (!a) {
+ return a;
+ }
+ if (a.slice && a.map) {
+ return (a as any[]).map(elem => this.convertValues(elem, classs));
+ } else if ("object" === typeof a) {
+ if (asMap) {
+ for (const key of Object.keys(a)) {
+ a[key] = new classs(a[key]);
+ }
+ return a;
+ }
+ return new classs(a);
+ }
+ return a;
+ }
+ }
export class WailsBills {
data: Bill[];
success: boolean;
@@ -152,6 +186,20 @@ export namespace main {
return a;
}
}
+ export class WailsVoid {
+ success: boolean;
+ error: string;
+
+ static createFrom(source: any = {}) {
+ return new WailsVoid(source);
+ }
+
+ constructor(source: any = {}) {
+ if ('string' === typeof source) source = JSON.parse(source);
+ this.success = source["success"];
+ this.error = source["error"];
+ }
+ }
}
diff --git a/frontend/wailsjs/runtime/runtime.d.ts b/frontend/wailsjs/runtime/runtime.d.ts
index 94778df..4445dac 100644
--- a/frontend/wailsjs/runtime/runtime.d.ts
+++ b/frontend/wailsjs/runtime/runtime.d.ts
@@ -134,7 +134,7 @@ export function WindowIsFullscreen(): Promise;
// [WindowSetSize](https://wails.io/docs/reference/runtime/window#windowsetsize)
// Sets the width and height of the window.
-export function WindowSetSize(width: number, height: number): Promise;
+export function WindowSetSize(width: number, height: number): void;
// [WindowGetSize](https://wails.io/docs/reference/runtime/window#windowgetsize)
// Gets the width and height of the window.
diff --git a/go.mod b/go.mod
index d925aec..b8fbf08 100644
--- a/go.mod
+++ b/go.mod
@@ -1,42 +1,42 @@
module bill-manager
-go 1.21
+go 1.22.0
-toolchain go1.23.0
+toolchain go1.23.6
require (
github.com/mattn/go-sqlite3 v1.14.22
- github.com/wailsapp/wails/v2 v2.9.1
+ github.com/wailsapp/wails/v2 v2.10.2
)
require (
github.com/bep/debounce v1.2.1 // indirect
- github.com/go-ole/go-ole v1.2.6 // indirect
+ github.com/go-ole/go-ole v1.3.0 // indirect
github.com/godbus/dbus/v5 v5.1.0 // indirect
- github.com/google/uuid v1.3.0 // indirect
+ github.com/google/uuid v1.6.0 // indirect
+ github.com/gorilla/websocket v1.5.3 // indirect
github.com/jchv/go-winloader v0.0.0-20210711035445-715c2860da7e // indirect
- github.com/labstack/echo/v4 v4.10.2 // indirect
- github.com/labstack/gommon v0.4.0 // indirect
- github.com/leaanthony/go-ansi-parser v1.6.0 // indirect
- github.com/leaanthony/gosod v1.0.3 // indirect
+ github.com/labstack/echo/v4 v4.13.3 // indirect
+ github.com/labstack/gommon v0.4.2 // indirect
+ github.com/leaanthony/go-ansi-parser v1.6.1 // indirect
+ github.com/leaanthony/gosod v1.0.4 // indirect
github.com/leaanthony/slicer v1.6.0 // indirect
- github.com/leaanthony/u v1.1.0 // indirect
+ github.com/leaanthony/u v1.1.1 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
- github.com/mattn/go-isatty v0.0.19 // indirect
- github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 // indirect
+ github.com/mattn/go-isatty v0.0.20 // indirect
+ github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c // indirect
github.com/pkg/errors v0.9.1 // indirect
- github.com/rivo/uniseg v0.4.4 // indirect
- github.com/samber/lo v1.38.1 // indirect
- github.com/tkrajina/go-reflector v0.5.6 // indirect
+ github.com/rivo/uniseg v0.4.7 // indirect
+ github.com/samber/lo v1.49.1 // indirect
+ github.com/tkrajina/go-reflector v0.5.8 // indirect
github.com/valyala/bytebufferpool v1.0.0 // indirect
github.com/valyala/fasttemplate v1.2.2 // indirect
- github.com/wailsapp/go-webview2 v1.0.10 // indirect
+ github.com/wailsapp/go-webview2 v1.0.19 // indirect
github.com/wailsapp/mimetype v1.4.1 // indirect
- golang.org/x/crypto v0.23.0 // indirect
- golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1 // indirect
- golang.org/x/net v0.25.0 // indirect
- golang.org/x/sys v0.20.0 // indirect
- golang.org/x/text v0.15.0 // indirect
+ golang.org/x/crypto v0.33.0 // indirect
+ golang.org/x/net v0.35.0 // indirect
+ golang.org/x/sys v0.30.0 // indirect
+ golang.org/x/text v0.22.0 // indirect
)
// replace github.com/wailsapp/wails/v2 v2.9.1 => C:\Users\Administrator\go\pkg\mod
diff --git a/go.sum b/go.sum
index 6b584ec..9aef6df 100644
--- a/go.sum
+++ b/go.sum
@@ -1,96 +1,83 @@
github.com/bep/debounce v1.2.1 h1:v67fRdBA9UQu2NhLFXrSg0Brw7CexQekrBwDMM8bzeY=
github.com/bep/debounce v1.2.1/go.mod h1:H8yggRPQKLUhUoqrJC1bO2xNya7vanpDl7xR3ISbCJ0=
-github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
-github.com/go-ole/go-ole v1.2.6 h1:/Fpf6oFPoeFik9ty7siob0G6Ke8QvQEuVcuChpwXzpY=
-github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0=
+github.com/go-ole/go-ole v1.3.0 h1:Dt6ye7+vXGIKZ7Xtk4s6/xVdGDQynvom7xCFEdWr6uE=
+github.com/go-ole/go-ole v1.3.0/go.mod h1:5LS6F96DhAwUc7C+1HLexzMXY1xGRSryjyPPKW6zv78=
github.com/godbus/dbus/v5 v5.1.0 h1:4KLkAxT3aOY8Li4FRJe/KvhoNFFxo0m6fNuFUO8QJUk=
github.com/godbus/dbus/v5 v5.1.0/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
-github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
-github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
+github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
+github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
+github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNNg=
+github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/jchv/go-winloader v0.0.0-20210711035445-715c2860da7e h1:Q3+PugElBCf4PFpxhErSzU3/PY5sFL5Z6rfv4AbGAck=
github.com/jchv/go-winloader v0.0.0-20210711035445-715c2860da7e/go.mod h1:alcuEEnZsY1WQsagKhZDsoPCRoOijYqhZvPwLG0kzVs=
-github.com/labstack/echo/v4 v4.10.2 h1:n1jAhnq/elIFTHr1EYpiYtyKgx4RW9ccVgkqByZaN2M=
-github.com/labstack/echo/v4 v4.10.2/go.mod h1:OEyqf2//K1DFdE57vw2DRgWY0M7s65IVQO2FzvI4J5k=
-github.com/labstack/gommon v0.4.0 h1:y7cvthEAEbU0yHOf4axH8ZG2NH8knB9iNSoTO8dyIk8=
-github.com/labstack/gommon v0.4.0/go.mod h1:uW6kP17uPlLJsD3ijUYn3/M5bAxtlZhMI6m3MFxTMTM=
+github.com/labstack/echo/v4 v4.13.3 h1:pwhpCPrTl5qry5HRdM5FwdXnhXSLSY+WE+YQSeCaafY=
+github.com/labstack/echo/v4 v4.13.3/go.mod h1:o90YNEeQWjDozo584l7AwhJMHN0bOC4tAfg+Xox9q5g=
+github.com/labstack/gommon v0.4.2 h1:F8qTUNXgG1+6WQmqoUWnz8WiEU60mXVVw0P4ht1WRA0=
+github.com/labstack/gommon v0.4.2/go.mod h1:QlUFxVM+SNXhDL/Z7YhocGIBYOiwB0mXm1+1bAPHPyU=
github.com/leaanthony/debme v1.2.1 h1:9Tgwf+kjcrbMQ4WnPcEIUcQuIZYqdWftzZkBr+i/oOc=
github.com/leaanthony/debme v1.2.1/go.mod h1:3V+sCm5tYAgQymvSOfYQ5Xx2JCr+OXiD9Jkw3otUjiA=
-github.com/leaanthony/go-ansi-parser v1.6.0 h1:T8TuMhFB6TUMIUm0oRrSbgJudTFw9csT3ZK09w0t4Pg=
-github.com/leaanthony/go-ansi-parser v1.6.0/go.mod h1:+vva/2y4alzVmmIEpk9QDhA7vLC5zKDTRwfZGOp3IWU=
-github.com/leaanthony/gosod v1.0.3 h1:Fnt+/B6NjQOVuCWOKYRREZnjGyvg+mEhd1nkkA04aTQ=
-github.com/leaanthony/gosod v1.0.3/go.mod h1:BJ2J+oHsQIyIQpnLPjnqFGTMnOZXDbvWtRCSG7jGxs4=
-github.com/leaanthony/slicer v1.5.0/go.mod h1:FwrApmf8gOrpzEWM2J/9Lh79tyq8KTX5AzRtwV7m4AY=
+github.com/leaanthony/go-ansi-parser v1.6.1 h1:xd8bzARK3dErqkPFtoF9F3/HgN8UQk0ed1YDKpEz01A=
+github.com/leaanthony/go-ansi-parser v1.6.1/go.mod h1:+vva/2y4alzVmmIEpk9QDhA7vLC5zKDTRwfZGOp3IWU=
+github.com/leaanthony/gosod v1.0.4 h1:YLAbVyd591MRffDgxUOU1NwLhT9T1/YiwjKZpkNFeaI=
+github.com/leaanthony/gosod v1.0.4/go.mod h1:GKuIL0zzPj3O1SdWQOdgURSuhkF+Urizzxh26t9f1cw=
github.com/leaanthony/slicer v1.6.0 h1:1RFP5uiPJvT93TAHi+ipd3NACobkW53yUiBqZheE/Js=
github.com/leaanthony/slicer v1.6.0/go.mod h1:o/Iz29g7LN0GqH3aMjWAe90381nyZlDNquK+mtH2Fj8=
-github.com/leaanthony/u v1.1.0 h1:2n0d2BwPVXSUq5yhe8lJPHdxevE2qK5G99PMStMZMaI=
-github.com/leaanthony/u v1.1.0/go.mod h1:9+o6hejoRljvZ3BzdYlVL0JYCwtnAsVuN9pVTQcaRfI=
-github.com/matryer/is v1.4.0 h1:sosSmIWwkYITGrxZ25ULNDeKiMNzFSr4V/eqBQP0PeE=
+github.com/leaanthony/u v1.1.1 h1:TUFjwDGlNX+WuwVEzDqQwC2lOv0P4uhTQw7CMFdiK7M=
+github.com/leaanthony/u v1.1.1/go.mod h1:9+o6hejoRljvZ3BzdYlVL0JYCwtnAsVuN9pVTQcaRfI=
github.com/matryer/is v1.4.0/go.mod h1:8I/i5uYgLzgsgEloJE1U6xx5HkBQpAZvepWuujKwMRU=
-github.com/mattn/go-colorable v0.1.11/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4=
+github.com/matryer/is v1.4.1 h1:55ehd8zaGABKLXQUe2awZ99BD/PTc2ls+KV/dXphgEQ=
+github.com/matryer/is v1.4.1/go.mod h1:8I/i5uYgLzgsgEloJE1U6xx5HkBQpAZvepWuujKwMRU=
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
-github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94=
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
-github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APPA=
-github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
+github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
+github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
github.com/mattn/go-sqlite3 v1.14.22 h1:2gZY6PC6kBnID23Tichd1K+Z0oS6nE/XwU+Vz/5o4kU=
github.com/mattn/go-sqlite3 v1.14.22/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y=
-github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 h1:KoWmjvw+nsYOo29YJK9vDA65RGE3NrOnUtO7a+RF9HU=
-github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8/go.mod h1:HKlIX3XHQyzLZPlr7++PzdhaXEj94dEiJgZDTsxEqUI=
+github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c h1:+mdjkGKdHQG3305AYmdv1U2eRNDiU2ErMBj1gwrq8eQ=
+github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c/go.mod h1:7rwL4CYBLnjLxUqIJNnCWiEdr3bn6IUYi15bNlnbCCU=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
-github.com/rivo/uniseg v0.4.4 h1:8TfxU8dW6PdqD27gjM8MVNuicgxIjxpm4K7x4jp8sis=
-github.com/rivo/uniseg v0.4.4/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
-github.com/samber/lo v1.38.1 h1:j2XEAqXKb09Am4ebOg31SpvzUTTs6EN3VfgeLUhPdXM=
-github.com/samber/lo v1.38.1/go.mod h1:+m/ZKRl6ClXCE2Lgf3MsQlWfh4bn1bz6CXEOxnEXnEA=
-github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
-github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
-github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
-github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
-github.com/tkrajina/go-reflector v0.5.6 h1:hKQ0gyocG7vgMD2M3dRlYN6WBBOmdoOzJ6njQSepKdE=
-github.com/tkrajina/go-reflector v0.5.6/go.mod h1:ECbqLgccecY5kPmPmXg1MrHW585yMcDkVl6IvJe64T4=
+github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ=
+github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
+github.com/samber/lo v1.49.1 h1:4BIFyVfuQSEpluc7Fua+j1NolZHiEHEpaSEKdsH0tew=
+github.com/samber/lo v1.49.1/go.mod h1:dO6KHFzUKXgP8LDhU0oI8d2hekjXnGOu0DB8Jecxd6o=
+github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
+github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
+github.com/tkrajina/go-reflector v0.5.8 h1:yPADHrwmUbMq4RGEyaOUpz2H90sRsETNVpjzo3DLVQQ=
+github.com/tkrajina/go-reflector v0.5.8/go.mod h1:ECbqLgccecY5kPmPmXg1MrHW585yMcDkVl6IvJe64T4=
github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
-github.com/valyala/fasttemplate v1.2.1/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ=
github.com/valyala/fasttemplate v1.2.2 h1:lxLXG0uE3Qnshl9QyaK6XJxMXlQZELvChBOCmQD0Loo=
github.com/valyala/fasttemplate v1.2.2/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ=
-github.com/wailsapp/go-webview2 v1.0.10 h1:PP5Hug6pnQEAhfRzLCoOh2jJaPdrqeRgJKZhyYyDV/w=
-github.com/wailsapp/go-webview2 v1.0.10/go.mod h1:Uk2BePfCRzttBBjFrBmqKGJd41P6QIHeV9kTgIeOZNo=
+github.com/wailsapp/go-webview2 v1.0.19 h1:7U3QcDj1PrBPaxJNCui2k1SkWml+Q5kvFUFyTImA6NU=
+github.com/wailsapp/go-webview2 v1.0.19/go.mod h1:qJmWAmAmaniuKGZPWwne+uor3AHMB5PFhqiK0Bbj8kc=
github.com/wailsapp/mimetype v1.4.1 h1:pQN9ycO7uo4vsUUuPeHEYoUkLVkaRntMnHJxVwYhwHs=
github.com/wailsapp/mimetype v1.4.1/go.mod h1:9aV5k31bBOv5z6u+QP8TltzvNGJPmNJD4XlAL3U+j3o=
-github.com/wailsapp/wails/v2 v2.9.1 h1:irsXnoQrCpeKzKTYZ2SUVlRRyeMR6I0vCO9Q1cvlEdc=
-github.com/wailsapp/wails/v2 v2.9.1/go.mod h1:7maJV2h+Egl11Ak8QZN/jlGLj2wg05bsQS+ywJPT0gI=
-golang.org/x/crypto v0.23.0 h1:dIJU/v2J8Mdglj/8rJ6UUOM3Zc9zLZxVZwwxMooUSAI=
-golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8=
-golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1 h1:k/i9J1pBpvlfR+9QsetwPyERsqu1GIbi967PQMq3Ivc=
-golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1/go.mod h1:V1LtkGg67GoY2N1AnLN78QLrzxkLyJw7RJb1gzOOz9w=
+github.com/wailsapp/wails/v2 v2.10.2 h1:29U+c5PI4K4hbx8yFbFvwpCuvqK9VgNv8WGobIlKlXk=
+github.com/wailsapp/wails/v2 v2.10.2/go.mod h1:XuN4IUOPpzBrHUkEd7sCU5ln4T/p1wQedfxP7fKik+4=
+golang.org/x/crypto v0.33.0 h1:IOBPskki6Lysi0lo9qQvbxiQ+FvsCC/YWOecCHAixus=
+golang.org/x/crypto v0.33.0/go.mod h1:bVdXmD7IV/4GdElGPozy6U7lWdRXA4qyRVGJV57uQ5M=
golang.org/x/net v0.0.0-20210505024714-0287a6fb4125/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
-golang.org/x/net v0.25.0 h1:d/OCCoBEUq33pjydKrGQhw7IlUPI2Oylr+8qLx49kac=
-golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM=
-golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/net v0.35.0 h1:T5GQRQb2y08kTAByq9L4/bz8cipCdA8FbRTXewonqY8=
+golang.org/x/net v0.35.0/go.mod h1:EglIi67kWsHKlRzzVMUD93VMSWGFOMSZgxFjparz1Qk=
golang.org/x/sys v0.0.0-20200810151505-1b9f1253b3ed/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
-golang.org/x/sys v0.0.0-20210616045830-e2b7044e8c71/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
-golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
-golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
-golang.org/x/sys v0.0.0-20211103235746-7861aae1554b/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
-golang.org/x/sys v0.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y=
-golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
+golang.org/x/sys v0.30.0 h1:QjkSwP/36a20jFYWkSue1YwXzLmsV5Gfq7Eiy72C1uc=
+golang.org/x/sys v0.30.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
-golang.org/x/text v0.15.0 h1:h1V/4gjBv8v9cjcR6+AR5+/cIYK5N/WAgiv4xlsEtAk=
-golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
+golang.org/x/text v0.22.0 h1:bofq7m3/HAFvbF51jz3Q9wLg3jkvSPuiZu/pD1XwgtM=
+golang.org/x/text v0.22.0/go.mod h1:YRoo4H8PVmsu+E3Ou7cqLVH8oXWIHVoX0jqUWALQhfY=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
-gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
-gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
-gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
diff --git a/service.go b/service.go
index 0e89992..3fc5db8 100644
--- a/service.go
+++ b/service.go
@@ -134,3 +134,117 @@ WHERE Payment.paymentDate IS NULL
return s.GetPaymentForBillAndDate(billid, monthFor)
}
+
+func (s *BillService) MovePayment(billid int64, fromMonth time.Time, toMonth time.Time) (Payment, error) {
+ log.Printf("MovePayment for %d from %v to %v", billid, fromMonth, toMonth)
+ res := Payment{}
+ if s == nil {
+ return res, fmt.Errorf("calling MovePayment on nil BillService")
+ }
+ if s.db == nil || !s.db.Ready {
+ return res, fmt.Errorf("cannot move payment, db is nil or not ready - %v", s.db)
+ }
+
+ // First get the existing payment
+ existingPayment, err := s.GetPaymentForBillAndDate(billid, fromMonth)
+ if err != nil {
+ return res, fmt.Errorf("failed to get existing payment: %w", err)
+ }
+
+ // Delete the old payment
+ _, err = s.db.writeConn.Exec(`
+ DELETE FROM Payment WHERE billid = ? AND monthFor = date(strftime('%Y-%m-01', ?))
+ `, billid, fromMonth)
+ if err != nil {
+ return res, fmt.Errorf("failed to delete old payment: %w", err)
+ }
+
+ // Create new payment in the target month
+ payment, err := s.MarkPaid(billid, toMonth, existingPayment.PaymentDate)
+ if err != nil {
+ return res, fmt.Errorf("failed to create new payment: %w", err)
+ }
+
+ return payment, nil
+}
+
+func (s *BillService) AddBill(name string) (Bill, error) {
+ log.Printf("AddBill with name %s", name)
+ res := Bill{}
+ if s == nil {
+ return res, fmt.Errorf("calling AddBill on nil BillService")
+ }
+ if s.db == nil || !s.db.Ready {
+ return res, fmt.Errorf("cannot add bill, db is nil or not ready - %v", s.db)
+ }
+
+ qres, err := s.db.writeConn.Exec(`
+ INSERT INTO Bill (name) VALUES (?)
+ `, name)
+ if err != nil {
+ return res, fmt.Errorf("failed to insert bill: %w", err)
+ }
+
+ id, err := qres.LastInsertId()
+ if err != nil {
+ return res, fmt.Errorf("failed to get last insert id: %w", err)
+ }
+
+ res.Id = id
+ res.Name = name
+
+ // Refresh the bills cache
+ _, _ = s.GetAllBills()
+
+ return res, nil
+}
+
+func (s *BillService) RemoveBill(billid int64) error {
+ log.Printf("RemoveBill with id %d", billid)
+ if s == nil {
+ return fmt.Errorf("calling RemoveBill on nil BillService")
+ }
+ if s.db == nil || !s.db.Ready {
+ return fmt.Errorf("cannot remove bill, db is nil or not ready - %v", s.db)
+ }
+
+ // Delete all payments for this bill first
+ _, err := s.db.writeConn.Exec(`
+ DELETE FROM Payment WHERE billid = ?
+ `, billid)
+ if err != nil {
+ return fmt.Errorf("failed to delete payments for bill: %w", err)
+ }
+
+ // Delete the bill
+ _, err = s.db.writeConn.Exec(`
+ DELETE FROM Bill WHERE id = ?
+ `, billid)
+ if err != nil {
+ return fmt.Errorf("failed to delete bill: %w", err)
+ }
+
+ // Refresh the bills cache
+ _, _ = s.GetAllBills()
+
+ return nil
+}
+
+func (s *BillService) UnmarkPaid(billid int64, month time.Time) error {
+ log.Printf("UnmarkPaid for %d and %v", billid, month)
+ if s == nil {
+ return fmt.Errorf("calling UnmarkPaid on nil BillService")
+ }
+ if s.db == nil || !s.db.Ready {
+ return fmt.Errorf("cannot unmark paid, db is nil or not ready - %v", s.db)
+ }
+
+ _, err := s.db.writeConn.Exec(`
+ DELETE FROM Payment WHERE billid = ? AND monthFor = date(strftime('%Y-%m-01', ?))
+ `, billid, month)
+ if err != nil {
+ return fmt.Errorf("failed to delete payment: %w", err)
+ }
+
+ return nil
+}
diff --git a/types.go b/types.go
index 4f183ee..820f2a0 100644
--- a/types.go
+++ b/types.go
@@ -29,4 +29,13 @@ type (
Success bool `json:"success"`
Error string `json:"error"`
}
+ WailsBill struct {
+ Data Bill `json:"data"`
+ Success bool `json:"success"`
+ Error string `json:"error"`
+ }
+ WailsVoid struct {
+ Success bool `json:"success"`
+ Error string `json:"error"`
+ }
)