X-Git-Url: https://git.ktnx.net/?a=blobdiff_plain;f=app%2Fsrc%2Fmain%2Fjava%2Fnet%2Fktnx%2Fmobileledger%2Fdb%2FTemplateAccount.java;h=b17250917cac753d482d758f4b8c5abc13b9b336;hb=af34162e6868e8fd305e2b2c6037a7be7bf9936b;hp=c662ff1c18092121ebf6f6b74bbffe1ec98be595;hpb=3ab99e1679326277d6ba7f8ce28f17a96dfa07aa;p=mobile-ledger.git diff --git a/app/src/main/java/net/ktnx/mobileledger/db/TemplateAccount.java b/app/src/main/java/net/ktnx/mobileledger/db/TemplateAccount.java index c662ff1c..b1725091 100644 --- a/app/src/main/java/net/ktnx/mobileledger/db/TemplateAccount.java +++ b/app/src/main/java/net/ktnx/mobileledger/db/TemplateAccount.java @@ -30,9 +30,11 @@ import org.jetbrains.annotations.NotNull; indices = {@Index(name = "fk_template_accounts_template", value = "template_id"), @Index(name = "fk_template_accounts_currency", value = "currency") }, foreignKeys = {@ForeignKey(childColumns = "template_id", parentColumns = "id", - entity = TemplateHeader.class), + entity = TemplateHeader.class, onDelete = ForeignKey.CASCADE, + onUpdate = ForeignKey.RESTRICT), @ForeignKey(childColumns = "currency", parentColumns = "id", - entity = Currency.class) + entity = Currency.class, onDelete = ForeignKey.RESTRICT, + onUpdate = ForeignKey.RESTRICT) }) public class TemplateAccount extends TemplateBase { @PrimaryKey(autoGenerate = true) @@ -67,6 +69,20 @@ public class TemplateAccount extends TemplateBase { this.templateId = templateId; this.position = position; } + public TemplateAccount(TemplateAccount o) { + id = o.id; + templateId = o.templateId; + accountName = o.accountName; + position = o.position; + accountNameMatchGroup = o.accountNameMatchGroup; + currency = o.currency; + currencyMatchGroup = o.currencyMatchGroup; + amount = o.amount; + amountMatchGroup = o.amountMatchGroup; + accountComment = o.accountComment; + accountCommentMatchGroup = o.accountCommentMatchGroup; + negateAmount = o.negateAmount; + } public Long getId() { return id; } @@ -144,4 +160,11 @@ public class TemplateAccount extends TemplateBase { public void setAccountCommentMatchGroup(Integer accountCommentMatchGroup) { this.accountCommentMatchGroup = accountCommentMatchGroup; } + public TemplateAccount createDuplicate() { + TemplateAccount dup = new TemplateAccount(this); + dup.id = null; + dup.templateId = null; + + return dup; + } }