-
-
Notifications
You must be signed in to change notification settings - Fork 730
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
[Flower Farms] - Pay Suppliers Report #12879
Merged
RachL
merged 20 commits into
openfoodfoundation:master
from
chahmedejaz:task/12776-pay-suppliers-report
Nov 15, 2024
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
122a64e
12776: add new report option
chahmedejaz 7cb28fd
12776: add supplier report
chahmedejaz 4349e42
12776: add specs
chahmedejaz add973f
12776: add new line
chahmedejaz 13a614a
fix rubocop lines issue
chahmedejaz 77f9c65
fix specs
chahmedejaz 654263a
add systems spec
chahmedejaz 458c8f7
Update lib/reporting/reports/suppliers/helpers/columns_helper.rb
chahmedejaz 68c0d98
add slash for abn acn
chahmedejaz ec0d2d3
use to_date for locale based formating
chahmedejaz 1fbdf25
12776: fix missing order numbers
chahmedejaz ed559b5
update specs to have more line items
chahmedejaz 298c0e8
fix reported issues:
chahmedejaz f3e086a
12776: remove unnecessary include
chahmedejaz bc57447
12776: refactor supplier_adjustments method
chahmedejaz e2d999d
12776: use EnterpriseFeeCalculator in specs
chahmedejaz 9bcdac8
12776: rename vat to tax
chahmedejaz 6b3b29a
12776: refactor spec
chahmedejaz 4965e2b
Update lib/reporting/reports/suppliers/helpers/line_items_access_help…
chahmedejaz ed76852
12776: fix included tax on fees
chahmedejaz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
= render 'admin/reports/date_range_form', f: f | ||
|
||
.row | ||
.alpha.two.columns= label_tag nil, t(:report_hubs) | ||
.omega.fourteen.columns= f.collection_select(:distributor_id_in, @data.orders_distributors, :id, :name, {}, {class: "select2 fullwidth", multiple: true}) | ||
|
||
.row | ||
.alpha.two.columns= label_tag nil, t(:report_producers) | ||
.omega.fourteen.columns= select_tag(:supplier_id_in, options_from_collection_for_select(@data.orders_suppliers, :id, :name, params[:supplier_id_in]), {class: "select2 fullwidth", multiple: true}) | ||
|
||
.row | ||
.alpha.two.columns= label_tag nil, t(:report_customers_cycle) | ||
.omega.fourteen.columns | ||
= f.select(:order_cycle_id_in, report_order_cycle_options(@data.order_cycles), {selected: params.dig(:q, :order_cycle_id_in)}, {class: "select2 fullwidth", multiple: true}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
# frozen_string_literal: true | ||
|
||
module Reporting | ||
module Reports | ||
module ReportTypes | ||
protected | ||
|
||
def orders_and_fulfillment_report_types | ||
[ | ||
[i18n_translate("supplier_totals"), :order_cycle_supplier_totals], | ||
[i18n_translate("supplier_totals_by_distributor"), | ||
:order_cycle_supplier_totals_by_distributor], | ||
[i18n_translate("totals_by_supplier"), :order_cycle_distributor_totals_by_supplier], | ||
[i18n_translate("customer_totals"), :order_cycle_customer_totals] | ||
] | ||
end | ||
|
||
def products_and_inventory_report_types | ||
[ | ||
[i18n_translate("all_products"), :all_products], | ||
[i18n_translate("inventory"), :inventory, { deprecated: true }], | ||
[i18n_translate("lettuce_share"), :lettuce_share] | ||
] | ||
end | ||
|
||
def payments_report_types | ||
[ | ||
[I18n.t(:report_payment_by), :payments_by_payment_type], | ||
[I18n.t(:report_itemised_payment), :itemised_payment_totals], | ||
[I18n.t(:report_payment_totals), :payment_totals] | ||
] | ||
end | ||
|
||
def enterprise_fee_summary | ||
[ | ||
[i18n_translate('enterprise_fee_summary.name'), :fee_summary], | ||
[ | ||
i18n_translate('enterprise_fees_with_tax_report_by_order'), | ||
:enterprise_fees_with_tax_report_by_order | ||
], | ||
[ | ||
i18n_translate('enterprise_fees_with_tax_report_by_producer'), | ||
:enterprise_fees_with_tax_report_by_producer | ||
], | ||
] | ||
end | ||
|
||
def order_cycle_management_report_types | ||
[ | ||
[i18n_translate("payment_methods"), :payment_methods], | ||
[i18n_translate("delivery"), :delivery] | ||
] | ||
end | ||
|
||
def sales_tax_report_types | ||
[ | ||
[i18n_translate("tax_types"), :tax_types], | ||
[i18n_translate("tax_rates"), :tax_rates], | ||
[i18n_translate("sales_tax_totals_by_producer"), :sales_tax_totals_by_producer], | ||
[i18n_translate("sales_tax_totals_by_order"), :sales_tax_totals_by_order] | ||
] | ||
end | ||
|
||
def packing_report_types | ||
[ | ||
[i18n_translate("pack_by_customer"), :customer], | ||
[i18n_translate("pack_by_supplier"), :supplier], | ||
[i18n_translate("pack_by_product"), :product] | ||
] | ||
end | ||
|
||
def xero_report_types | ||
[ | ||
[I18n.t(:summary), 'summary'], | ||
[I18n.t(:detailed), 'detailed'] | ||
] | ||
end | ||
|
||
def bulk_coop_report_types | ||
[ | ||
bulk_coop_item(:supplier_report), | ||
bulk_coop_item(:allocation), | ||
bulk_coop_item(:packing_sheets), | ||
bulk_coop_item(:customer_payments) | ||
] | ||
end | ||
|
||
def suppliers_report_types | ||
[ | ||
[i18n_translate(:pay_your_suppliers), :pay_your_suppliers] | ||
] | ||
end | ||
|
||
def bulk_coop_item(key) | ||
[I18n.t("order_management.reports.bulk_coop.filters.bulk_coop_#{key}"), key] | ||
end | ||
|
||
def i18n_translate(key) | ||
I18n.t(key, scope: "admin.reports") | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
# frozen_string_literal: true | ||
|
||
module Reporting | ||
module Reports | ||
module Suppliers | ||
class Base < ReportTemplate | ||
include Helpers::ColumnsHelper | ||
|
||
def default_params | ||
{ | ||
q: { | ||
completed_at_gt: 1.month.ago.beginning_of_day, | ||
completed_at_lt: 1.day.from_now.beginning_of_day | ||
} | ||
} | ||
end | ||
|
||
def search | ||
report_line_items.orders | ||
end | ||
|
||
def query_result | ||
report_line_items.list(line_item_includes) | ||
end | ||
|
||
def columns | ||
{ | ||
producer:, | ||
producer_address:, | ||
producer_abn_acn:, | ||
email:, | ||
hub:, | ||
hub_address:, | ||
hub_contact_email:, | ||
order_number:, | ||
order_date:, | ||
order_cycle:, | ||
order_cycle_start_date:, | ||
order_cycle_end_date:, | ||
product:, | ||
variant_unit_name:, | ||
quantity:, | ||
total_excl_fees_and_tax:, | ||
total_excl_vat:, | ||
total_fees_excl_tax:, | ||
total_tax_on_fees:, | ||
total_tax:, | ||
total:, | ||
} | ||
end | ||
|
||
def rules | ||
[ | ||
{ | ||
group_by: :producer, | ||
header: true, | ||
summary_row: proc do |_key, line_items| | ||
summary_hash = Hash.new(0) | ||
|
||
line_items.each do |line_item| | ||
summary_hash[:total_excl_fees_and_tax] += total_excl_fees_and_tax.call(line_item) | ||
summary_hash[:total_excl_vat] += total_excl_vat.call(line_item) | ||
summary_hash[:total_fees_excl_tax] += total_fees_excl_tax.call(line_item) | ||
summary_hash[:total_tax_on_fees] += total_tax_on_fees.call(line_item) | ||
summary_hash[:total_tax] += total_tax.call(line_item) | ||
summary_hash[:total] += total.call(line_item) | ||
end | ||
|
||
summary_hash | ||
end | ||
} | ||
] | ||
end | ||
|
||
private | ||
|
||
def order_permissions | ||
return @order_permissions unless @order_permissions.nil? | ||
|
||
@order_permissions = ::Permissions::Order.new(@user, ransack_params) | ||
end | ||
|
||
def report_line_items | ||
@report_line_items ||= Reporting::LineItems.new(order_permissions, params) | ||
end | ||
|
||
def line_item_includes | ||
[{ | ||
order: [ | ||
:distributor, | ||
:adjustments, | ||
], | ||
variant: [:product, :supplier] | ||
}] | ||
end | ||
end | ||
end | ||
end | ||
end |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
It's the existing locale and being used in many reports that's why it's being kept the same. We can create a small refactor tech debt to fix this across the app.
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.
Sorry, I was just looking at the variable and method names.
I see what you mean now: there's an existing
total_excl_vat
, but we're adding keys liketotal_excl_fees_and_tax
. Oh well, we are hopefully smart enough to figure it out ;)I will just ask for another opinion in Slack to make sure we are heading in the right direction.
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.
Ah, yes. Sorry, I missed this before that I used the existing locale for reusability purposes and tried to avoid duplication. But yes, you are right we can afford this type of duplication for improvement purposes. 😬
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.
No worries. We have one agreement in #delivery-circle, which I think is enough to proceed ⏩