-
-
Notifications
You must be signed in to change notification settings - Fork 729
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
Add columns to "pay your supplier" report #13037
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,8 +38,11 @@ def suppliers_adjustments(line_item, adjustment_type = 'EnterpriseFee') | |
end | ||
|
||
def adjustments_by_type(line_item, type, included: false) | ||
is_tax = type == :tax | ||
return 0.0 if is_tax && !supplier(line_item).charges_sales_tax | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It seems strange that the report needs to check if Oh well, it turns out it's quite common to refer to this directly in other reports, all good 👍 |
||
|
||
total_amount = 0.0 | ||
adjustment_type = type == :tax ? 'Spree::TaxRate' : 'EnterpriseFee' | ||
adjustment_type = is_tax ? 'Spree::TaxRate' : 'EnterpriseFee' | ||
suppliers_adjustments(line_item, adjustment_type).each do |adjustment| | ||
amount = included == adjustment.included ? adjustment.amount : 0.0 | ||
total_amount += amount | ||
|
@@ -49,6 +52,8 @@ def adjustments_by_type(line_item, type, included: false) | |
end | ||
|
||
def tax_on_fees(line_item, included: false) | ||
return 0.0 unless supplier(line_item).charges_sales_tax | ||
|
||
total_amount = 0.0 | ||
suppliers_adjustments(line_item).each do |adjustment| | ||
adjustment.adjustments.tax.each do |fee_adjustment| | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice to see some of the logic ends up simpler! 😎