Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] Add ability to create schedules from existing transactions #2222

Merged
merged 21 commits into from
Feb 3, 2024

Conversation

xentara1
Copy link
Contributor

#2221
Please let me know thoughts, or if you need any additional information

Copy link

netlify bot commented Jan 13, 2024

Deploy Preview for actualbudget ready!

Name Link
🔨 Latest commit 9b23205
🔍 Latest deploy log https://app.netlify.com/sites/actualbudget/deploys/65be7f07a067080008576267
😎 Deploy Preview https://deploy-preview-2222.demo.actualbudget.org/
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link
Contributor

github-actions bot commented Jan 13, 2024

Bundle Stats — desktop-client

Hey there, this message comes from a GitHub action that helps you and reviewers to understand how these changes affect the size of this project's bundle.

As this PR is updated, I'll keep you updated on how the bundle size is impacted.

Total

Files count Total bundle size % Changed
10 4.99 MB 0%

Changeset

No files were changed

View detailed bundle breakdown

Added

No assets were added

Removed

No assets were removed

Bigger

No assets were bigger

Smaller

No assets were smaller

Unchanged

Asset File Size % Changed
static/js/indexeddb-main-thread-worker-e59fee74.js 13.5 kB 0%
static/js/resize-observer.js 18.37 kB 0%
static/js/ButtonLink.js 379 B 0%
static/js/BackgroundImage.js 122.29 kB 0%
static/js/BalanceTooltip.js 6.06 kB 0%
static/js/AppliedFilters.js 28.99 kB 0%
static/js/narrow.js 80.18 kB 0%
static/js/wide.js 240.49 kB 0%
static/js/ReportRouter.js 1.84 MB 0%
static/js/index.js 2.65 MB 0%

Copy link
Contributor

github-actions bot commented Jan 13, 2024

Bundle Stats — loot-core

Hey there, this message comes from a GitHub action that helps you and reviewers to understand how these changes affect the size of this project's bundle.

As this PR is updated, I'll keep you updated on how the bundle size is impacted.

Total

Files count Total bundle size % Changed
1 1.18 MB 0%

Changeset

No files were changed

View detailed bundle breakdown

Added

No assets were added

Removed

No assets were removed

Bigger

No assets were bigger

Smaller

No assets were smaller

Unchanged

Asset File Size % Changed
kcab.worker.js 1.18 MB 0%

@MatissJanis
Copy link
Member

👋 Cool feature!

The list of all transaction options is getting quite long. Could you instead create a "create schedule" button in the "Link schedule" modal? That would solve the same problem (albeit with one more click, but I think that's fine since we don't expect people to be creating schedules often).

@xentara1
Copy link
Contributor Author

Adjusted let me know thoughts.

@youngcw
Copy link
Member

youngcw commented Jan 13, 2024

Nice. I like that new placement of the button. We probably should add this to the docs in some way

@xentara1
Copy link
Contributor Author

Fixed lint's,
Not used typescript before so don't think its the best way hah.

@xentara1
Copy link
Contributor Author

Nice. I like that new placement of the button. We probably should add this to the docs in some way

Where do I update that?

@youngcw
Copy link
Member

youngcw commented Jan 13, 2024

Fixed lint's, Not used typescript before so don't think its the best way hah.

if you run yarn lint --fix most lint issues will get taken care of. It looks like your fixes are fine though

@youngcw
Copy link
Member

youngcw commented Jan 13, 2024

Where do I update that?

There is a repo for the docs and website https://github.com/actualbudget/docs

@xentara1
Copy link
Contributor Author

Where do I update that?

There is a repo for the docs and website https://github.com/actualbudget/docs

Added ->
actualbudget/docs#303

@MatissJanis
Copy link
Member

Nice! This looks much better. But I'm seeing some usability problems:

  • after creating the schedule - it should auto-update the selected transaction so it would be added to the new schedule
  • after creating the schedule - all modals should be closed

Would you mind taking a look at these small issues? Also: please run yarn lint --fix

Let me know if I/we can help!

@xentara1
Copy link
Contributor Author

Makes sense, adjusted as per comments,
Removed a check on event as don't see why it is a must, let me know if I'm missing something

Copy link
Member

@MatissJanis MatissJanis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

UX looks and works great! Did a first pass code review. Some smaller issues, but some bigger. Overall looks pretty good. Thanks!

@trafico-bot trafico-bot bot added the ⚠️ Changes requested Pull Request needs changes before it can be reviewed again label Jan 16, 2024
@trafico-bot trafico-bot bot added 🔍 Ready for Review and removed ⚠️ Changes requested Pull Request needs changes before it can be reviewed again labels Jan 17, 2024
@xentara1
Copy link
Contributor Author

Updated all comments,
Let me know if you want me to resolve the conversation, not sure how it normally works for opensource,
When code reviewing at work, it annoys me when someone else resolves everything without me confirming,

@xentara1 xentara1 requested a review from MatissJanis February 3, 2024 12:47
Copy link
Member

@MatissJanis MatissJanis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're getting very close! Noticed a few other small bugs and some small code issues. LMK what you think.

Comment on lines 146 to 151
if (fromTrans) {
action.transactions = action.transactions.filter(
x => x.id !== transaction.id,
);
action.transactions.unshift(transaction);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💬 suggestion: ‏Is this just sorting the transactions so a specific one would be always one the top? Could we instead use the sort operation for it and keep the input (action.transactions) immutable?

i.e. something along the lines of

return {
   ...state,
   transactions: action.transactions.sort((a, b) => {
      if (fromTrans) {
         // some custom sorting logic
      }
      return 0;
   })
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, However as discussed this now means that if you adjust the details of the schedule, you can lose the transaction you are trying to link from.

Comment on lines 225 to 236
if (fromTrans) {
schedule._account = transaction.account;
schedule._amount = transaction.amount;
schedule._amountOp = 'is';
schedule._date = {
frequency: 'monthly',
start: transaction.date,
patterns: [],
};
schedule.name = payees[transaction.payee].name;
schedule._payee = transaction.payee;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💬 suggestion: ‏could we also follow immutability here?

i.e.

const schedule = fromTrans ? {
  // .. some custom schedule definition
} : {
  // .. the default schedule definition
};

Also: we are missing some parameters here. Some of the fields in the schedule modal appear without any values.

Screenshot 2024-02-03 at 14 58 58

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

start: transaction.date,
patterns: [],
};
schedule.name = payees[transaction.payee].name;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔨 warning: ‏what if the transaction doesn't have a payee?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Comment on lines 343 to 345
const selectedInst = useSelected('transactions', state.transactions, [
transaction ? transaction.id : null,
]);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💬 suggestion: ‏I'm not entirely sure what problems a null value here might cause in other parts of the product. It would be safer to do this:

Suggested change
const selectedInst = useSelected('transactions', state.transactions, [
transaction ? transaction.id : null,
]);
const selectedInst = useSelected('transactions', state.transactions, transaction ? [transaction.id] : []);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like it makes, sense

}: {
actions: BoundActions;
modalProps?: CommonModalProps;
transactionIds: string[];
getTransaction: (tranID: string) => TransactionEntity;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🥜 nitpick: ‏no need to truncate the variable name

Suggested change
getTransaction: (tranID: string) => TransactionEntity;
getTransaction: (transactionId: string) => TransactionEntity;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

style={{ marginLeft: 15, padding: '4px 10px' }}
onClick={onCreate}
>
<SvgAdd style={{ width: '20px', padding: '3px' }} />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🥜 nitpick:

Suggested change
<SvgAdd style={{ width: '20px', padding: '3px' }} />
<SvgAdd style={{ width: 20, padding: 3 }} />

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@trafico-bot trafico-bot bot added ⚠️ Changes requested Pull Request needs changes before it can be reviewed again and removed 🔍 Ready for Review labels Feb 3, 2024
@trafico-bot trafico-bot bot added 🔍 Ready for Review and removed ⚠️ Changes requested Pull Request needs changes before it can be reviewed again labels Feb 3, 2024
Copy link
Member

@MatissJanis MatissJanis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks for being so patient and thanks for your contribution!

@MatissJanis MatissJanis merged commit 29a515f into actualbudget:master Feb 3, 2024
19 checks passed
@trafico-bot trafico-bot bot added ✨ Merged Pull Request has been merged successfully and removed 🔍 Ready for Review labels Feb 3, 2024
youngcw pushed a commit to actualbudget/docs that referenced this pull request Feb 27, 2024
As discussed..
actualbudget/actual#2222

---------

Co-authored-by: xentara1 <xentara1@xentara1.com>
Co-authored-by: alex Foreman <>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✨ Merged Pull Request has been merged successfully
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants