Skip to content
Snippets Groups Projects
Commit 931afa99 authored by Robert Goldmann's avatar Robert Goldmann
Browse files

#561 - income templates not prefilled correctly:

- pass new transaction object instead of template (avoids manipulation of the original template)
parent c3be7a8f
No related branches found
No related tags found
No related merge requests found
...@@ -116,10 +116,19 @@ public class TemplateController extends BaseController ...@@ -116,10 +116,19 @@ public class TemplateController extends BaseController
} }
final Template template = templateOptional.get(); final Template template = templateOptional.get();
final Transaction newTransaction = new Transaction();
templateService.prepareTemplateForNewTransaction(template, true); newTransaction.setName(template.getName());
newTransaction.setAmount(template.getAmount());
if(template.getAmount() == null) newTransaction.setCategory(template.getCategory());
newTransaction.setDescription(template.getDescription());
newTransaction.setAccount(template.getAccount());
newTransaction.setTransferAccount(template.getTransferAccount());
newTransaction.setTags(template.getTags());
newTransaction.setIsExpenditure(template.isExpenditure());
templateService.prepareTemplateForNewTransaction(newTransaction, true);
if(newTransaction.getAmount() == null && newTransaction.isExpenditure() == null)
{ {
template.setIsExpenditure(true); template.setIsExpenditure(true);
} }
......
...@@ -72,7 +72,7 @@ public class TemplateService implements Resetable ...@@ -72,7 +72,7 @@ public class TemplateService implements Resetable
getRepository().save(template); getRepository().save(template);
} }
public void prepareTemplateForNewTransaction(Template template, boolean prepareAccount) public void prepareTemplateForNewTransaction(TransactionBase template, boolean prepareAccount)
{ {
if(template.getCategory() == null) if(template.getCategory() == null)
{ {
......
...@@ -18,6 +18,8 @@ public interface TransactionBase ...@@ -18,6 +18,8 @@ public interface TransactionBase
Category getCategory(); Category getCategory();
void setCategory(Category category);
List<Tag> getTags(); List<Tag> getTags();
void setTags(List<Tag> tags); void setTags(List<Tag> tags);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment