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
@@ -17,7 +17,7 @@ module Skr
|
|
17
17
|
delegate_and_export :terms_code, :terms_description
|
18
18
|
|
19
19
|
validates :name, presence: true
|
20
|
-
validates :terms,
|
20
|
+
validates :terms, set: true
|
21
21
|
|
22
22
|
before_validation :set_defaults, :on=>:create
|
23
23
|
end
|
@@ -113,6 +113,9 @@ module Skr
|
|
113
113
|
glt.add_posting( amount: amount, debit: debit, credit: credit )
|
114
114
|
else
|
115
115
|
options.merge!(source: owner, location: options[:location] || owner.location)
|
116
|
+
if owner.respond_to?(:attributes_for_gl_transaction)
|
117
|
+
options.reverse_merge!( owner.attributes_for_gl_transaction )
|
118
|
+
end
|
116
119
|
glt = GlTransaction.new( options )
|
117
120
|
glt.add_posting( amount: amount, debit: debit, credit: credit )
|
118
121
|
glt.save!
|
data/lib/skr/models/inv_line.rb
CHANGED
@@ -88,18 +88,23 @@ module Skr
|
|
88
88
|
self.sku_trans.build(
|
89
89
|
origin: self, qty: changed_qty * -1, sku_loc: self.sku_loc, uom: self.uom,
|
90
90
|
mac: 0, cost: price_change,
|
91
|
-
origin_description:
|
91
|
+
origin_description: gl_origin_description,
|
92
92
|
debit_gl_account: debit, credit_gl_account: credit
|
93
93
|
)
|
94
94
|
else
|
95
95
|
GlTransaction.push_or_save(
|
96
96
|
owner: self, amount: price_change,
|
97
|
-
debit: debit, credit: credit
|
97
|
+
debit: debit, credit: credit,
|
98
|
+
options: {description: gl_origin_description}
|
98
99
|
)
|
99
100
|
end
|
100
101
|
true
|
101
102
|
end
|
102
103
|
|
104
|
+
def gl_origin_description
|
105
|
+
"INV #{self.invoice.visible_id}:#{self.sku.code}"
|
106
|
+
end
|
107
|
+
|
103
108
|
def prevent_destroy
|
104
109
|
errors.add(:base, "Can not destroy #{self.class.model_name}, only create/modify is allowed" )
|
105
110
|
end
|
@@ -38,11 +38,6 @@ module Skr
|
|
38
38
|
state_event == :mark_applied
|
39
39
|
end
|
40
40
|
|
41
|
-
def attributes_for_gl_transaction
|
42
|
-
{ source: self, location: location,
|
43
|
-
description: "IA #{self.visible_id}" }
|
44
|
-
end
|
45
|
-
|
46
41
|
def ensure_state_is_savable
|
47
42
|
if applied? && state_was == 'applied'
|
48
43
|
errors.add('base' , "Cannot update record once it's approved and applied")
|
data/lib/skr/models/invoice.rb
CHANGED
@@ -30,7 +30,6 @@ module Skr
|
|
30
30
|
has_random_hash_code
|
31
31
|
has_gl_transaction
|
32
32
|
is_order_like
|
33
|
-
has_additional_events :amount_paid_change
|
34
33
|
|
35
34
|
belongs_to :sales_order, export: true
|
36
35
|
belongs_to :customer_project, export: true
|
@@ -47,17 +46,27 @@ module Skr
|
|
47
46
|
class_name: 'Skr::InvLine', inverse_of: :invoice,
|
48
47
|
extend: Concerns::INV::Lines, export: { writable: true }
|
49
48
|
|
50
|
-
|
49
|
+
has_many :payments, inverse_of: :invoice,
|
50
|
+
extend: Concerns::INV::Payments,
|
51
|
+
listen: { save: :apply_payment },
|
52
|
+
export: { writable: true }
|
51
53
|
|
52
54
|
before_validation :set_defaults, on: :create
|
53
55
|
|
54
56
|
validates :customer, :location, set: true
|
55
57
|
validate :ensure_unlocked, :ensure_location_matches_so
|
56
58
|
|
59
|
+
# used to update customer account balances when invoices created / paid
|
57
60
|
scope :open_for_customer, lambda{ | customer |
|
58
61
|
where(state: :open, customer_id: customer.is_a?(Customer) ? customer.id : customer)
|
59
62
|
}, export: true
|
60
63
|
|
64
|
+
scope :with_sku_id, lambda { | sku_id |
|
65
|
+
joins("join (select skr_sku_inv_xref.invoice_id as invoice_id from skr_sku_inv_xref " +
|
66
|
+
"where sku_id=#{sku_id.to_i} group by skr_sku_inv_xref.invoice_id) as sku_inv " +
|
67
|
+
"on sku_inv.invoice_id = skr_invoices.id")
|
68
|
+
}, export: true
|
69
|
+
|
61
70
|
scope :with_details, lambda { |should_use=true |
|
62
71
|
compose_query_using_detail_view( view: 'skr_inv_details', join_to: 'invoice_id' )
|
63
72
|
}, export: true
|
@@ -65,20 +74,18 @@ module Skr
|
|
65
74
|
enum state: {
|
66
75
|
open: 1,
|
67
76
|
paid: 5,
|
68
|
-
|
77
|
+
partialy_paid: 10
|
69
78
|
}
|
70
79
|
|
71
80
|
state_machine do
|
72
81
|
state :open, initial: true
|
73
82
|
state :paid
|
74
|
-
state :
|
83
|
+
state :partialy_paid
|
75
84
|
event :mark_paid do
|
76
|
-
transitions from: [:open,:
|
77
|
-
before :apply_balances
|
85
|
+
transitions from: [:open,:partialy_paid], to: :paid
|
78
86
|
end
|
79
|
-
event :
|
80
|
-
transitions from:
|
81
|
-
before :apply_balances
|
87
|
+
event :mark_partialy_paid do
|
88
|
+
transitions from: :open, to: :partialy_paid
|
82
89
|
end
|
83
90
|
end
|
84
91
|
|
@@ -90,7 +97,7 @@ module Skr
|
|
90
97
|
|
91
98
|
# @return [BigDecimal] total - amount_paid
|
92
99
|
def unpaid_amount
|
93
|
-
self.total -
|
100
|
+
self.total - self.payments.total
|
94
101
|
end
|
95
102
|
|
96
103
|
# @return [Boolean] is the invoice paid in full
|
@@ -109,36 +116,18 @@ module Skr
|
|
109
116
|
|
110
117
|
private
|
111
118
|
|
112
|
-
# attributes for GlTransaction
|
113
|
-
def attributes_for_gl_transaction
|
114
|
-
{ location: location, source: self,
|
115
|
-
description: "INV #{self.visible_id}" }
|
116
|
-
end
|
117
|
-
|
118
119
|
# set the state if the amount_paid was changed
|
119
|
-
def
|
120
|
-
return unless amount_paid_changed?
|
120
|
+
def apply_payment(pymnt)
|
121
121
|
if self.fully_paid? && self.may_mark_paid?
|
122
|
-
self.mark_paid
|
123
|
-
elsif self.
|
124
|
-
|
125
|
-
end
|
126
|
-
end
|
122
|
+
self.mark_paid!
|
123
|
+
elsif self.payments.total > 0 && self.may_mark_partialy_paid?
|
124
|
+
Lanes.logger_debug('paying')
|
127
125
|
|
128
|
-
|
129
|
-
return unless amount_paid_changed?
|
130
|
-
change = amount_paid - amount_paid_was
|
131
|
-
Lanes.logger.debug "Applying payment #{amount_paid} changed: #{change}"
|
132
|
-
return if change.zero?
|
133
|
-
GlTransaction.push_or_save(
|
134
|
-
owner: self, amount: change,
|
135
|
-
debit: customer.gl_receivables_account,
|
136
|
-
credit: GlAccount.default_for(:deposit_holding)
|
137
|
-
)
|
138
|
-
fire_pubsub_event( :amount_paid_change )
|
139
|
-
true
|
140
|
-
end
|
126
|
+
#self.mark_partialy_paid!
|
141
127
|
|
128
|
+
Lanes.logger_debug('paid')
|
129
|
+
end
|
130
|
+
end
|
142
131
|
|
143
132
|
def set_defaults
|
144
133
|
|
data/lib/skr/models/location.rb
CHANGED
@@ -5,7 +5,7 @@ module Skr
|
|
5
5
|
|
6
6
|
has_code_identifier :from=>'name'
|
7
7
|
|
8
|
-
|
8
|
+
has_one :logo, as: :owner, :class_name=>'Lanes::Asset', export: { writable: false }, :dependent => :destroy
|
9
9
|
|
10
10
|
belongs_to :address, export: { writable: true }
|
11
11
|
|
data/lib/skr/models/payment.rb
CHANGED
@@ -1,20 +1,31 @@
|
|
1
1
|
module Skr
|
2
2
|
|
3
|
+
# A payment can be for either incoming or outgoing, if incoming must
|
4
|
+
# be associated with an Invoice, otherwise a Vendor or PaymentCategory
|
3
5
|
class Payment < Model
|
6
|
+
|
7
|
+
SEQUENTIAL_ID_PREFIX = 'Pmnt-'
|
8
|
+
|
4
9
|
has_visible_id
|
5
10
|
has_random_hash_code
|
6
11
|
has_gl_transaction
|
7
12
|
|
8
13
|
belongs_to :category, class_name: 'Skr::PaymentCategory', export: true
|
9
14
|
belongs_to :vendor, class_name: 'Skr::Vendor', export: true
|
15
|
+
belongs_to :invoice, class_name: 'Skr::Invoice', export: true
|
10
16
|
belongs_to :bank_account, class_name: 'Skr::BankAccount', export: true
|
11
17
|
belongs_to :location, class_name: 'Skr::Location', export: true
|
12
18
|
|
13
|
-
validates :name, :amount, :
|
19
|
+
validates :name, :amount, :bank_account, presence: true
|
20
|
+
|
21
|
+
attr_accessor :credit_card
|
22
|
+
whitelist_attributes :credit_card
|
14
23
|
|
15
24
|
has_one :gl_transaction, class_name: 'Skr::GlTransaction', as: :source
|
16
25
|
|
17
26
|
before_validation :set_defaults, on: :create
|
27
|
+
before_validation :attempt_charging_provided_card,
|
28
|
+
on: :create, if: :credit_card
|
18
29
|
|
19
30
|
after_save :apply_transaction
|
20
31
|
|
@@ -22,27 +33,62 @@ module Skr
|
|
22
33
|
{ 'position' => :absolute }
|
23
34
|
end
|
24
35
|
|
36
|
+
def incoming?
|
37
|
+
vendor.present?
|
38
|
+
end
|
39
|
+
|
40
|
+
def outgoing?
|
41
|
+
vendor.present? || category.present?
|
42
|
+
end
|
43
|
+
|
25
44
|
private
|
26
45
|
|
27
|
-
def
|
28
|
-
|
29
|
-
|
46
|
+
def attempt_charging_provided_card
|
47
|
+
return unless credit_card.present?
|
48
|
+
|
49
|
+
card = ActiveMerchant::Billing::CreditCard.new(credit_card)
|
50
|
+
gw = Skr::MerchantGateway.get
|
51
|
+
resp = gw.purchase(amount, card)
|
52
|
+
if resp.success?
|
53
|
+
metadata['authorization'] = resp.authorization
|
54
|
+
else
|
55
|
+
errors.add(:credit_card, "purchase failed: #{resp.message}")
|
56
|
+
end
|
30
57
|
end
|
31
58
|
|
32
|
-
def
|
33
|
-
|
59
|
+
def gl_accounts
|
60
|
+
if vendor
|
61
|
+
[vendor.gl_payables_account, bank_account.gl_account]
|
62
|
+
elsif invoice
|
63
|
+
[bank_account.gl_account,
|
64
|
+
invoice.customer.gl_receivables_account]
|
65
|
+
else
|
66
|
+
[category.gl_account, bank_account.gl_account]
|
67
|
+
end
|
68
|
+
end
|
34
69
|
|
70
|
+
def apply_transaction
|
71
|
+
(credit, debit) = gl_accounts
|
35
72
|
GlTransaction.push_or_save(
|
36
|
-
owner:
|
37
|
-
debit:
|
38
|
-
credit: credit
|
73
|
+
owner: self, amount: amount,
|
74
|
+
debit: debit, credit: credit
|
39
75
|
)
|
40
76
|
end
|
41
77
|
|
42
78
|
def set_defaults
|
43
79
|
self.location ||= Location.default
|
44
80
|
self.date ||= Date.today
|
45
|
-
|
81
|
+
if name.blank?
|
82
|
+
if self.vendor
|
83
|
+
self.name = vendor.name
|
84
|
+
elsif self.invoice
|
85
|
+
self.name = invoice.billing_address.name
|
86
|
+
end
|
87
|
+
end
|
88
|
+
if bank_account && outgoing?
|
89
|
+
self.check_number ||= SequentialId.next_for(SEQUENTIAL_ID_PREFIX + bank_account.id.to_s)
|
90
|
+
end
|
91
|
+
self.bank_account ||= BankAccount.default
|
46
92
|
end
|
47
93
|
|
48
94
|
end
|
@@ -31,14 +31,6 @@ module Skr
|
|
31
31
|
|
32
32
|
private
|
33
33
|
|
34
|
-
def attributes_for_gl_transaction
|
35
|
-
{ location: location, source: self,
|
36
|
-
description: "PO RECPT #{self.visible_id}" }
|
37
|
-
end
|
38
|
-
|
39
|
-
def logit
|
40
|
-
end
|
41
|
-
|
42
34
|
def record_freight
|
43
35
|
GlTransaction.current.add_posting( amount: self.freight,
|
44
36
|
debit: GlAccount.default_for( :inventory_receipts_clearing ),
|
@@ -36,7 +36,7 @@ module Skr
|
|
36
36
|
has_many :invoices, inverse_of: :sales_order, listen: { save: 'on_invoice' }
|
37
37
|
|
38
38
|
validates :location, :terms, :customer, set: true
|
39
|
-
validates :
|
39
|
+
validates :order_date, presence: true
|
40
40
|
validate :ensure_location_changes_are_valid
|
41
41
|
|
42
42
|
after_save :check_if_location_changed
|
@@ -47,11 +47,16 @@ module Skr
|
|
47
47
|
# joins the so_amount_details view which includes additional fields:
|
48
48
|
# customer_code, customer_name, bill_addr_name, total, num_lines, total_other_charge_amount,
|
49
49
|
# total_tax_amount, total_shipping_amount,subtotal_amount
|
50
|
-
|
51
50
|
scope :with_details, lambda { | *args |
|
52
51
|
compose_query_using_detail_view(view: 'skr_so_details')
|
53
52
|
}, export: true
|
54
53
|
|
54
|
+
scope :with_sku_id, lambda { | sku_id |
|
55
|
+
joins("join (select skr_sku_so_xref.sales_order_id from skr_sku_so_xref " +
|
56
|
+
"where sku_id=#{sku_id.to_i} group by skr_sku_so_xref.sales_order_id) as sku_so " +
|
57
|
+
"on sku_so.sales_order_id = skr_sales_orders.id")
|
58
|
+
}, export: true
|
59
|
+
|
55
60
|
# joins the so_allocation_details which includes the additional fields:
|
56
61
|
# number_of_lines, allocated_total, number_of_lines_allocated, number_of_lines_fully_allocated
|
57
62
|
scope :with_allocation_details, lambda {
|
@@ -16,7 +16,12 @@ module Skr
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def self.set_next( klass, value )
|
19
|
-
self.
|
19
|
+
record = self.find_or_initialize_by(name: klass.to_s)
|
20
|
+
return if record.new_record? and 0 == value.to_i
|
21
|
+
record.unlock_fields(:current_value) do
|
22
|
+
record.current_value = value.to_i
|
23
|
+
record.save
|
24
|
+
end
|
20
25
|
end
|
21
26
|
|
22
27
|
end
|
data/lib/skr/models/sku.rb
CHANGED
@@ -54,6 +54,9 @@ module Skr
|
|
54
54
|
with_qty_details.where("details.qty_on_order > details.qty_on_hand")
|
55
55
|
}, export: true
|
56
56
|
|
57
|
+
def price
|
58
|
+
uoms.default.price
|
59
|
+
end
|
57
60
|
|
58
61
|
# Rebuilding is sometimes needed for cases where the location's
|
59
62
|
# allocation/on order/reserved counts get out of sync with the
|
data/lib/skr/print.rb
CHANGED
@@ -0,0 +1,19 @@
|
|
1
|
+
module Skr
|
2
|
+
module Print
|
3
|
+
class Context < ErbLatex::Context
|
4
|
+
|
5
|
+
def pluralize(count, word)
|
6
|
+
count == 1 ? word : word.pluralize
|
7
|
+
end
|
8
|
+
|
9
|
+
|
10
|
+
def get_snippet(name)
|
11
|
+
snips = Skr.system_settings['latex_snippets'] || {}
|
12
|
+
if name && snips[name]
|
13
|
+
snips[name]
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/lib/skr/print/form.rb
CHANGED
@@ -14,7 +14,12 @@ module Skr
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def as_pdf
|
17
|
-
|
17
|
+
begin
|
18
|
+
template.to_stringio
|
19
|
+
rescue => e
|
20
|
+
Lanes.logger.warn e.log
|
21
|
+
raise
|
22
|
+
end
|
18
23
|
end
|
19
24
|
|
20
25
|
def as_latex
|
@@ -35,6 +40,7 @@ module Skr
|
|
35
40
|
def template
|
36
41
|
ErbLatex::Template.new( @latex,
|
37
42
|
data: data,
|
43
|
+
context: Skr::Print::Context,
|
38
44
|
layout: ROOT.join('layout.tex.erb'),
|
39
45
|
partials_path: ROOT.join('partials'),
|
40
46
|
packages_path: ROOT.join('packages')
|
data/lib/skr/version.rb
CHANGED
@@ -0,0 +1,26 @@
|
|
1
|
+
{
|
2
|
+
"name": "stockor",
|
3
|
+
"version": "0.0.1",
|
4
|
+
"private": true,
|
5
|
+
"description": "Assets built for Stockor",
|
6
|
+
"main": "vendor.js",
|
7
|
+
"scripts": {
|
8
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
9
|
+
},
|
10
|
+
"author": "",
|
11
|
+
"license": "AGPL-3.0",
|
12
|
+
"dependencies": {
|
13
|
+
"card": "^1.3.2",
|
14
|
+
"payment": "^1.0.4"
|
15
|
+
},
|
16
|
+
"devDependencies": {
|
17
|
+
"bourbon": "^4.2.7",
|
18
|
+
"coffee-loader": "^0.7.2",
|
19
|
+
"coffee-script": "^1.10.0",
|
20
|
+
"css-loader": "^0.23.1",
|
21
|
+
"node-sass": "^3.7.0",
|
22
|
+
"sass-loader": "^3.2.0",
|
23
|
+
"style-loader": "^0.13.1",
|
24
|
+
"webpack": "^1.13.1"
|
25
|
+
}
|
26
|
+
}
|