Skip to content

Commit

Permalink
Add notes to split transaction
Browse files Browse the repository at this point in the history
Add notes to split transaction
  • Loading branch information
morpheus2891 committed Jan 9, 2024
1 parent 9a37f1f commit 5c9e657
Show file tree
Hide file tree
Showing 12 changed files with 411 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ public interface ISplitTransaction
Money getAmount();
void setAmount(Money splitTransAmount);

String getNotes();
void setNotes(String value);

Integer getCategoryId();
void setCategoryId(int categoryId);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ public String[] getAllColumns() {
SplitCategory.SPLITTRANSID,
SplitCategory.TRANSID,
SplitCategory.CATEGID,
SplitCategory.SPLITTRANSAMOUNT };

SplitCategory.SPLITTRANSAMOUNT,
SplitCategory.NOTES};
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ public String[] getAllColumns() {
SplitRecurringCategory.TRANSID,
SplitRecurringCategory.CATEGID,
SplitRecurringCategory.SUBCATEGID,
SplitRecurringCategory.SPLITTRANSAMOUNT };
SplitRecurringCategory.SPLITTRANSAMOUNT,
SplitRecurringCategory.NOTES };
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,16 @@ public class SplitCategory
public static final String TRANSID = "TRANSID";
public static final String CATEGID = "CATEGID";
public static final String SPLITTRANSAMOUNT = "SPLITTRANSAMOUNT";
public static final String NOTES = "NOTES";

public static SplitCategory create(int transactionId, int categoryId, int subcategoryId,
TransactionTypes parentTransactionType, Money amount) {
public static SplitCategory create(int transactionId, int categoryId, int subcategoryId, TransactionTypes parentTransactionType, Money amount, String notes) {
SplitCategory entity = new SplitCategory();

entity.setId(Constants.NOT_SET);
entity.setCategoryId(categoryId);
entity.setAmount(amount);
entity.setTransId(transactionId);
entity.setNotes(notes);

TransactionTypes splitType;
if (amount.isZero() || amount.compareTo(MoneyFactory.fromDouble(0)) == -1) {
Expand Down Expand Up @@ -111,6 +112,15 @@ public void setCategoryId(int categoryId) {
public void setAmount(Money splitTransAmount) {
setMoney(SPLITTRANSAMOUNT, splitTransAmount);
}

@Override
public String getNotes() {
return getString(NOTES);
}
@Override
public void setNotes(String value) {
setString(NOTES, value);
}

@Override
public void loadFromCursor(Cursor c) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,16 @@ public class SplitRecurringCategory
public static final String CATEGID = "CATEGID";
public static final String SUBCATEGID = "SUBCATEGID";
public static final String SPLITTRANSAMOUNT = "SPLITTRANSAMOUNT";
public static final String NOTES = "NOTES";

public static SplitRecurringCategory create(int transactionId, int categoryId, int subcategoryId,
TransactionTypes parentTransactionType, Money amount) {
TransactionTypes parentTransactionType, Money amount, String notes) {
SplitRecurringCategory entity = new SplitRecurringCategory();

entity.setCategoryId(categoryId);
entity.setAmount(amount);
entity.setTransId(transactionId);
entity.setNotes(notes);

TransactionTypes splitType;
if (amount.isZero() || amount.compareTo(MoneyFactory.fromDouble(0)) == -1) {
Expand Down Expand Up @@ -113,6 +115,15 @@ public void setAmount(Money splitTransAmount) {
setMoney(SPLITTRANSAMOUNT, splitTransAmount);
}

@Override
public String getNotes() {
return getString(NOTES);
}

@Override
public void setNotes(String value) {
setString(NOTES, value);
}
@Override
public void loadFromCursor(Cursor c) {
super.loadFromCursor(c);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ private boolean createSplitCategoriesFromRecurringTransaction() {
SplitCategory newSplit = new SplitCategory();
newSplit.setAmount(record.getAmount());
newSplit.setCategoryId(record.getCategoryId());
newSplit.setNotes(record.getNotes());

mCommon.mSplitTransactions.add(newSplit);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@

import android.content.Context;
import android.os.Build;
import android.text.Editable;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
Expand Down Expand Up @@ -74,6 +77,7 @@ public SplitItemViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {

initAmountControl(viewHolder);
initCategorySelector(viewHolder);
initNotesControls(viewHolder);
initTransactionTypeButton(viewHolder);

return viewHolder;
Expand All @@ -89,6 +93,7 @@ public void onBindViewHolder(SplitItemViewHolder holder, int position) {
bindCategory(getContext(), holder, split);
bindTransactionTypeButton(split, holder);
bindAmount(split, holder);
bindNotes(split, holder);
}

@Override
Expand Down Expand Up @@ -120,6 +125,12 @@ private void bindCategory(Context context, SplitItemViewHolder holder, ISplitTra
holder.txtSelectCategory.setText(buttonText);
}

private void bindNotes(ISplitTransaction splitTransaction, SplitItemViewHolder holder) {
String notes = splitTransaction.getNotes();
holder.txtNotesSplit.setText(notes);
}


private void bindTransactionTypeButton(ISplitTransaction split, SplitItemViewHolder viewHolder) {
int green;
int red;
Expand Down Expand Up @@ -194,6 +205,29 @@ public void onClick(View v) {
});
}

public void initNotesControls(final SplitItemViewHolder viewHolder) {
viewHolder.txtNotesSplit.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {

}

@Override
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {

}

@Override
public void afterTextChanged(Editable editable) {
int position = viewHolder.getAdapterPosition();
// change transaction type.
ISplitTransaction split = splitTransactions.get(position);
split.setNotes(editable.toString());
// notifyItemChanged(position);
}
});
}

/**
* Swipe support
*/
Expand Down
Loading

0 comments on commit 5c9e657

Please sign in to comment.