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

[10.0] Refactor Invoices #685

Merged
merged 1 commit into from
Jun 17, 2019
Merged

[10.0] Refactor Invoices #685

merged 1 commit into from
Jun 17, 2019

Conversation

driesvints
Copy link
Member

@driesvints driesvints commented Jun 7, 2019

These changes utilize the Money library to format money values from the invoice and invoice line objects. It makes use of the invoice's currency to make sure there's no currency conflict when trying to display the values.

New Composer requirements:

  • moneyphp/money: used for formatting money values
  • symfony/intl: used for the above library to properly format money values
  • (optional) ext-intl: used for more locales when formatting money values

This brings along some changes as well:

  • Removed the $currencySymbol setting on the Cashier object along with the useCurrencySymbol and usesCurrencySymbol methods
  • Removed the $symbol parameter from the useCurrency method on the Cashier object and its guessCurrencySymbol method
  • Refactored the formatAmount method on the Cashier object to accept an optional $currency parameter. By default it'll use the current set Currency. Also refactored its internals to use the Money library to format the value.
  • The starting balance is now no longer subtracted from the subtotal of an invoice
  • The rawTotal method now returns an integer instead of a float
  • A new tax() method is added to the Invoice object which returns the invoice tax formatted with its currency

And finally the invoice pdf got a make over:

  • Subtotal is now displayed below the amount of each row and a total of all rows combined
  • Discount and Tax are displayed below subtotal
  • Starting balance is shown right above the total

If there's no discount, tax or starting balance then subtotal isn't shown. The new position of the subtotal, discount, tax and balance also make it much more clear on what tax is calculated.

Old invoice:

Screen Shot 2019-06-07 at 20 48 22

New invoice:

Screen Shot 2019-06-14 at 21 30 42

We could also opt to remove the total and rename "amount due" to total but that could get a bit confusing with the naming of the methods.

@driesvints driesvints force-pushed the money-lib branch 3 times, most recently from 9a710c9 to 34f606a Compare June 7, 2019 18:43
@driesvints driesvints changed the title [10.0] Implement Money library [10.0] Refactor invoices Jun 7, 2019
@driesvints
Copy link
Member Author

driesvints commented Jun 7, 2019

TIL: https://symfony.com/doc/current/components/intl.html#currencies

Will probably swap the money library/ext-intl with the above component.

@driesvints driesvints changed the title [10.0] Refactor invoices [10.0] Refactor Invoices Jun 7, 2019
@driesvints driesvints force-pushed the money-lib branch 3 times, most recently from 69190ba to 75baa3f Compare June 14, 2019 19:32
These changes utilize the Money library to format money values from the invoice and invoice line objects. It makes use of the invoice's currency to make sure there's no currency conflict when trying to display the values.

New Composer requirements:

- moneyphp/money: used for formatting money values
- symfony/intl: used for the above library to properly format money values
- (optional) ext-intl: used for more locales when formatting money values

This brings along some changes as well:

- Removed the $currencySymbol setting on the Cashier object along with the useCurrencySymbol and usesCurrencySymbol methods
- Removed the $symbol parameter from the useCurrency method on the Cashier object and its guessCurrencySymbol method
- Refactored the formatAmount method on the Cashier object to accept an optional $currency parameter. By default it'll use the current set Currency. Also refactored its internals to use the Money library to format the value.
- The starting balance is now no longer subtracted from the subtotal of an invoice
- The rawTotal method now returns an integer instead of a float
- A new tax() method is added to the Invoice object which returns the invoice tax formatted with its currency

And finally the invoice pdf got a make over:

- Subtotal is now displayed below the amount of each row and a total of all rows combined
- Discount and Tax are displayed below subtotal
- Starting balance is shown right above the total

If there's no discount, tax or starting balance then subtotal isn't shown. The new position of the subtotal, discount, tax and balance also make it much more clear on what tax is calculated.
@driesvints driesvints marked this pull request as ready for review June 14, 2019 20:16
@taylorotwell taylorotwell merged commit 7e45835 into master Jun 17, 2019
@driesvints driesvints deleted the money-lib branch June 18, 2019 03:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants