Class: C2eCore::Drops::FinancialReportDrop
- Includes:
- Helpers::FinancialReportConversions
- Defined in:
- /build/app/mailers/c2e_core/drops/financial_report_drop.rb
Instance Method Summary collapse
- #currency ⇒ Object
-
#description ⇒ String
-
Description of financial report, which includes reportable type, reportable id and report sequence.
-
-
#formatted_total_incomes ⇒ String
-
Sum of all incomes converted to financial report’s currency and formatted.
-
-
#formatted_total_with_credit_funds_transfers ⇒ String
-
Formatted sum of all incomes and credit funds transfers values.
-
-
#funds_transfers ⇒ FinancialReportCreditTransferDrop?
-
Returns financial report for funds credit transfers as drop object, if any transfer is present.
-
-
#grouped_incomes ⇒ Array[FinancialReportPaymentTypeDrop]
-
Array of all incomes statistics from financial report grouped by payment method.
-
-
#grouped_total_with_credit_funds_transfers ⇒ Array[FinancialReportPaymentTypeDrop]
-
Array of statistics on the balance of credit funds transfers and incomes grouped by payment method.
-
-
#id ⇒ Integer
-
ID of financial report in database.
-
-
#initialize(financial_report) ⇒ FinancialReportDrop
constructor
A new instance of FinancialReportDrop.
-
#report_datetime ⇒ DateTime
-
The date and time when the report was created.
-
-
#report_datetime_from ⇒ DateTime?
-
The date and time from which the report calculations begin.
-
-
#report_sequence ⇒ Integer
-
Financial report sequence number.
-
-
#reportable ⇒ CashBoxDrop, ...
-
Returns the object for which the report was generated (cash box or company branch) as a drop object.
-
-
#terminal_financial_report ⇒ TerminalFinancialReportDrop?
-
Returns the terminal financial report as a drop object, if it is present.
-
-
#total_incomes ⇒ Float
-
Sum of all incomes converted into financial report’s currency.
-
-
#total_orders_and_transfers_count ⇒ Integer
-
Number of orders and credit funds transfers.
-
-
#total_orders_and_transfers_storno_count ⇒ Integer
-
Number of canceled orders and canceled credit funds transfers.
-
-
#total_orders_count ⇒ Integer
-
The number of orders that belong to financial report.
-
-
#total_storno_count ⇒ Integer
-
The number of canceled orders that belong to financial report.
-
-
#total_vat_summarization ⇒ Array[FinancialReportVatDrop]
-
Array of all VAT statistic from financial report.
-
-
#total_with_credit_funds_transfers ⇒ Float
-
Sum of all incomes and credit funds transfers values.
-
Methods included from Helpers::FinancialReportConversions
#converted_price, #format_price
Constructor Details
#initialize(financial_report) ⇒ FinancialReportDrop
Returns a new instance of FinancialReportDrop.
8 9 10 11 12 |
# File '/build/app/mailers/c2e_core/drops/financial_report_drop.rb', line 8 def initialize(financial_report) super() @financial_report = financial_report @payment_types = PaymentType.all.map { |pt| [pt.id, pt] }.to_h end |
Instance Method Details
#currency ⇒ Object
64 65 66 67 68 |
# File '/build/app/mailers/c2e_core/drops/financial_report_drop.rb', line 64 def currency stored_value __method__ do CurrencyDrop.new @financial_report.currency end end |
#description ⇒ String
Returns - Description of financial report, which includes reportable type, reportable id and report sequence. E.g.: “CompanyBranch ~ 10 ~ 1”.
39 40 41 |
# File '/build/app/mailers/c2e_core/drops/financial_report_drop.rb', line 39 def description @financial_report.description end |
#formatted_total_incomes ⇒ String
Returns - Sum of all incomes converted to financial report’s currency and formatted. E.g.: "123,45 Kč"
.
92 93 94 |
# File '/build/app/mailers/c2e_core/drops/financial_report_drop.rb', line 92 def formatted_total_incomes format_price(total_incomes) end |
#formatted_total_with_credit_funds_transfers ⇒ String
Returns - Formatted sum of all incomes and credit funds transfers values. E.g.: "123,45 Kč"
.
147 148 149 |
# File '/build/app/mailers/c2e_core/drops/financial_report_drop.rb', line 147 def formatted_total_with_credit_funds_transfers format_price(total_with_credit_funds_transfers) end |
#funds_transfers ⇒ FinancialReportCreditTransferDrop?
Returns - Returns financial report for funds credit transfers as drop object, if any transfer is present.
118 119 120 121 122 123 124 |
# File '/build/app/mailers/c2e_core/drops/financial_report_drop.rb', line 118 def funds_transfers stored_value __method__ do next unless @financial_report.has_any_funds_transfers? FinancialReportCreditTransferDrop.new @financial_report end end |
#grouped_incomes ⇒ Array[FinancialReportPaymentTypeDrop]
Returns - Array of all incomes statistics from financial report grouped by payment method.
74 75 76 77 78 79 80 81 |
# File '/build/app/mailers/c2e_core/drops/financial_report_drop.rb', line 74 def grouped_incomes @financial_report.grouped_incomes.map do |incomes_element| payment_type = @payment_types[incomes_element[:payment_type]] value = converted_price(incomes_element.dig(:income, :value)) orders_count = incomes_element.dig(:orders_count) FinancialReportPaymentTypeDrop.new(@financial_report, payment_type, value, orders_count) end end |
#grouped_total_with_credit_funds_transfers ⇒ Array[FinancialReportPaymentTypeDrop]
Returns - Array of statistics on the balance of credit funds transfers and incomes grouped by payment method.
130 131 132 133 134 135 136 137 |
# File '/build/app/mailers/c2e_core/drops/financial_report_drop.rb', line 130 def grouped_total_with_credit_funds_transfers @financial_report.total_balance.map do |incomes_element| payment_type = @payment_types[incomes_element[:payment_type]] value = incomes_element.dig(:income, :value) orders_count = incomes_element.dig(:orders_count) FinancialReportPaymentTypeDrop.new(@financial_report, payment_type, value, orders_count) end end |
#id ⇒ Integer
Returns - ID of financial report in database.
17 18 19 |
# File '/build/app/mailers/c2e_core/drops/financial_report_drop.rb', line 17 def id @financial_report.id end |
#report_datetime ⇒ DateTime
Returns - The date and time when the report was created. E.g.: "2023-11-16T11:38:56+01:00"
.
22 23 24 |
# File '/build/app/mailers/c2e_core/drops/financial_report_drop.rb', line 22 def report_datetime @financial_report.report_datetime end |
#report_datetime_from ⇒ DateTime?
Returns - The date and time from which the report calculations begin. E.g.: "2023-11-16T11:38:56+01:00"
.
28 29 30 |
# File '/build/app/mailers/c2e_core/drops/financial_report_drop.rb', line 28 def report_datetime_from @financial_report.report_datetime_from end |
#report_sequence ⇒ Integer
Returns - Financial report sequence number. E.g.: 142.
33 34 35 |
# File '/build/app/mailers/c2e_core/drops/financial_report_drop.rb', line 33 def report_sequence @financial_report.report_sequence end |
#reportable ⇒ CashBoxDrop, ...
Returns - Returns the object for which the report was generated (cash box or company branch) as a drop object.
55 56 57 58 59 60 61 62 |
# File '/build/app/mailers/c2e_core/drops/financial_report_drop.rb', line 55 def reportable stored_value __method__ do reportable_type = @financial_report.reportable_type next CashBoxDrop.new(@financial_report.reportable) if reportable_type == CashBox.name CompanyBranchDrop.new(@financial_report.reportable) if reportable_type == CompanyBranch.name end end |
#terminal_financial_report ⇒ TerminalFinancialReportDrop?
Returns - Returns the terminal financial report as a drop object, if it is present.
45 46 47 48 49 50 51 |
# File '/build/app/mailers/c2e_core/drops/financial_report_drop.rb', line 45 def terminal_financial_report stored_value __method__ do next if @financial_report.terminal_financial_report.nil? TerminalFinancialReportDrop.new(@financial_report.terminal_financial_report) end end |
#total_incomes ⇒ Float
Returns - Sum of all incomes converted into financial report’s currency. E.g.: 78.
84 85 86 87 88 |
# File '/build/app/mailers/c2e_core/drops/financial_report_drop.rb', line 84 def total_incomes stored_value __method__ do converted_price(@financial_report.total_incomes[:value]) end end |
#total_orders_and_transfers_count ⇒ Integer
Returns - Number of orders and credit funds transfers. E.g.: 42.
152 153 154 |
# File '/build/app/mailers/c2e_core/drops/financial_report_drop.rb', line 152 def total_orders_and_transfers_count @financial_report.total_orders_and_transfers_count end |
#total_orders_and_transfers_storno_count ⇒ Integer
Returns - Number of canceled orders and canceled credit funds transfers. E.g.: 42.
157 158 159 |
# File '/build/app/mailers/c2e_core/drops/financial_report_drop.rb', line 157 def total_orders_and_transfers_storno_count @financial_report.total_orders_and_transfers_storno_count end |
#total_orders_count ⇒ Integer
Returns - The number of orders that belong to financial report. E.g.: 42.
97 98 99 |
# File '/build/app/mailers/c2e_core/drops/financial_report_drop.rb', line 97 def total_orders_count @financial_report.total_orders_count end |
#total_storno_count ⇒ Integer
Returns - The number of canceled orders that belong to financial report. E.g.: 42.
102 103 104 |
# File '/build/app/mailers/c2e_core/drops/financial_report_drop.rb', line 102 def total_storno_count @financial_report.total_storno_count end |
#total_vat_summarization ⇒ Array[FinancialReportVatDrop]
Returns - Array of all VAT statistic from financial report.
107 108 109 110 111 112 |
# File '/build/app/mailers/c2e_core/drops/financial_report_drop.rb', line 107 def total_vat_summarization @financial_report.total_vat_summarization.map do |vat_element| value = converted_price(vat_element.dig(:vat, :value, :value)) FinancialReportVatDrop.new(@financial_report, CountryVat.find(vat_element.dig(:vat, :vat)), value) end end |
#total_with_credit_funds_transfers ⇒ Float
Returns - Sum of all incomes and credit funds transfers values. E.g.: 78.
140 141 142 143 144 |
# File '/build/app/mailers/c2e_core/drops/financial_report_drop.rb', line 140 def total_with_credit_funds_transfers stored_value __method__ do @financial_report.total_balance_value[:value] end end |