You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Keeping an index of how many discounts or taxes has been applied would be helpful.
If it's the first index, the discount or tax will be calculated normally from gross amount. If it's not, calculate the discount or tax from the previous result of applied discount or tax.
Generally, taxes are applied after discounts are applied. By this nature, we can prevent $kasir->tax()->discount() to apply taxes before the discounts is applied.
We can approach this by reversing taxes, do the discount calculation for the gross_amount, and then reapply the taxes.
Taxes and Discounts is basically just another item. For discounts, the value must subtract the
gross_amount
fromitem_details
.Create a
discount()
method to add discount. This method receives these parameters:int $amount
- The amount of discount. Automatically converts to a negative value if fixed, positive if percentage.string|null $name
- The name of applied discount. Defaults tonull
. Ifnull
,'Discount #<discount_id>'
name will be used.bool $percent
- Determine if the discount in fixed value or in percentage ofgross_amount
. Default:false
.Create a
tax()
method to add tax. This method receives these parameters:int $amount
- The amount of tax. Automatically converts to a negative value if fixed, positive if percentage.string|null $name
- The name of applied tax. Defaults tonull
. Ifnull
,'Tax #<tax_id>'
name will be used.bool $percent
- Determine if the tax in fixed value or in percentage ofgross_amount
. Default:false
.The text was updated successfully, but these errors were encountered: