stockor 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +3 -0
- data/.rubocop.yml +15 -0
- data/Gemfile +3 -1
- data/Gemfile.lock +97 -193
- data/client/skr/Extension.coffee +8 -4
- data/client/skr/api.js +21 -0
- data/client/skr/api.scss +148 -0
- data/client/skr/api/Components/AddressForm.cjsx +47 -0
- data/client/skr/api/Components/Base.coffee +7 -0
- data/client/skr/api/Components/SaleHistory.cjsx +32 -0
- data/client/skr/api/Components/SingleItemCart.cjsx +30 -0
- data/client/skr/api/Models/Base.coffee +10 -0
- data/client/skr/api/Models/Cart.coffee +40 -0
- data/client/skr/api/Models/Sale.coffee +43 -0
- data/client/skr/api/Models/SalesHistory.coffee +17 -0
- data/client/skr/api/Models/Sku.coffee +16 -0
- data/client/skr/api/SingleItemCheckout.cjsx +99 -0
- data/client/skr/api/namespace.js +6 -0
- data/client/skr/api/onReady.coffee +23 -0
- data/client/skr/components/CreditCardForm.cjsx +35 -0
- data/client/skr/components/CustomerFinder.cjsx +0 -3
- data/client/skr/components/InvoiceFinder.cjsx +1 -0
- data/client/skr/components/LatexSnippets.cjsx +65 -0
- data/client/skr/components/LocationChooser.cjsx +5 -1
- data/client/skr/components/PrintButton.cjsx +33 -0
- data/client/skr/components/PrintFormChooser.cjsx +10 -10
- data/client/skr/components/SalesOrderFinder.cjsx +2 -1
- data/client/skr/components/SystemSettings.cjsx +69 -9
- data/client/skr/components/address/index.js +1 -0
- data/client/skr/models/Address.coffee +3 -0
- data/client/skr/models/CreditCard.coffee +49 -0
- data/client/skr/models/CreditCardGateway.coffee +27 -0
- data/client/skr/models/Invoice.coffee +13 -5
- data/client/skr/models/Location.coffee +6 -4
- data/client/skr/models/Payment.coffee +33 -13
- data/client/skr/models/SalesOrder.coffee +7 -3
- data/client/skr/models/SequentialId.coffee +17 -0
- data/client/skr/models/Sku.coffee +1 -1
- data/client/skr/models/TimeEntry.coffee +3 -4
- data/client/skr/models/mixins/PrintSupport.coffee +4 -1
- data/client/skr/models/mixins/SkuLine.coffee +1 -1
- data/client/skr/screens/customer-maint/CustomerMaint.cjsx +1 -2
- data/client/skr/screens/customer-projects/CustomerProjects.cjsx +7 -3
- data/client/skr/screens/customer-projects/index.scss +1 -0
- data/client/skr/screens/fresh-books-import/ApiInfo.cjsx +1 -1
- data/client/skr/screens/gl-accounts/GlAccounts.cjsx +1 -1
- data/client/skr/screens/gl-transactions/GlTransactions.cjsx +1 -1
- data/client/skr/screens/invoice/Invoice.cjsx +9 -17
- data/client/skr/screens/invoice/Payment.cjsx +94 -13
- data/client/skr/screens/invoice/index.scss +32 -0
- data/client/skr/screens/locations/Locations.cjsx +3 -2
- data/client/skr/screens/payment-category/PaymentCategory.cjsx +1 -1
- data/client/skr/screens/payments/Payments.cjsx +5 -4
- data/client/skr/screens/sale-report/SaleReport.cjsx +73 -0
- data/client/skr/screens/sale-report/index.js +5 -0
- data/client/skr/screens/sale-report/index.scss +9 -0
- data/client/skr/screens/sales-order/SalesOrder.cjsx +4 -4
- data/client/skr/screens/sku-maint/SkuMaint.cjsx +5 -0
- data/client/skr/screens/sku-maint/SkuUomList.cjsx +45 -56
- data/client/skr/screens/sku-maint/index.scss +33 -13
- data/client/skr/screens/time-invoicing/TimeInvoicing.cjsx +2 -2
- data/client/skr/screens/time-tracking/EditEntry.cjsx +2 -4
- data/client/skr/screens/time-tracking/TimeTracking.cjsx +1 -1
- data/client/skr/screens/vendor-maint/VendorMaint.cjsx +1 -1
- data/client/skr/vendor/index.js +2438 -0
- data/config/lanes.rb +10 -3
- data/config/routes.rb +9 -7
- data/config/screens.rb +39 -13
- data/db/migrate/20160517032350_create_remove_location_logos.rb +11 -0
- data/db/migrate/20160531014306_create_public_skus.rb +7 -0
- data/db/migrate/20160604195848_create_null_addresses.rb +9 -0
- data/db/migrate/20160605024432_create_sku_associations_views.rb +48 -0
- data/db/migrate/20160608023553_create_invoice_payments.rb +9 -0
- data/db/migrate/20160620010455_add_payments_to_inv_details.rb +54 -0
- data/db/schema.sql +206 -38
- data/db/seed.rb +6 -0
- data/lib/skr.rb +1 -1
- data/lib/skr/access_roles.rb +6 -1
- data/lib/skr/concerns/has_gl_transaction.rb +8 -0
- data/lib/skr/concerns/inv_extensions.rb +11 -0
- data/lib/skr/concerns/is_order_like.rb +3 -3
- data/lib/skr/concerns/visible_id_identifier.rb +3 -8
- data/lib/skr/configuration.rb +2 -0
- data/lib/skr/extension.rb +6 -0
- data/lib/skr/handlers/credit_card_gateway.rb +31 -0
- data/lib/skr/handlers/invoice_from_time_entries.rb +12 -26
- data/lib/skr/handlers/sales.rb +44 -0
- data/lib/skr/handlers/sequential_ids.rb +46 -0
- data/lib/skr/handlers/skus.rb +36 -0
- data/lib/skr/jobs/fresh_books/import.rb +3 -1
- data/lib/skr/merchant_gateway.rb +37 -0
- data/lib/skr/models/address.rb +7 -5
- data/lib/skr/models/bank_account.rb +12 -0
- data/lib/skr/models/business_entity.rb +1 -1
- data/lib/skr/models/gl_transaction.rb +3 -0
- data/lib/skr/models/inv_line.rb +7 -2
- data/lib/skr/models/inventory_adjustment.rb +0 -5
- data/lib/skr/models/invoice.rb +25 -36
- data/lib/skr/models/location.rb +1 -1
- data/lib/skr/models/payment.rb +56 -10
- data/lib/skr/models/po_receipt.rb +0 -8
- data/lib/skr/models/sales_order.rb +7 -2
- data/lib/skr/models/sequential_id.rb +6 -1
- data/lib/skr/models/sku.rb +3 -0
- data/lib/skr/print.rb +1 -0
- data/lib/skr/print/context.rb +19 -0
- data/lib/skr/print/form.rb +7 -1
- data/lib/skr/version.rb +1 -1
- data/npm-build/package.json +26 -0
- data/npm-build/vendor.js +10 -0
- data/npm-build/webpack.config.js +25 -0
- data/spec/fixtures/skr/bank_account.yml +9 -0
- data/spec/fixtures/skr/customer.yml +10 -0
- data/spec/fixtures/skr/inv_line.yml +12 -0
- data/spec/fixtures/skr/invoice.yml +17 -0
- data/spec/fixtures/skr/payment_category.yml +6 -0
- data/spec/fixtures/skr/sales_order.yml +1 -1
- data/spec/fixtures/skr/sku.yml +10 -0
- data/spec/fixtures/skr/sku_loc.yml +4 -0
- data/spec/fixtures/skr/uom.yml +6 -0
- data/spec/server/handlers/invoice_from_time_entries_spec.rb +13 -6
- data/spec/server/handlers/sequential_ids_spec.rb +22 -0
- data/spec/server/models/invoice_spec.rb +36 -0
- data/spec/server/models/payment_spec.rb +50 -22
- data/spec/server/models/sales_order_spec.rb +12 -0
- data/spec/server/print/form_spec.rb +20 -4
- data/spec/skr/api/SingleItemCheckoutSpec.cjsx +10 -0
- data/spec/skr/screens/sale-report/SaleReportSpec.coffee +5 -0
- data/stockor.gemspec +5 -4
- data/templates/print/layout.tex.erb +1 -1
- data/templates/print/packages/INSTALL +7 -0
- data/templates/print/packages/qrcode.sty +3051 -0
- data/templates/print/packages/svgnam.def +186 -0
- data/templates/print/packages/x11nam.def +352 -0
- data/templates/print/packages/xcolor.pro +58 -0
- data/templates/print/packages/xcolor.sty +1460 -0
- data/templates/print/types/invoice/default.tex.erb +2 -0
- data/templates/print/types/invoice/labor.tex.erb +2 -1
- data/templates/print/types/invoice/ticket.tex.erb +41 -0
- data/templates/print/types/payment/default.tex.erb +13 -12
- 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
data/lib/skr/access_roles.rb
CHANGED
@@ -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
|
@@ -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
|
17
|
-
self.billing_address = cust.billing_address.dup
|
18
|
-
self.shipping_address = cust.shipping_address.dup
|
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
|
-
|
40
|
-
|
41
|
-
|
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
|
data/lib/skr/configuration.rb
CHANGED
@@ -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
@@ -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(
|
6
|
-
@
|
7
|
-
@entry_ids =
|
8
|
-
|
9
|
-
@location
|
10
|
-
@sku_loc
|
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
|
13
|
+
def perform_creation
|
15
14
|
invoice = Invoice.new(
|
16
|
-
|
15
|
+
notes: @options['notes'],
|
16
|
+
po_num: @options['po_num'] || @project.po_num,
|
17
17
|
customer: @project.customer,
|
18
|
-
|
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
|
@@ -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
|
data/lib/skr/models/address.rb
CHANGED
@@ -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
|
-
|
83
|
-
|
84
|
-
|
85
|
-
ret <<
|
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
|