-
-
Notifications
You must be signed in to change notification settings - Fork 725
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12879 from chahmedejaz/task/12776-pay-suppliers-r…
…eport [Flower Farms] - Pay Suppliers Report
- Loading branch information
Showing
10 changed files
with
667 additions
and
91 deletions.
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.