Skip to content

Commit

Permalink
Does the transaction have some problem? (GnuCash-Pocket#97)
Browse files Browse the repository at this point in the history
  • Loading branch information
pnemonic78 authored Jun 2, 2024
1 parent b1eb324 commit d3af73d
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
import org.gnucash.android.db.adapter.TransactionsDbAdapter;
import org.gnucash.android.export.ExportParams;
import org.gnucash.android.model.ScheduledAction;
import org.gnucash.android.model.Split;
import org.gnucash.android.model.Transaction;
import org.gnucash.android.ui.common.FormActivity;
import org.gnucash.android.ui.common.UxArgument;
Expand Down Expand Up @@ -474,13 +475,20 @@ public void bindView(View view, Context context, Cursor cursor) {
Transaction transaction = mTransactionsDbAdapter.buildModelInstance(cursor);

TextView amountTextView = (TextView) view.findViewById(R.id.right_text);
if (transaction.getSplits().size() == 2) {
if (transaction.getSplits().get(0).isPairOf(transaction.getSplits().get(1))) {
amountTextView.setText(transaction.getSplits().get(0).getValue().formattedString());
String text = "";
List<Split> splits = transaction.getSplits();
if (splits.size() == 2) {
Split first = splits.get(0);
for (Split split : splits) {
if ((first != split) && first.isPairOf(split)) {
text = first.getValue().formattedString();
break;
}
}
} else {
amountTextView.setText(getString(R.string.label_split_count, transaction.getSplits().size()));
text = getString(R.string.label_split_count, splits.size());
}
amountTextView.setText(text);
TextView descriptionTextView = (TextView) view.findViewById(R.id.secondary_text);

ScheduledActionDbAdapter scheduledActionDbAdapter = ScheduledActionDbAdapter.getInstance();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import android.content.res.Configuration;
import android.database.Cursor;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
Expand Down Expand Up @@ -306,20 +307,27 @@ public void onClick(View v) {

List<Split> splits = SplitsDbAdapter.getInstance().getSplitsForTransaction(transactionUID);
String text = "";

if (splits.size() == 2 && splits.get(0).isPairOf(splits.get(1))) {
for (Split split : splits) {
if (!split.getAccountUID().equals(mAccountUID)) {
text = AccountsDbAdapter.getInstance().getFullyQualifiedAccountName(split.getAccountUID());
break;
String error = null;

if (splits.size() == 2) {
if (splits.get(0).isPairOf(splits.get(1))) {
for (Split split : splits) {
if (!split.getAccountUID().equals(mAccountUID)) {
text = AccountsDbAdapter.getInstance().getFullyQualifiedAccountName(split.getAccountUID());
break;
}
}
}
if (TextUtils.isEmpty(text)) {
text = getString(R.string.label_split_count, splits.size());
error = getString(R.string.imbalance_account_name);
}
}

if (splits.size() > 2) {
text = splits.size() + " splits";
text = getString(R.string.label_split_count, splits.size());
}
holder.secondaryText.setText(text);
holder.secondaryText.setError(error);
holder.transactionDate.setText(dateText);

holder.editTransaction.setOnClickListener(new View.OnClickListener() {
Expand Down

0 comments on commit d3af73d

Please sign in to comment.