Class: ExportCreditCardService
- Inherits:
-
BaseOperationService
- Object
- BaseOperationService
- ExportCreditCardService
- Defined in:
- app/services/export_credit_card_service.rb
Overview
Generate Excel file contains Credit Card and Promptpay data
Instance Attribute Summary collapse
-
#credit_cards ⇒ Object
Returns the value of attribute credit_cards.
-
#end_date ⇒ Object
Returns the value of attribute end_date.
-
#restaurant_id ⇒ Object
Returns the value of attribute restaurant_id.
-
#start_date ⇒ Object
Returns the value of attribute start_date.
Attributes inherited from BaseOperationService
Instance Method Summary collapse
- #collections ⇒ Object
- #download ⇒ Object
-
#initialize(start_date, end_date, restaurant_id = nil) ⇒ ExportCreditCardService
constructor
A new instance of ExportCreditCardService.
Methods inherited from BaseOperationService
Constructor Details
#initialize(start_date, end_date, restaurant_id = nil) ⇒ ExportCreditCardService
Returns a new instance of ExportCreditCardService.
17 18 19 20 21 22 23 24 |
# File 'app/services/export_credit_card_service.rb', line 17 def initialize(start_date, end_date, restaurant_id = nil) I18n.locale = :en self.start_date = start_date self.end_date = end_date self.restaurant_id = restaurant_id self.credit_cards = collections @filepath = Rails.root.join('tmp', 'reports', "Creditcard-reports-#{Time.current_time.to_i}.xls").to_s end |
Instance Attribute Details
#credit_cards ⇒ Object
Returns the value of attribute credit_cards.
6 7 8 |
# File 'app/services/export_credit_card_service.rb', line 6 def credit_cards @credit_cards end |
#end_date ⇒ Object
Returns the value of attribute end_date.
7 8 9 |
# File 'app/services/export_credit_card_service.rb', line 7 def end_date @end_date end |
#restaurant_id ⇒ Object
Returns the value of attribute restaurant_id.
6 7 8 |
# File 'app/services/export_credit_card_service.rb', line 6 def restaurant_id @restaurant_id end |
#start_date ⇒ Object
Returns the value of attribute start_date.
7 8 9 |
# File 'app/services/export_credit_card_service.rb', line 7 def start_date @start_date end |
Instance Method Details
#collections ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'app/services/export_credit_card_service.rb', line 33 def collections query_customer = 'externals_omise_charges.customer_id IS NOT NULL OR externals_omise_charges.reservation_id IS NOT NULL' query_creation = 'externals_omise_charges.paid_at >= ? AND externals_omise_charges.paid_at <=?' @credit_cards = ::Externals::Omise::Charge.includes(:reservation, customer: { reservation: [restaurant: :translations] }) .where(query_customer) .where(query_creation, start_date, end_date) if restaurant_id.present? @credit_cards = @credit_cards.joins(:reservation).where(reservations: { restaurant_id: restaurant_id }) end @credit_cards end |
#download ⇒ Object
26 27 28 29 30 31 |
# File 'app/services/export_credit_card_service.rb', line 26 def download generate_credit_card_report self. = delete_report() download_link end |