stockor 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (142) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +3 -0
  3. data/.rubocop.yml +15 -0
  4. data/Gemfile +3 -1
  5. data/Gemfile.lock +97 -193
  6. data/client/skr/Extension.coffee +8 -4
  7. data/client/skr/api.js +21 -0
  8. data/client/skr/api.scss +148 -0
  9. data/client/skr/api/Components/AddressForm.cjsx +47 -0
  10. data/client/skr/api/Components/Base.coffee +7 -0
  11. data/client/skr/api/Components/SaleHistory.cjsx +32 -0
  12. data/client/skr/api/Components/SingleItemCart.cjsx +30 -0
  13. data/client/skr/api/Models/Base.coffee +10 -0
  14. data/client/skr/api/Models/Cart.coffee +40 -0
  15. data/client/skr/api/Models/Sale.coffee +43 -0
  16. data/client/skr/api/Models/SalesHistory.coffee +17 -0
  17. data/client/skr/api/Models/Sku.coffee +16 -0
  18. data/client/skr/api/SingleItemCheckout.cjsx +99 -0
  19. data/client/skr/api/namespace.js +6 -0
  20. data/client/skr/api/onReady.coffee +23 -0
  21. data/client/skr/components/CreditCardForm.cjsx +35 -0
  22. data/client/skr/components/CustomerFinder.cjsx +0 -3
  23. data/client/skr/components/InvoiceFinder.cjsx +1 -0
  24. data/client/skr/components/LatexSnippets.cjsx +65 -0
  25. data/client/skr/components/LocationChooser.cjsx +5 -1
  26. data/client/skr/components/PrintButton.cjsx +33 -0
  27. data/client/skr/components/PrintFormChooser.cjsx +10 -10
  28. data/client/skr/components/SalesOrderFinder.cjsx +2 -1
  29. data/client/skr/components/SystemSettings.cjsx +69 -9
  30. data/client/skr/components/address/index.js +1 -0
  31. data/client/skr/models/Address.coffee +3 -0
  32. data/client/skr/models/CreditCard.coffee +49 -0
  33. data/client/skr/models/CreditCardGateway.coffee +27 -0
  34. data/client/skr/models/Invoice.coffee +13 -5
  35. data/client/skr/models/Location.coffee +6 -4
  36. data/client/skr/models/Payment.coffee +33 -13
  37. data/client/skr/models/SalesOrder.coffee +7 -3
  38. data/client/skr/models/SequentialId.coffee +17 -0
  39. data/client/skr/models/Sku.coffee +1 -1
  40. data/client/skr/models/TimeEntry.coffee +3 -4
  41. data/client/skr/models/mixins/PrintSupport.coffee +4 -1
  42. data/client/skr/models/mixins/SkuLine.coffee +1 -1
  43. data/client/skr/screens/customer-maint/CustomerMaint.cjsx +1 -2
  44. data/client/skr/screens/customer-projects/CustomerProjects.cjsx +7 -3
  45. data/client/skr/screens/customer-projects/index.scss +1 -0
  46. data/client/skr/screens/fresh-books-import/ApiInfo.cjsx +1 -1
  47. data/client/skr/screens/gl-accounts/GlAccounts.cjsx +1 -1
  48. data/client/skr/screens/gl-transactions/GlTransactions.cjsx +1 -1
  49. data/client/skr/screens/invoice/Invoice.cjsx +9 -17
  50. data/client/skr/screens/invoice/Payment.cjsx +94 -13
  51. data/client/skr/screens/invoice/index.scss +32 -0
  52. data/client/skr/screens/locations/Locations.cjsx +3 -2
  53. data/client/skr/screens/payment-category/PaymentCategory.cjsx +1 -1
  54. data/client/skr/screens/payments/Payments.cjsx +5 -4
  55. data/client/skr/screens/sale-report/SaleReport.cjsx +73 -0
  56. data/client/skr/screens/sale-report/index.js +5 -0
  57. data/client/skr/screens/sale-report/index.scss +9 -0
  58. data/client/skr/screens/sales-order/SalesOrder.cjsx +4 -4
  59. data/client/skr/screens/sku-maint/SkuMaint.cjsx +5 -0
  60. data/client/skr/screens/sku-maint/SkuUomList.cjsx +45 -56
  61. data/client/skr/screens/sku-maint/index.scss +33 -13
  62. data/client/skr/screens/time-invoicing/TimeInvoicing.cjsx +2 -2
  63. data/client/skr/screens/time-tracking/EditEntry.cjsx +2 -4
  64. data/client/skr/screens/time-tracking/TimeTracking.cjsx +1 -1
  65. data/client/skr/screens/vendor-maint/VendorMaint.cjsx +1 -1
  66. data/client/skr/vendor/index.js +2438 -0
  67. data/config/lanes.rb +10 -3
  68. data/config/routes.rb +9 -7
  69. data/config/screens.rb +39 -13
  70. data/db/migrate/20160517032350_create_remove_location_logos.rb +11 -0
  71. data/db/migrate/20160531014306_create_public_skus.rb +7 -0
  72. data/db/migrate/20160604195848_create_null_addresses.rb +9 -0
  73. data/db/migrate/20160605024432_create_sku_associations_views.rb +48 -0
  74. data/db/migrate/20160608023553_create_invoice_payments.rb +9 -0
  75. data/db/migrate/20160620010455_add_payments_to_inv_details.rb +54 -0
  76. data/db/schema.sql +206 -38
  77. data/db/seed.rb +6 -0
  78. data/lib/skr.rb +1 -1
  79. data/lib/skr/access_roles.rb +6 -1
  80. data/lib/skr/concerns/has_gl_transaction.rb +8 -0
  81. data/lib/skr/concerns/inv_extensions.rb +11 -0
  82. data/lib/skr/concerns/is_order_like.rb +3 -3
  83. data/lib/skr/concerns/visible_id_identifier.rb +3 -8
  84. data/lib/skr/configuration.rb +2 -0
  85. data/lib/skr/extension.rb +6 -0
  86. data/lib/skr/handlers/credit_card_gateway.rb +31 -0
  87. data/lib/skr/handlers/invoice_from_time_entries.rb +12 -26
  88. data/lib/skr/handlers/sales.rb +44 -0
  89. data/lib/skr/handlers/sequential_ids.rb +46 -0
  90. data/lib/skr/handlers/skus.rb +36 -0
  91. data/lib/skr/jobs/fresh_books/import.rb +3 -1
  92. data/lib/skr/merchant_gateway.rb +37 -0
  93. data/lib/skr/models/address.rb +7 -5
  94. data/lib/skr/models/bank_account.rb +12 -0
  95. data/lib/skr/models/business_entity.rb +1 -1
  96. data/lib/skr/models/gl_transaction.rb +3 -0
  97. data/lib/skr/models/inv_line.rb +7 -2
  98. data/lib/skr/models/inventory_adjustment.rb +0 -5
  99. data/lib/skr/models/invoice.rb +25 -36
  100. data/lib/skr/models/location.rb +1 -1
  101. data/lib/skr/models/payment.rb +56 -10
  102. data/lib/skr/models/po_receipt.rb +0 -8
  103. data/lib/skr/models/sales_order.rb +7 -2
  104. data/lib/skr/models/sequential_id.rb +6 -1
  105. data/lib/skr/models/sku.rb +3 -0
  106. data/lib/skr/print.rb +1 -0
  107. data/lib/skr/print/context.rb +19 -0
  108. data/lib/skr/print/form.rb +7 -1
  109. data/lib/skr/version.rb +1 -1
  110. data/npm-build/package.json +26 -0
  111. data/npm-build/vendor.js +10 -0
  112. data/npm-build/webpack.config.js +25 -0
  113. data/spec/fixtures/skr/bank_account.yml +9 -0
  114. data/spec/fixtures/skr/customer.yml +10 -0
  115. data/spec/fixtures/skr/inv_line.yml +12 -0
  116. data/spec/fixtures/skr/invoice.yml +17 -0
  117. data/spec/fixtures/skr/payment_category.yml +6 -0
  118. data/spec/fixtures/skr/sales_order.yml +1 -1
  119. data/spec/fixtures/skr/sku.yml +10 -0
  120. data/spec/fixtures/skr/sku_loc.yml +4 -0
  121. data/spec/fixtures/skr/uom.yml +6 -0
  122. data/spec/server/handlers/invoice_from_time_entries_spec.rb +13 -6
  123. data/spec/server/handlers/sequential_ids_spec.rb +22 -0
  124. data/spec/server/models/invoice_spec.rb +36 -0
  125. data/spec/server/models/payment_spec.rb +50 -22
  126. data/spec/server/models/sales_order_spec.rb +12 -0
  127. data/spec/server/print/form_spec.rb +20 -4
  128. data/spec/skr/api/SingleItemCheckoutSpec.cjsx +10 -0
  129. data/spec/skr/screens/sale-report/SaleReportSpec.coffee +5 -0
  130. data/stockor.gemspec +5 -4
  131. data/templates/print/layout.tex.erb +1 -1
  132. data/templates/print/packages/INSTALL +7 -0
  133. data/templates/print/packages/qrcode.sty +3051 -0
  134. data/templates/print/packages/svgnam.def +186 -0
  135. data/templates/print/packages/x11nam.def +352 -0
  136. data/templates/print/packages/xcolor.pro +58 -0
  137. data/templates/print/packages/xcolor.sty +1460 -0
  138. data/templates/print/types/invoice/default.tex.erb +2 -0
  139. data/templates/print/types/invoice/labor.tex.erb +2 -1
  140. data/templates/print/types/invoice/ticket.tex.erb +41 -0
  141. data/templates/print/types/payment/default.tex.erb +13 -12
  142. metadata +78 -12
data/db/seed.rb CHANGED
@@ -14,6 +14,12 @@ module Skr
14
14
  Lanes::User.scoped_to(user) do
15
15
  seeds_path = Pathname.new(__FILE__).dirname.join('seed')
16
16
 
17
+ unless BankAccount.default
18
+ BankAccount.create(code: Skr.config.default_bank_account_code, name: "System default",
19
+ address: Address.new(name:"System default")
20
+ )
21
+ end
22
+
17
23
  unless Location.default
18
24
  Location.create( code: Skr.config.default_location_code, name: "System default",
19
25
  address: Address.new(name:"System default")
data/lib/skr.rb CHANGED
@@ -23,4 +23,4 @@ require_rel "skr/jobs/fresh_books/*.rb"
23
23
  require_relative "skr/print"
24
24
  require_relative "skr/model"
25
25
  require_relative "skr/access_roles"
26
- require_rel "skr/handlers/*.rb"
26
+ require_relative "skr/merchant_gateway"
@@ -1,7 +1,10 @@
1
1
  require 'lanes/access'
2
2
  require_relative "model"
3
3
 
4
+ # Access control
4
5
  module Lanes::Access
6
+
7
+ # Roles specific to Stockor
5
8
  module Roles
6
9
 
7
10
  # re-open the exising Support role
@@ -14,6 +17,7 @@ module Lanes::Access
14
17
  Skr::TimeEntry
15
18
  end
16
19
 
20
+ # Accounting role for members who deal with finance
17
21
  class Accounting < Lanes::Access::Role
18
22
  grant Skr::Customer,
19
23
  Skr::PaymentTerm,
@@ -30,13 +34,14 @@ module Lanes::Access
30
34
  lock Skr::Customer, :gl_receivables_account
31
35
  end
32
36
 
33
-
37
+ # Purchase (PO's, Vendors)
34
38
  class Purchasing < Lanes::Access::Role
35
39
  read Skr::Customer
36
40
  grant Skr::Sku,
37
41
  Skr::SalesOrder
38
42
  end
39
43
 
44
+ # Standard employee role
40
45
  class Workforce < Lanes::Access::Role
41
46
  read Skr::Customer,
42
47
  Skr::Sku
@@ -49,6 +49,14 @@ module Skr
49
49
  end
50
50
  end
51
51
 
52
+ def attributes_for_gl_transaction
53
+ identifier = has_attribute?(:visible_id) ? visible_id : id
54
+ {
55
+ source: self,
56
+ location: location,
57
+ description: "#{self.class.to_s.demodulize} #{identifier}"
58
+ }
59
+ end
52
60
  end
53
61
 
54
62
  module ClassMethods
@@ -3,6 +3,17 @@ module Skr
3
3
 
4
4
  module INV
5
5
 
6
+ module Payments
7
+ def total
8
+ if proxy_association.loaded?
9
+ inject(0){ | sum, pymnt | sum+pymnt.amount }
10
+ else
11
+ sum('amount')
12
+ end
13
+ end
14
+
15
+ end
16
+
6
17
  module Lines
7
18
 
8
19
  def other_charge
@@ -13,9 +13,9 @@ module Skr
13
13
  def customer=(cust)
14
14
  super
15
15
  self.terms ||= cust.terms
16
- self.is_tax_exempt = cust.is_tax_exempt if self.is_tax_exempt.nil?
17
- self.billing_address = cust.billing_address.dup unless self.billing_address.present?
18
- self.shipping_address = cust.shipping_address.dup unless self.shipping_address.present?
16
+ self.is_tax_exempt = cust.is_tax_exempt if self.is_tax_exempt.nil?
17
+ self.billing_address = cust.billing_address.dup if self.billing_address.nil? and cust.billing_address
18
+ self.shipping_address = cust.shipping_address.dup if self.shipping_address.nil? and cust.shipping_address
19
19
  end
20
20
 
21
21
  protected
@@ -36,14 +36,9 @@ module Skr
36
36
  alias_attribute :record_identifier, :visible_id
37
37
  before_validation :assign_visible_id!, :on=>:create
38
38
 
39
- export_scope :with_visible_id, lambda{ | visid |
40
- if visid.to_s =~/%/
41
- where( 'cast(visible_id as varchar) like ?', visid.to_s )
42
- else
43
- where( 'cast(visible_id as varchar) = ?', visid.to_s )
44
- end
45
- }
46
-
39
+ export_sort :visible_id do | q, dir |
40
+ q.order("cast(visible_id as integer) #{dir}")
41
+ end
47
42
  end
48
43
 
49
44
  end
@@ -17,6 +17,8 @@ module Skr
17
17
  # Transactions that do not specify a location will use the one that's identified by this code
18
18
  config_option :default_location_code, 'DEFAULT'
19
19
 
20
+ config_option :default_bank_account_code, 'DEFAULT'
21
+
20
22
  # Do freshly created SKUs default to being backorderable?
21
23
  config_option :skus_backorder_default, true
22
24
 
data/lib/skr/extension.rb CHANGED
@@ -26,6 +26,12 @@ module Skr
26
26
  }
27
27
  end
28
28
 
29
+ def each_static_asset
30
+ super do | entry |
31
+ yield entry
32
+ end
33
+ [ 'skr/api.js', 'skr/api.css' ].each { | asset | yield asset }
34
+ end
29
35
  end
30
36
 
31
37
  end
@@ -0,0 +1,31 @@
1
+ require 'ruby-freshbooks'
2
+
3
+ module Skr::Handlers
4
+
5
+ module CreditCardGateway
6
+ class << self
7
+
8
+ def get
9
+ Lanes::API::RequestWrapper.with_authenticated_user(
10
+ role: 'administrator', with_transaction: false
11
+ ) do |user, req|
12
+ settings = Lanes::SystemSettings.for_ext('skr-ccgateway')
13
+ req.std_api_reply :get, (settings['credit_card_gateway'] || {})
14
+ end
15
+ end
16
+
17
+ def update
18
+ Lanes::API::RequestWrapper.with_authenticated_user(
19
+ role: 'administrator', with_transaction: false
20
+ ) do |user, req|
21
+ settings = Lanes::SystemSettings.for_ext('skr-ccgateway')
22
+ settings['credit_card_gateway'] = req.data
23
+ settings.persist!
24
+ req.std_api_reply :save, (settings['credit_card_gateway'] || {})
25
+ end
26
+ end
27
+
28
+ end
29
+ end
30
+
31
+ end
@@ -1,22 +1,21 @@
1
1
  module Skr
2
2
  module Handlers
3
- class InvoiceFromTimeEntries
3
+ class InvoiceFromTimeEntries < ::Lanes::API::ControllerBase
4
4
 
5
- def initialize(project_id, entry_ids, options = {})
6
- @project = CustomerProject.find(project_id)
7
- @entry_ids = entry_ids
8
-
9
- @location = Location.default # should be set on project maybe?
10
- @sku_loc = @project.sku.sku_locs.find_by(location: @location)
11
- @options = options
5
+ def initialize(model, authentication, params, data)
6
+ @options = data
7
+ @entry_ids = data['time_entry_ids']
8
+ @project = CustomerProject.find( data['customer_project_id'] )
9
+ @location = Location.default # should be set on project maybe?
10
+ @sku_loc = @project.sku.sku_locs.find_by(location: @location)
12
11
  end
13
12
 
14
- def build_invoice
13
+ def perform_creation
15
14
  invoice = Invoice.new(
16
- customer_project: @project,
15
+ notes: @options['notes'],
16
+ po_num: @options['po_num'] || @project.po_num,
17
17
  customer: @project.customer,
18
- po_num: @options['po_num'] || @project.po_num,
19
- notes: @options['notes']
18
+ customer_project: @project
20
19
  )
21
20
  @entry_ids.each do | entry_id |
22
21
  entry = TimeEntry.find(entry_id)
@@ -28,22 +27,9 @@ module Skr
28
27
  qty: ((entry.end_at - entry.start_at) / 1.hour)
29
28
  )
30
29
  end
31
- invoice
30
+ std_api_reply :create, { invoice: invoice }, success: invoice.save
32
31
  end
33
32
 
34
-
35
- def self.handler
36
- lambda do
37
- wrap_reply do
38
- builder = InvoiceFromTimeEntries.new(
39
- data['customer_project_id'], data['time_entry_ids'], data
40
- )
41
- invoice = builder.build_invoice
42
- std_api_reply :create, { invoice: invoice }, success: invoice.save
43
- end
44
-
45
- end
46
- end
47
33
  end
48
34
  end
49
35
  end
@@ -0,0 +1,44 @@
1
+ module Skr
2
+
3
+ class Handlers::Sales < Lanes::API::ControllerBase
4
+
5
+ def create
6
+
7
+ customer = if data['customer']
8
+ Skr::Customer.find_by_code(data['customer'])
9
+ else
10
+ Skr::Customer.joins(:billing_address)
11
+ .merge( Skr::Address.where( data['billing_address'] ) ).first
12
+ end
13
+ unless customer
14
+ customer = Skr::Customer.create!(
15
+ name: data['billing_address']['name'],
16
+ billing_address_attributes: data['billing_address']
17
+ )
18
+ end
19
+
20
+ invoice = Skr::Invoice.new(
21
+ customer: customer,
22
+ billing_address_attributes: data['billing_address']
23
+ )
24
+ invoice.location = data['location'] ? Skr::Location.find_by_code(data['location']) :
25
+ Skr::Location.default
26
+ %w{form options}.each do | attr |
27
+ invoice[attr] = data[attr] if data[attr]
28
+ end
29
+
30
+ (data['skus'] || []).each do | l |
31
+ sku_loc = Skr::SkuLoc
32
+ .where({ location: invoice.location, sku_id: l['sku_id'] })
33
+ .first
34
+ invoice.lines << Skr::InvLine.new({
35
+ sku_loc: sku_loc, qty: l['qty']
36
+ })
37
+ end
38
+
39
+ std_api_reply(:create, invoice, methods: 'total', success: invoice.save)
40
+ end
41
+
42
+ end
43
+
44
+ end
@@ -0,0 +1,46 @@
1
+ require 'lanes/api/formatted_reply'
2
+
3
+ module Skr
4
+ module Handlers
5
+ class SequentialIds
6
+
7
+ attr_reader :model, :user, :params, :data
8
+ include Lanes::API::FormattedReply
9
+
10
+ TYPES = %w{ Invoice SalesOrder GlManualEntry InventoryAdjustment Payment PickTicket Voucher }
11
+
12
+ def initialize(model, authentication, params, data)
13
+ @data = data
14
+ end
15
+
16
+ def perform_retrieval
17
+ ids = {}
18
+ Skr::SequentialId.pluck(:name, :current_value).map do |name, count|
19
+ ids[name.demodulize] = count
20
+ end
21
+ list = TYPES.map do | t |
22
+ {id: t, name: t.titleize, count: ids[t] || 0}
23
+ end
24
+ Skr::BankAccount.find_each do |ba|
25
+ id = Payment::SEQUENTIAL_ID_PREFIX + ba.id.to_s
26
+ list.push({id: id, name: "#{ba.name} Check", count: ids[id] || 0})
27
+ end
28
+ std_api_reply(:retrieve, {id: 'all', ids: list}, success: true)
29
+ end
30
+
31
+ def perform_update
32
+ data['ids'].each do | si |
33
+ Lanes.logger.warn "#{si['id']}"
34
+ id = if 0 == si['id'].index(Payment::SEQUENTIAL_ID_PREFIX)
35
+ si['id']
36
+ else
37
+ "Skr::#{si['id']}"
38
+ end
39
+ Skr::SequentialId.set_next(id, si['count'])
40
+ end
41
+ std_api_reply(:create, {ids: data['ids']}, success: true )
42
+ end
43
+
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,36 @@
1
+ module Skr
2
+
3
+ # exposes sku records to the public via a CORS enabled endpoing, without authentication
4
+ # Care is taken to only expose a few attributes of SKU's marked as "public"
5
+ class Handlers::Skus < Lanes::API::ControllerBase
6
+
7
+ def show
8
+ query = build_query.where(
9
+ is_public: true
10
+ ).unscope(:select).select(:id, :code, :description, :default_uom_code)
11
+ options = {methods: :price}
12
+
13
+ #options = build_reply_options
14
+
15
+ # options[:include] = include_associations.each_with_object({}) do |association, includes|
16
+
17
+ # query = add_modifiers_to_query(query)
18
+ options[:total_count] = query.dup.unscope(:select).count if should_include_total_count?
19
+ if params[:id]
20
+ query = query.first!
21
+ end
22
+ std_api_reply(:retrieve, query, options)
23
+
24
+ # sku = Sku.where(code: params[:code]).first.pluck(:id, :code, :description)
25
+
26
+ # std_api_reply(:get, sku, success: true )
27
+
28
+ end
29
+
30
+ def self.get
31
+ lambda do
32
+ 'hiu'
33
+ end
34
+ end
35
+ end
36
+ end
@@ -125,7 +125,9 @@ module Skr::Jobs::FreshBooks
125
125
  }.compact
126
126
  )
127
127
  if r['paid'].to_f > 0
128
- inv.update_attributes(amount_paid: r['paid'])
128
+ inv.payments.create!(
129
+ amount: r['paid'], bank_account: Skr::BankAccount.default
130
+ )
129
131
  end
130
132
  inv
131
133
  end
@@ -0,0 +1,37 @@
1
+ require 'active_merchant'
2
+
3
+ module Skr
4
+
5
+ module MerchantGateway
6
+
7
+ class InvalidCard < StandardError
8
+ end
9
+
10
+ def self.get
11
+ @gateway || _create_gateway
12
+ end
13
+
14
+ def self._create_gateway
15
+ unless Lanes.env.production?
16
+ return ActiveMerchant::Billing::BogusGateway.new
17
+ end
18
+ settings = Lanes::SystemSettings.for_ext('skr-ccgateway')['credit_card_gateway'] || {}
19
+ gateway = nil
20
+ if settings['type']
21
+ gateway = ActiveMerchant::Billing.const_get(settings['type'].classify)
22
+ end
23
+ if gw.nil?
24
+ Lanes.logger.warn("Unable to find gateway class for id #{settings['type']}")
25
+ raise ActiveRecord::RecordNotFound
26
+ end
27
+ gateway.new(settings.except('type'))
28
+ end
29
+
30
+ def purchase(amount, card)
31
+ raise InvalidCard.new(credit_card.validate) unless credit_card.validate.empty?
32
+ gw.purchase(amount, card)
33
+ end
34
+
35
+ end
36
+
37
+ end
@@ -77,12 +77,14 @@ module Skr
77
77
  # PO Box 87
78
78
  # Nowhereville, Urgandishly ASCN 1ZZ
79
79
  # 877-5550-5555
80
- def to_s( include: [] )
80
+ def to_s( include: [], without: [] )
81
81
  ret = ""
82
- %w{ name line1 line2 }.each{ |a| ret << self[a] + "\n" unless self[a].blank? }
83
- ret << city.to_s
84
- ret << ' ' + state unless state.blank?
85
- ret << ', ' + postal_code.to_s unless postal_code.blank?
82
+ [ :name, :line1, :line2 ].each{ |a|
83
+ ret << self[a] + "\n" unless without.include?(a) || self[a].blank?
84
+ }
85
+ ret << city.to_s unless without.include?(:city)
86
+ ret << ' ' + state unless without.include?(:state) || state.blank?
87
+ ret << ', ' + postal_code.to_s unless without.include?(:postal_code) || postal_code.blank?
86
88
  include = [ *include ]
87
89
  if include.any?
88
90
  ret << "\n" + include.map{ | field | self[ field ] }.join("\n")
@@ -8,6 +8,18 @@ module Skr
8
8
 
9
9
  belongs_to :address, class_name: 'Skr::Address',
10
10
  export: { writable: true }, dependent: :destroy
11
+
12
+ def self.default
13
+ account = nil
14
+ if default_id = Skr.system_settings['bank_acount_id']
15
+ account = BankAccount.find(default_id)
16
+ end
17
+ account ||
18
+ BankAccount.find_by_code( Skr.config.default_bank_account_code ) ||
19
+ BankAccount.first
20
+ end
21
+
11
22
  end
12
23
 
24
+
13
25
  end