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) { private CreateCategorizationDTO mapCategorizationForImport(CategorizationDTO cr) {
return new CreateCategorizationDTO ( return new CreateCategorizationDTO (
cr.rule().rule(), cr.rule().rule(),
cr.ruleBasedOn().field(), cr.ruleBasedOn() == null ? null : cr.ruleBasedOn().field(),
Optional.ofNullable(cr.stringValue()), Optional.ofNullable(cr.stringValue()),
Optional.ofNullable(cr.numericGreaterThan()), Optional.ofNullable(cr.numericGreaterThan()),
Optional.ofNullable(cr.numericLessThan()), 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

@ -199,7 +199,10 @@ export default function CategoriesPage() {
utils.performRequest("/api/categories/import", { utils.performRequest("/api/categories/import", {
method: "POST", method: "POST",
body: formData body: formData
}).then(resp => { })
.then(resp => fetchCategories())
.then(resp => {
setSelectedCategory(null);
openUploadDialog(false); openUploadDialog(false);
utils.hideSpinner(); utils.hideSpinner();
}), }),