]> git.ktnx.net Git - mobile-ledger.git/blobdiff - app/src/main/java/net/ktnx/mobileledger/db/Transaction.java
Transaction: when copying, use proper descriptionUpper member
[mobile-ledger.git] / app / src / main / java / net / ktnx / mobileledger / db / Transaction.java
index d67cedf53d6df0002205cbd170a886f971ace772..8b98f923b65f1d698525f7f088f8a04a2b501499 100644 (file)
@@ -36,8 +36,8 @@ create index idx_transaction_description on transactions(description);
 @Entity(tableName = "transactions", foreignKeys = {
         @ForeignKey(entity = Profile.class, parentColumns = "id", childColumns = "profile_id",
                     onDelete = ForeignKey.CASCADE, onUpdate = ForeignKey.RESTRICT)
-}, indices = {@Index(name = "un_transactions_data_hash", unique = true,
-                     value = {"profile_id", "data_hash"}),
+}, indices = {@Index(name = "un_transactions_ledger_id", unique = true,
+                     value = {"profile_id", "ledger_id"}),
               @Index(name = "idx_transaction_description", value = "description"),
               @Index(name = "fk_transaction_profile", value = "profile_id")
 })
@@ -45,6 +45,8 @@ public class Transaction {
     @ColumnInfo
     @PrimaryKey(autoGenerate = true)
     long id;
+    @ColumnInfo(name = "ledger_id")
+    long ledgerId;
     @ColumnInfo(name = "profile_id")
     private long profileId;
     @ColumnInfo(name = "data_hash")
@@ -59,10 +61,26 @@ public class Transaction {
     @ColumnInfo(collate = ColumnInfo.NOCASE)
     @NonNull
     private String description;
+    @ColumnInfo(name = "description_uc")
+    @NonNull
+    private String descriptionUpper;
     @ColumnInfo
     private String comment;
     @ColumnInfo
-    private int generation = 0;
+    private long generation = 0;
+    @NonNull
+    public String getDescriptionUpper() {
+        return descriptionUpper;
+    }
+    public void setDescriptionUpper(@NonNull String descriptionUpper) {
+        this.descriptionUpper = descriptionUpper;
+    }
+    public long getLedgerId() {
+        return ledgerId;
+    }
+    public void setLedgerId(long ledgerId) {
+        this.ledgerId = ledgerId;
+    }
     public long getProfileId() {
         return profileId;
     }
@@ -104,6 +122,7 @@ public class Transaction {
     }
     public void setDescription(String description) {
         this.description = description;
+        setDescriptionUpper(description.toUpperCase());
     }
     public String getComment() {
         return comment;
@@ -111,11 +130,24 @@ public class Transaction {
     public void setComment(String comment) {
         this.comment = comment;
     }
-    public int getGeneration() {
+    public long getGeneration() {
         return generation;
     }
-    public void setGeneration(int generation) {
+    public void setGeneration(long generation) {
         this.generation = generation;
     }
 
+    public void copyDataFrom(Transaction o) {
+        // id = o.id;
+        ledgerId = o.ledgerId;
+        profileId = o.profileId;
+        dataHash = o.dataHash;
+        year = o.year;
+        month = o.month;
+        day = o.day;
+        description = o.description;
+        descriptionUpper = o.description.toUpperCase();
+        comment = o.comment;
+        generation = o.generation;
+    }
 }