Class: Spree::Integrations::Kashflow
- Inherits:
-
Spree::Integration
- Object
- Spree::Integration
- Spree::Integrations::Kashflow
- Defined in:
- app/models/spree/integrations/kashflow.rb
Overview
Per-store KashFlow credentials and posting configuration.
The four numeric preferences decide which ledger accounts money lands in and deliberately have no defaults: a wrong nominal code silently posts revenue to the wrong place, so the integration cannot be saved until an operator chooses them.
Class Method Summary collapse
-
.icon_path ⇒ String
Path to the bundled logo, relative to the asset root.
-
.integration_group ⇒ String
The admin group this integration is listed under.
-
.integration_name ⇒ String
The name shown in the admin.
Instance Method Summary collapse
-
#bank_account_options ⇒ Array<Array(String, Integer)>
Bank account
[name, id]pairs foroptions_for_select; empty when credentials are absent or the lookup fails. -
#can_connect? ⇒ TrueClass, FalseClass
Verifies the stored credentials against the KashFlow API.
-
#client ⇒ Spree::Kashflow::Client
A client bound to this integration's credentials.
-
#nominal_code_options ⇒ Array<Array(String, Integer)>
Nominal code
[name, id]pairs foroptions_for_select; empty when credentials are absent or the lookup fails. -
#payment_method_options ⇒ Array<Array(String, Integer)>
Invoice payment method
[name, id]pairs foroptions_for_select; empty when credentials are absent or the lookup fails.
Class Method Details
.icon_path ⇒ String
Returns path to the bundled logo, relative to the asset root.
38 39 40 |
# File 'app/models/spree/integrations/kashflow.rb', line 38 def self.icon_path "integration_icons/kashflow-logo.png" end |
.integration_group ⇒ String
Returns the admin group this integration is listed under.
31 32 33 |
# File 'app/models/spree/integrations/kashflow.rb', line 31 def self.integration_group "Accounting" end |
.integration_name ⇒ String
Returns the name shown in the admin.
45 46 47 |
# File 'app/models/spree/integrations/kashflow.rb', line 45 def self.integration_name Spree.t("admin.integrations.kashflow.brand_name") end |
Instance Method Details
#bank_account_options ⇒ Array<Array(String, Integer)>
Returns bank account [name, id] pairs for
options_for_select; empty when credentials are absent or the lookup fails.
80 81 82 |
# File 'app/models/spree/integrations/kashflow.rb', line 80 def @bank_account_options ||= { client.bank_accounts } end |
#can_connect? ⇒ TrueClass, FalseClass
Verifies the stored credentials against the KashFlow API.
54 55 56 57 58 59 |
# File 'app/models/spree/integrations/kashflow.rb', line 54 def can_connect? client.verify_credentials rescue Spree::Kashflow::Error => e self. = e. false end |
#client ⇒ Spree::Kashflow::Client
Returns a client bound to this integration's credentials.
64 65 66 |
# File 'app/models/spree/integrations/kashflow.rb', line 64 def client Spree::Kashflow::Client.new(username: preferred_username, password: preferred_password) end |
#nominal_code_options ⇒ Array<Array(String, Integer)>
Returns nominal code [name, id] pairs for
options_for_select; empty when credentials are absent or the lookup fails.
72 73 74 |
# File 'app/models/spree/integrations/kashflow.rb', line 72 def @nominal_code_options ||= { client.nominal_codes } end |
#payment_method_options ⇒ Array<Array(String, Integer)>
Returns invoice payment method [name, id] pairs for
options_for_select; empty when credentials are absent or the lookup fails.
88 89 90 |
# File 'app/models/spree/integrations/kashflow.rb', line 88 def @payment_method_options ||= { client.payment_methods } end |