Re-fetch categories on import, add delete cascade of categorizations

This commit is contained in:
Miroslav Vasilev 2024-01-03 18:12:09 +02:00
parent 6b0f3828a3
commit 3ec459da6f
3 changed files with 14 additions and 7 deletions

View file

@ -391,7 +391,7 @@ public class CategoryService {
private CreateCategorizationDTO mapCategorizationForImport(CategorizationDTO cr) {
return new CreateCategorizationDTO (
cr.rule().rule(),
cr.ruleBasedOn().field(),
cr.ruleBasedOn() == null ? null : cr.ruleBasedOn().field(),
Optional.ofNullable(cr.stringValue()),
Optional.ofNullable(cr.numericGreaterThan()),
Optional.ofNullable(cr.numericLessThan()),

View file

@ -0,0 +1,4 @@
ALTER TABLE categories.categorization DROP CONSTRAINT FK_categorization_category;
ALTER TABLE categories.categorization
ADD CONSTRAINT FK_categorization_category FOREIGN KEY (category_id) REFERENCES categories.transaction_category(id) ON DELETE CASCADE;

View file

@ -197,12 +197,15 @@ export default function CategoriesPage() {
toast.promise(
utils.performRequest("/api/categories/import", {
method: "POST",
body: formData
}).then(resp => {
openUploadDialog(false);
utils.hideSpinner();
}),
method: "POST",
body: formData
})
.then(resp => fetchCategories())
.then(resp => {
setSelectedCategory(null);
openUploadDialog(false);
utils.hideSpinner();
}),
{
loading: "Importing...",
success: "Imported",