stockor 0.1.7 → 0.1.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/Gemfile.lock +13 -13
- data/client/skr/Extension.coffee +12 -2
- data/client/skr/models/GlAccount.coffee +12 -1
- data/client/skr/models/PurchaseOrder.coffee +6 -1
- data/client/skr/models/SalesOrder.coffee +7 -1
- data/client/skr/models/Sku.coffee +6 -2
- data/client/skr/models/mixins/VisibleID.coffee +5 -0
- data/client/skr/screens/customer-maint/CustomerMaint.coffee +1 -1
- data/client/skr/screens/mixins/index.js +0 -1
- data/client/skr/screens/sales-order/SalesOrder.coffee +30 -0
- data/client/skr/screens/sales-order/index.js +5 -0
- data/client/skr/screens/sales-order/index.scss +8 -0
- data/client/skr/screens/sales-order/layout.html +30 -0
- data/client/skr/screens/sku-maint/SkuMaint.coffee +7 -2
- data/client/skr/screens/sku-maint/layout.html +4 -0
- data/client/skr/screens/vendor-maint/VendorMaint.coffee +1 -1
- data/client/skr/styles.scss +1 -0
- data/config/screens.rb +22 -6
- data/db/migrate/20140322223912_create_skr_sales_orders.rb +1 -1
- data/db/migrate/20140327202102_create_skr_purchase_orders.rb +1 -1
- data/db/migrate/20140330232810_create_skr_sku_qty_details_view.rb +2 -2
- data/db/schema.sql +71 -71
- data/db/seed.rb +4 -3
- data/lib/skr/access_roles.rb +14 -4
- data/lib/skr/concerns/state_machine.rb +7 -2
- data/lib/skr/extension.rb +10 -0
- data/lib/skr/model.rb +34 -1
- data/lib/skr/models/address.rb +4 -4
- data/lib/skr/models/customer.rb +1 -1
- data/lib/skr/models/purchase_order.rb +6 -1
- data/lib/skr/models/sales_order.rb +7 -1
- data/lib/skr/version.rb +1 -1
- data/lib/skr.rb +1 -2
- data/spec/fixtures/skr/address.yml +8 -0
- data/spec/fixtures/skr/customer.yml +7 -0
- data/spec/fixtures/skr/gl_account.yml +41 -0
- data/spec/fixtures/skr/location.yml +5 -0
- data/spec/fixtures/skr/payment_term.yml +4 -0
- data/spec/server/models/{address.rb → address_spec.rb} +2 -2
- data/spec/server/models/{customer.rb → customer_spec.rb} +2 -2
- data/spec/server/models/{gl_account.rb → gl_account_spec.rb} +2 -2
- data/spec/server/models/{gl_manual_entry.rb → gl_manual_entry_spec.rb} +2 -2
- data/spec/server/models/{gl_period.rb → gl_period_spec.rb} +2 -2
- data/spec/server/models/{gl_posting.rb → gl_posting_spec.rb} +2 -2
- data/spec/server/models/{gl_transaction.rb → gl_transaction_spec.rb} +2 -2
- data/spec/server/models/{ia_line.rb → ia_line_spec.rb} +2 -2
- data/spec/server/models/{ia_reason.rb → ia_reason_spec.rb} +2 -2
- data/spec/server/models/{inv_line.rb → inv_line_spec.rb} +2 -2
- data/spec/server/models/{inventory_adjustment.rb → inventory_adjustment_spec.rb} +2 -2
- data/spec/server/models/{invoice.rb → invoice_spec.rb} +2 -2
- data/spec/server/models/{location.rb → location_spec.rb} +2 -2
- data/spec/server/models/{payment_term.rb → payment_term_spec.rb} +2 -2
- data/spec/server/models/{pick_ticket.rb → pick_ticket_spec.rb} +2 -2
- data/spec/server/models/{po_line.rb → po_line_spec.rb} +2 -2
- data/spec/server/models/{po_receipt.rb → po_receipt_spec.rb} +2 -2
- data/spec/server/models/{por_line.rb → por_line_spec.rb} +2 -2
- data/spec/server/models/{pt_line.rb → pt_line_spec.rb} +2 -2
- data/spec/server/models/{purchase_order.rb → purchase_order_spec.rb} +2 -2
- data/spec/server/models/sales_order_spec.rb +22 -0
- data/spec/server/models/{sku_loc.rb → sku_loc_spec.rb} +2 -2
- data/spec/server/models/{sku.rb → sku_spec.rb} +2 -2
- data/spec/server/models/{sku_tran.rb → sku_tran_spec.rb} +2 -2
- data/spec/server/models/{sku_vendor.rb → sku_vendor_spec.rb} +2 -2
- data/spec/server/models/{so_line.rb → so_line_spec.rb} +2 -2
- data/spec/server/models/{uom.rb → uom_spec.rb} +2 -2
- data/spec/server/models/{vendor.rb → vendor_spec.rb} +2 -2
- data/spec/server/models/{vo_line.rb → vo_line_spec.rb} +2 -2
- data/spec/server/models/{voucher.rb → voucher_spec.rb} +2 -2
- data/spec/server/spec_helper.rb +42 -0
- data/spec/skr/models/CustomerSpec.coffee +4 -3
- data/spec/skr/models/SalesOrderSpec.coffee +4 -2
- data/spec/skr/screens/sales-order/SalesOrderSpec.coffee +5 -0
- metadata +40 -36
- data/client/skr/screens/mixins/Editing.coffee +0 -32
- data/lib/skr/concerns/code_identifier.rb +0 -43
- data/log/test.log +0 -0
- data/spec/server/models/sales_order.rb +0 -10
- /data/spec/server/models/{spec_helper.rb → spec_helper_spec.rb} +0 -0
data/db/schema.sql
CHANGED
@@ -526,7 +526,7 @@ CREATE TABLE skr_sales_orders (
|
|
526
526
|
billing_address_id integer NOT NULL,
|
527
527
|
terms_id integer NOT NULL,
|
528
528
|
order_date date NOT NULL,
|
529
|
-
state
|
529
|
+
state smallint NOT NULL,
|
530
530
|
is_revised boolean DEFAULT false NOT NULL,
|
531
531
|
hash_code character varying NOT NULL,
|
532
532
|
ship_partial boolean DEFAULT false NOT NULL,
|
@@ -568,7 +568,7 @@ CREATE TABLE skr_sku_locs (
|
|
568
568
|
|
569
569
|
CREATE TABLE skr_skus (
|
570
570
|
id integer NOT NULL,
|
571
|
-
default_vendor_id integer
|
571
|
+
default_vendor_id integer,
|
572
572
|
gl_asset_account_id integer NOT NULL,
|
573
573
|
default_uom_code character varying NOT NULL,
|
574
574
|
code character varying NOT NULL,
|
@@ -601,22 +601,22 @@ CREATE VIEW skr_inv_details AS
|
|
601
601
|
COALESCE(ttls.other_charge_total, (0)::numeric) AS total_other_charge_amount,
|
602
602
|
(COALESCE(ttls.total, 0.0) - COALESCE(ttls.other_charge_total, 0.0)) AS subtotal_amount
|
603
603
|
FROM (((((skr_invoices inv
|
604
|
-
|
605
|
-
|
606
|
-
|
607
|
-
|
608
|
-
|
609
|
-
|
610
|
-
|
611
|
-
|
612
|
-
|
613
|
-
|
614
|
-
|
615
|
-
|
616
|
-
|
617
|
-
|
618
|
-
|
619
|
-
|
604
|
+
JOIN skr_customers cust ON ((cust.id = inv.customer_id)))
|
605
|
+
LEFT JOIN skr_addresses ba ON ((ba.id = inv.billing_address_id)))
|
606
|
+
LEFT JOIN skr_sales_orders so ON ((so.id = inv.sales_order_id)))
|
607
|
+
LEFT JOIN skr_pick_tickets pt ON ((pt.id = inv.pick_ticket_id)))
|
608
|
+
LEFT JOIN ( SELECT ivl.invoice_id,
|
609
|
+
sum(((ivl.qty)::numeric * ivl.price)) AS total,
|
610
|
+
sum(
|
611
|
+
CASE
|
612
|
+
WHEN s.is_other_charge THEN ((ivl.qty)::numeric * ivl.price)
|
613
|
+
ELSE (0)::numeric
|
614
|
+
END) AS other_charge_total,
|
615
|
+
count(ivl.*) AS num_lines
|
616
|
+
FROM ((skr_inv_lines ivl
|
617
|
+
JOIN skr_sku_locs sl ON ((sl.id = ivl.sku_loc_id)))
|
618
|
+
JOIN skr_skus s ON ((s.id = sl.sku_id)))
|
619
|
+
GROUP BY ivl.invoice_id) ttls ON ((ttls.invoice_id = inv.id)));
|
620
620
|
|
621
621
|
|
622
622
|
--
|
@@ -964,7 +964,7 @@ CREATE TABLE skr_purchase_orders (
|
|
964
964
|
location_id integer NOT NULL,
|
965
965
|
ship_addr_id integer NOT NULL,
|
966
966
|
terms_id integer NOT NULL,
|
967
|
-
state
|
967
|
+
state smallint NOT NULL,
|
968
968
|
is_revised boolean DEFAULT false NOT NULL,
|
969
969
|
order_date date NOT NULL,
|
970
970
|
receiving_completed_at timestamp without time zone,
|
@@ -1106,10 +1106,10 @@ CREATE VIEW skr_sku_loc_details AS
|
|
1106
1106
|
sv.part_code AS vendor_part_code,
|
1107
1107
|
sv.cost AS purchase_cost
|
1108
1108
|
FROM ((((skr_sku_locs sl
|
1109
|
-
|
1110
|
-
|
1111
|
-
|
1112
|
-
|
1109
|
+
JOIN skr_skus s ON ((s.id = sl.sku_id)))
|
1110
|
+
LEFT JOIN skr_uoms uom ON (((uom.sku_id = s.id) AND ((uom.code)::text = (s.default_uom_code)::text))))
|
1111
|
+
JOIN skr_vendors v ON ((s.default_vendor_id = v.id)))
|
1112
|
+
JOIN skr_sku_vendors sv ON (((sv.vendor_id = v.id) AND (sv.sku_id = s.id))));
|
1113
1113
|
|
1114
1114
|
|
1115
1115
|
--
|
@@ -1168,24 +1168,24 @@ CREATE VIEW skr_sku_qty_details AS
|
|
1168
1168
|
COALESCE(sol_ttl.qty, (0)::bigint) AS qty_on_orders,
|
1169
1169
|
COALESCE(pol_ttl.qty, (0)::bigint) AS qty_incoming
|
1170
1170
|
FROM (((skr_skus s
|
1171
|
-
|
1171
|
+
JOIN ( SELECT sum(sl.qty) AS qty,
|
1172
1172
|
sl.sku_id
|
1173
1173
|
FROM skr_sku_locs sl
|
1174
1174
|
GROUP BY sl.sku_id) sl_ttl ON ((sl_ttl.sku_id = s.id)))
|
1175
|
-
|
1176
|
-
|
1177
|
-
|
1178
|
-
|
1179
|
-
|
1180
|
-
|
1181
|
-
|
1182
|
-
|
1183
|
-
|
1184
|
-
|
1185
|
-
|
1186
|
-
|
1187
|
-
|
1188
|
-
|
1175
|
+
LEFT JOIN ( SELECT s_1.id AS sku_id,
|
1176
|
+
sum(((sol.qty - sol.qty_canceled) * sol.uom_size)) AS qty
|
1177
|
+
FROM (((skr_so_lines sol
|
1178
|
+
JOIN skr_sales_orders so ON (((so.id = sol.sales_order_id) AND (so.state <> ALL (ARRAY[5, 9])))))
|
1179
|
+
JOIN skr_sku_locs sl ON ((sl.id = sol.sku_loc_id)))
|
1180
|
+
JOIN skr_skus s_1 ON ((s_1.id = sl.sku_id)))
|
1181
|
+
GROUP BY s_1.id) sol_ttl ON ((sol_ttl.sku_id = s.id)))
|
1182
|
+
LEFT JOIN ( SELECT s_1.id AS sku_id,
|
1183
|
+
sum(((pol.qty - pol.qty_canceled) * pol.uom_size)) AS qty
|
1184
|
+
FROM (((skr_po_lines pol
|
1185
|
+
JOIN skr_purchase_orders po ON (((po.id = pol.purchase_order_id) AND (po.state <> ALL (ARRAY[5, 9])))))
|
1186
|
+
JOIN skr_sku_locs sl ON ((sl.id = pol.sku_loc_id)))
|
1187
|
+
JOIN skr_skus s_1 ON ((s_1.id = sl.sku_id)))
|
1188
|
+
GROUP BY s_1.id) pol_ttl ON ((pol_ttl.sku_id = s.id)));
|
1189
1189
|
|
1190
1190
|
|
1191
1191
|
--
|
@@ -1286,14 +1286,14 @@ CREATE VIEW skr_so_allocation_details AS
|
|
1286
1286
|
ELSE 0
|
1287
1287
|
END) AS number_of_lines_fully_allocated
|
1288
1288
|
FROM ((skr_so_lines sol
|
1289
|
-
|
1290
|
-
|
1289
|
+
JOIN skr_sku_locs sl ON ((sl.id = sol.sku_loc_id)))
|
1290
|
+
JOIN skr_skus s ON (((s.id = sl.sku_id) AND (s.is_other_charge = false))))
|
1291
1291
|
GROUP BY sol.sales_order_id
|
1292
1292
|
HAVING (sum(
|
1293
|
-
CASE
|
1294
|
-
|
1295
|
-
|
1296
|
-
END) > 0);
|
1293
|
+
CASE
|
1294
|
+
WHEN (((sol.qty_allocated - sol.qty_canceled) - sol.qty_picking) > 0) THEN 1
|
1295
|
+
ELSE 0
|
1296
|
+
END) > 0);
|
1297
1297
|
|
1298
1298
|
|
1299
1299
|
--
|
@@ -1313,30 +1313,30 @@ CREATE VIEW skr_so_amount_details AS
|
|
1313
1313
|
COALESCE(ttls.shipping_charge_total, (0)::numeric) AS total_shipping_amount,
|
1314
1314
|
(COALESCE(ttls.total, 0.0) - COALESCE(ttls.other_charge_total, 0.0)) AS subtotal_amount
|
1315
1315
|
FROM (((skr_sales_orders so
|
1316
|
-
|
1317
|
-
|
1318
|
-
|
1319
|
-
|
1320
|
-
|
1321
|
-
|
1322
|
-
|
1323
|
-
|
1324
|
-
|
1325
|
-
|
1326
|
-
|
1327
|
-
|
1328
|
-
|
1329
|
-
|
1330
|
-
|
1331
|
-
|
1332
|
-
|
1333
|
-
|
1334
|
-
|
1335
|
-
|
1336
|
-
|
1337
|
-
|
1338
|
-
|
1339
|
-
|
1316
|
+
JOIN skr_customers cust ON ((cust.id = so.customer_id)))
|
1317
|
+
JOIN skr_addresses addr ON ((addr.id = so.billing_address_id)))
|
1318
|
+
LEFT JOIN ( SELECT sol.sales_order_id,
|
1319
|
+
sum(((sol.qty)::numeric * sol.price)) AS total,
|
1320
|
+
sum(
|
1321
|
+
CASE
|
1322
|
+
WHEN s.is_other_charge THEN ((sol.qty)::numeric * sol.price)
|
1323
|
+
ELSE (0)::numeric
|
1324
|
+
END) AS other_charge_total,
|
1325
|
+
sum(
|
1326
|
+
CASE
|
1327
|
+
WHEN ((sol.sku_code)::text = 'SHIP'::text) THEN ((sol.qty)::numeric * sol.price)
|
1328
|
+
ELSE (0)::numeric
|
1329
|
+
END) AS shipping_charge_total,
|
1330
|
+
sum(
|
1331
|
+
CASE
|
1332
|
+
WHEN ((sol.sku_code)::text = 'TAX'::text) THEN ((sol.qty)::numeric * sol.price)
|
1333
|
+
ELSE (0)::numeric
|
1334
|
+
END) AS tax_charge_total,
|
1335
|
+
count(sol.*) AS num_lines
|
1336
|
+
FROM ((skr_so_lines sol
|
1337
|
+
JOIN skr_sku_locs sl ON ((sl.id = sol.sku_loc_id)))
|
1338
|
+
JOIN skr_skus s ON ((s.id = sl.sku_id)))
|
1339
|
+
GROUP BY sol.sales_order_id) ttls ON ((ttls.sales_order_id = so.id)));
|
1340
1340
|
|
1341
1341
|
|
1342
1342
|
--
|
@@ -1350,13 +1350,13 @@ CREATE VIEW skr_so_dailly_sales_history AS
|
|
1350
1350
|
COALESCE(ttls.line_count, (0)::bigint) AS line_count,
|
1351
1351
|
COALESCE(ttls.total, 0.0) AS total
|
1352
1352
|
FROM (generate_series(0, 120, 1) days_ago(days_ago)
|
1353
|
-
|
1353
|
+
LEFT JOIN ( SELECT count(DISTINCT sol.sales_order_id) AS order_count,
|
1354
1354
|
count(*) AS line_count,
|
1355
1355
|
sum((sol.price * (sol.qty)::numeric)) AS total,
|
1356
1356
|
date_trunc('day'::text, so.created_at) AS so_date
|
1357
1357
|
FROM (skr_so_lines sol
|
1358
|
-
|
1359
|
-
|
1358
|
+
JOIN skr_sales_orders so ON ((sol.sales_order_id = so.id)))
|
1359
|
+
GROUP BY date_trunc('day'::text, so.created_at)) ttls ON ((ttls.so_date = date_trunc('day'::text, ((('now'::text)::date - days_ago.days_ago))::timestamp with time zone))))
|
1360
1360
|
ORDER BY date_trunc('day'::text, ((('now'::text)::date - days_ago.days_ago))::timestamp with time zone) DESC;
|
1361
1361
|
|
1362
1362
|
|
data/db/seed.rb
CHANGED
@@ -4,11 +4,12 @@ require_relative '../lib/skr'
|
|
4
4
|
|
5
5
|
|
6
6
|
module Skr
|
7
|
-
|
8
7
|
user = Lanes::User.where(login: 'admin').first
|
9
8
|
if user.nil?
|
10
|
-
user = Lanes::User.
|
11
|
-
|
9
|
+
user = Lanes::User.create!(name: "Admin", email: "admin@test.com",
|
10
|
+
password: 'senal', password_confirmation: 'senal',
|
11
|
+
login: 'admin', role_names: ['administrator'])
|
12
|
+
|
12
13
|
end
|
13
14
|
Lanes::User.scoped_to(user) do
|
14
15
|
seeds_path = Pathname.new(__FILE__).dirname.join('seed')
|
data/lib/skr/access_roles.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'lanes/access'
|
2
|
+
require_relative "model"
|
2
3
|
|
3
4
|
module Lanes::Access
|
4
5
|
module Roles
|
@@ -6,23 +7,32 @@ module Lanes::Access
|
|
6
7
|
|
7
8
|
# re-open the exising Support role
|
8
9
|
class Support
|
9
|
-
grant Skr::Customer
|
10
|
+
grant Skr::Customer,
|
11
|
+
Skr::Sku,
|
12
|
+
Skr::SalesOrder
|
13
|
+
|
10
14
|
end
|
11
15
|
|
12
16
|
|
13
17
|
class Accounting < Lanes::Access::Role
|
14
|
-
grant Skr::Customer,
|
15
|
-
|
18
|
+
grant Skr::Customer,
|
19
|
+
Skr::PaymentTerm,
|
20
|
+
Skr::Sku,
|
21
|
+
Skr::SalesOrder
|
22
|
+
lock_writes Skr::Sku, :gl_asset_account_id
|
16
23
|
lock_writes Skr::Customer, :terms_id
|
17
24
|
end
|
18
25
|
|
19
26
|
|
20
27
|
class Purchasing < Lanes::Access::Role
|
21
|
-
|
28
|
+
read Skr::Customer
|
29
|
+
grant Skr::Sku,
|
30
|
+
Skr::SalesOrder
|
22
31
|
end
|
23
32
|
|
24
33
|
end
|
25
34
|
|
35
|
+
Role.grant_global_access(Skr::Address)
|
26
36
|
Role.grant_global_access(:read, Skr::PaymentTerm)
|
27
37
|
|
28
38
|
end
|
@@ -20,10 +20,15 @@ module Skr
|
|
20
20
|
# * Blacklists the "state" field so it cannot be set via the API
|
21
21
|
# * Allows access to the "state_event" pseudo field from the API
|
22
22
|
# * Sets up the aasm library with the contents of &block
|
23
|
-
def state_machine(
|
23
|
+
def state_machine(options={}, &block )
|
24
24
|
include InstanceMethods
|
25
25
|
include AASM
|
26
|
-
|
26
|
+
attr_accessor :state_event
|
27
|
+
whitelist_attributes :state_event
|
28
|
+
default_options={
|
29
|
+
no_direct_assignment: true, column: 'state', enum: true
|
30
|
+
}
|
31
|
+
aasm(default_options.merge(options), &block)
|
27
32
|
|
28
33
|
whitelist_attributes :state_event
|
29
34
|
|
data/lib/skr/extension.rb
CHANGED
@@ -9,6 +9,16 @@ module Skr
|
|
9
9
|
root_path Pathname.new(__FILE__).dirname.join("..","..").expand_path
|
10
10
|
components "record-finder", "select-field"
|
11
11
|
|
12
|
+
def client_bootstrap_data(view)
|
13
|
+
gl_accounts = Skr::GlAccount.all.as_json
|
14
|
+
{
|
15
|
+
default_gl_account_ids: Hash[ Skr.config.default_gl_accounts.map{ |code,number|
|
16
|
+
account = gl_accounts.detect{|gla|gla['number'] == number}
|
17
|
+
[code, account ? account['id'] : 0]
|
18
|
+
}],
|
19
|
+
gl_accounts: gl_accounts
|
20
|
+
}
|
21
|
+
end
|
12
22
|
|
13
23
|
end
|
14
24
|
|
data/lib/skr/model.rb
CHANGED
@@ -12,8 +12,41 @@ module Skr
|
|
12
12
|
include Concerns::ImmutableModel
|
13
13
|
include Concerns::VisibleIdIdentifier
|
14
14
|
include Concerns::LockedFields
|
15
|
-
include Concerns::CodeIdentifier
|
16
15
|
include Concerns::RandomHashCode
|
17
16
|
end
|
18
17
|
|
18
|
+
autoload :Address, "skr/models/address"
|
19
|
+
autoload :BusinessEntity, "skr/models/business_entity"
|
20
|
+
autoload :Customer, "skr/models/customer"
|
21
|
+
autoload :GlAccount, "skr/models/gl_account"
|
22
|
+
autoload :GlManualEntry, "skr/models/gl_manual_entry"
|
23
|
+
autoload :GlPeriod, "skr/models/gl_period"
|
24
|
+
autoload :GlPosting, "skr/models/gl_posting"
|
25
|
+
autoload :GlTransaction, "skr/models/gl_transaction"
|
26
|
+
autoload :IaLine, "skr/models/ia_line"
|
27
|
+
autoload :IaReason, "skr/models/ia_reason"
|
28
|
+
autoload :InvLine, "skr/models/inv_line"
|
29
|
+
autoload :InventoryAdjustment, "skr/models/inventory_adjustment"
|
30
|
+
autoload :Invoice, "skr/models/invoice"
|
31
|
+
autoload :Location, "skr/models/location"
|
32
|
+
autoload :PaymentTerm, "skr/models/payment_term"
|
33
|
+
autoload :PickTicket, "skr/models/pick_ticket"
|
34
|
+
autoload :PoLine, "skr/models/po_line"
|
35
|
+
autoload :PoReceipt, "skr/models/po_receipt"
|
36
|
+
autoload :PorLine, "skr/models/por_line"
|
37
|
+
autoload :PtLine, "skr/models/pt_line"
|
38
|
+
autoload :PurchaseOrder, "skr/models/purchase_order"
|
39
|
+
autoload :SalesOrder, "skr/models/sales_order"
|
40
|
+
autoload :SequentialId, "skr/models/sequential_id"
|
41
|
+
autoload :Sku, "skr/models/sku"
|
42
|
+
autoload :SkuLoc, "skr/models/sku_loc"
|
43
|
+
autoload :SkuTran, "skr/models/sku_tran"
|
44
|
+
autoload :SkuVendor, "skr/models/sku_vendor"
|
45
|
+
autoload :SoLine, "skr/models/so_line"
|
46
|
+
autoload :Uom, "skr/models/uom"
|
47
|
+
autoload :UserProxy, "skr/models/user_proxy"
|
48
|
+
autoload :DocumentsController, "skr/models/user_proxy"
|
49
|
+
autoload :Vendor, "skr/models/vendor"
|
50
|
+
autoload :VoLine, "skr/models/vo_line"
|
51
|
+
autoload :Voucher, "skr/models/voucher"
|
19
52
|
end
|
data/lib/skr/models/address.rb
CHANGED
@@ -23,7 +23,7 @@ module Skr
|
|
23
23
|
validates :name, :line1, :city, :state, :postal_code, :presence=>true, :if=>:ensure_not_blank
|
24
24
|
validates :email, :presence=>true, :email=>true, :if=>:validate_email
|
25
25
|
validates :phone, :presence=>true, :if=>:validate_phone
|
26
|
-
|
26
|
+
|
27
27
|
# @return [Address] a blank copy of an address
|
28
28
|
def self.blank
|
29
29
|
Address.new({ name: '', line1: '', city: '', state: '', postal_code: '' })
|
@@ -45,9 +45,9 @@ module Skr
|
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
48
|
-
# @return [Boolean] is
|
49
|
-
def
|
50
|
-
return
|
48
|
+
# @return [Boolean] is all of (name line1 city state postal_code) blank?
|
49
|
+
def incomplete?
|
50
|
+
return %w{ name line1 city state postal_code }.all?{ |field| self[field].blank? }
|
51
51
|
end
|
52
52
|
|
53
53
|
# split the name on space
|
data/lib/skr/models/customer.rb
CHANGED
@@ -47,7 +47,12 @@ module Skr
|
|
47
47
|
}
|
48
48
|
|
49
49
|
export_scope :only_incoming, lambda { |should_use=true|
|
50
|
-
with_details.where(
|
50
|
+
with_details.where.not(state: :received) if should_use
|
51
|
+
}
|
52
|
+
|
53
|
+
enum state: {
|
54
|
+
open: 1,
|
55
|
+
received: 2
|
51
56
|
}
|
52
57
|
|
53
58
|
state_machine do
|
@@ -62,7 +62,7 @@ module Skr
|
|
62
62
|
|
63
63
|
# a open SalesOrder is one who's state is not "complete" or "canceled"
|
64
64
|
scope :open, lambda { | *args |
|
65
|
-
where(
|
65
|
+
where.not(state: [:complete,:canceled])
|
66
66
|
}, export: true
|
67
67
|
|
68
68
|
# a SalesOrder is allocated if it has one or more lines with qty_allocated>0
|
@@ -89,6 +89,12 @@ module Skr
|
|
89
89
|
connection.execute(qry).values
|
90
90
|
end
|
91
91
|
|
92
|
+
enum state: {
|
93
|
+
open: 1,
|
94
|
+
complete: 5,
|
95
|
+
canceled: 9
|
96
|
+
}
|
97
|
+
|
92
98
|
state_machine do
|
93
99
|
state :open, initial: true
|
94
100
|
state :complete
|
data/lib/skr/version.rb
CHANGED
data/lib/skr.rb
CHANGED
@@ -1,2 +1,43 @@
|
|
1
1
|
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
|
2
2
|
|
3
|
+
cash:
|
4
|
+
number: 1010
|
5
|
+
name: Cash
|
6
|
+
description: Checking account balance (as shown in company records), currency, coins, checks received from customers but not yet deposited.
|
7
|
+
|
8
|
+
bank_checking:
|
9
|
+
number: 1011
|
10
|
+
name: Cash
|
11
|
+
description: Checking account balance (as shown in company records), currency, coins, checks received from customers but not yet deposited.
|
12
|
+
|
13
|
+
deposits:
|
14
|
+
number: 1200
|
15
|
+
name: Deposits
|
16
|
+
description: Deposit holding account
|
17
|
+
|
18
|
+
inv_recpt:
|
19
|
+
number: 2600
|
20
|
+
name: Accounts Receivable Clearing
|
21
|
+
description: Inventory Receipts clearing
|
22
|
+
|
23
|
+
ar:
|
24
|
+
number: 1220
|
25
|
+
name: Accounts Receivable
|
26
|
+
description: Amounts owed to the company for services performed or products sold but not yet paid for.
|
27
|
+
|
28
|
+
tax:
|
29
|
+
number: 2250
|
30
|
+
name: Sales Tax Recv
|
31
|
+
description: Tax collected
|
32
|
+
|
33
|
+
ap:
|
34
|
+
number: 2200
|
35
|
+
name: Accounts Payable
|
36
|
+
description: Amounts owed to the outside vendors for services performed or products received but not yet paid for.
|
37
|
+
|
38
|
+
sales:
|
39
|
+
number: 4000
|
40
|
+
name: Sales
|
41
|
+
description: Amounts earned from selling physical goods. When a sale is provided on credit, both this account and Accounts Receivable will increase. When a service is provided for immediate cash, both this account and Cash will increase.
|
42
|
+
|
43
|
+
|