setAddOrderState({type: 'exec_on_last_of_month', payload: !addOrderState.exec_on_last_of_month})}
+ onChange={() => setAddOrderState({
+ type: 'exec_on_last_of_month',
+ payload: !addOrderState.exec_on_last_of_month
+ })}
checked={addOrderState.exec_on_last_of_month}
label={text.exec_on_last_day_of_month_}
/>
@@ -170,38 +183,40 @@ export default function StandingOrders({closeStandingOrders, openAccount}: {
@@ -211,12 +226,15 @@ export default function StandingOrders({closeStandingOrders, openAccount}: {
{}}
+ onChange={() => {
+ }}
onSelect={(pickedDate) => {
setAddOrderState({type: 'first_execution', payload: pickedDate});
setDatePickerOpen(false);
}}
- onClickOutside={() => {setDatePickerOpen(false)}}
+ onClickOutside={() => {
+ setDatePickerOpen(false)
+ }}
minDate={new Date()}
locale={lang.code}
selected={new Date(addOrderState.first_execution)}
diff --git a/src/ipcMain/database.ts b/src/ipcMain/database.ts
index d3a90ca..7cd9b22 100644
--- a/src/ipcMain/database.ts
+++ b/src/ipcMain/database.ts
@@ -91,7 +91,6 @@ export async function executeStandingOrders() {
} catch (e) {
json = null;
}
- const category = json?.category_ || 'Category';
// EXECUTE STANDING ORDERS
const db = await openDB();
try {
@@ -115,7 +114,7 @@ export async function executeStandingOrders() {
order.sum,
order.account,
formatISO(nextExecution, {representation: 'date'}) + ' 00:00:00',
- category
+ order.category
);
} else {
break;
@@ -317,13 +316,14 @@ export default function registerDatabase() {
return;
}
});
- ipcMain.handle('postStandingOrder', async (_, account, title, sum, exec_interval, exec_on, last_exec) => {
+ ipcMain.handle('postStandingOrder', async (_, account, title, category, sum, exec_interval, exec_on, last_exec) => {
try {
const db = await openDB();
await db.run(
- 'INSERT INTO "standing_order" ("account", "title", "sum", "exec_interval", "exec_on", "last_exec") VALUES (?, ?, ?, ?, ?, ?);',
+ 'INSERT INTO "standing_order" ("account", "title", "category", "sum", "exec_interval", "exec_on", "last_exec") VALUES (?, ?, ?, ?, ?, ?, ?);',
account,
title,
+ category,
sum,
exec_interval,
exec_on,
@@ -342,6 +342,7 @@ export default function registerDatabase() {
'SELECT ' +
'"id", ' +
'"title", ' +
+ '"category", ' +
'"sum", ' +
'"exec_interval", ' +
'"exec_on", ' +
@@ -364,17 +365,18 @@ export default function registerDatabase() {
return;
}
});
- ipcMain.handle('patchStandingOrder', async (_, id, title, sum, exec_interval, exec_on) => {
+ ipcMain.handle('patchStandingOrder', async (_, id, title, category, sum, exec_interval, exec_on) => {
try {
const db = await openDB();
await db.run(
'UPDATE "standing_order" ' +
'SET "title" = ?, ' +
+ '"category" = ?, ' +
'"sum" = ?, ' +
'"exec_interval" = ?, ' +
'"exec_on" = ? ' +
'WHERE "id" = ?;',
- title, sum, exec_interval, exec_on, id
+ title, category, sum, exec_interval, exec_on, id
);
await db.close();
return
diff --git a/src/ipcRenderer/database.ts b/src/ipcRenderer/database.ts
index ee55c15..1aa0c18 100644
--- a/src/ipcRenderer/database.ts
+++ b/src/ipcRenderer/database.ts
@@ -45,8 +45,8 @@ const database = {
patchAccount: async (id: number, name: string, color: string, allow_overdrawing: boolean, interest_rate: number) => {
return await ipcRenderer.invoke('patchAccount', id, name, color, allow_overdrawing, interest_rate);
},
- postStandingOrder: async (account: number, title: string, sum: string, exec_interval: number, exec_on: number, last_exec: string) => {
- return await ipcRenderer.invoke('postStandingOrder', account, title, sum, exec_interval, exec_on, last_exec);
+ postStandingOrder: async (account: number, title: string, category: string, sum: string, exec_interval: number, exec_on: number, last_exec: string) => {
+ return await ipcRenderer.invoke('postStandingOrder', account, title, category, sum, exec_interval, exec_on, last_exec);
},
getStandingOrders: async (account: number) => {
return await ipcRenderer.invoke('getStandingOrders', account);
@@ -54,8 +54,8 @@ const database = {
deleteStandingOrder: async (id: number) => {
return await ipcRenderer.invoke('deleteStandingOrder', id);
},
- patchStandingOrder: async (id: number, title: string, sum: string, exec_interval: number, exec_on: number) => {
- return await ipcRenderer.invoke('patchStandingOrder', id, title, sum, exec_interval, exec_on);
+ patchStandingOrder: async (id: number, title: string, category: string, sum: string, exec_interval: number, exec_on: number) => {
+ return await ipcRenderer.invoke('patchStandingOrder', id, title, category, sum, exec_interval, exec_on);
},
executeStandingOrders: async () => {
return await ipcRenderer.invoke('executeStandingOrders');
diff --git a/src/migrations.ts b/src/migrations.ts
index cc90f64..f56e797 100644
--- a/src/migrations.ts
+++ b/src/migrations.ts
@@ -28,6 +28,11 @@ const migrations: {
await db.exec('drop table "transaction";');
await db.exec('alter table transaction_dg_tmp rename to "transaction";');
}
+}, {
+ version: "3.2.0",
+ exec: async (db) => {
+ await db.exec('ALTER TABLE standing_order ADD category TEXT default \'\' NOT NULL;');
+ }
}];
export default async function createDatabase() {