unidom-product 0.4 → 1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +6 -0
- data/app/models/unidom/product/product_associating.rb +3 -3
- data/lib/unidom/product/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eec6cc009a7832a8b54efc5d072b77c5ccce2ad0
|
4
|
+
data.tar.gz: 435f58b1832e69ae946fce6a82e0d2e067c54932
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: efed501763cd32d445c46d7fca604340373a3675a2a10937f6d6247dbd31787b53a3758a1f6bc5db45281cedeac05e4181a9f157c0e88217aa4f9fb0b61175a0
|
7
|
+
data.tar.gz: 91d1ffda19db36b028a54778996bf44b5a776886508311c02997fb5665ac78988b84f8ecd1e69848685efd9935de158ad25a533b0a30de84a684c1254f16a675
|
data/README.md
CHANGED
@@ -34,4 +34,10 @@ product = Unidom::Product::Product.create(name: 'Apple iPhone 6S Plus 64G',
|
|
34
34
|
|
35
35
|
# Find the Product per Formset Code
|
36
36
|
Product.formset_coded_as('SRVC').valid_at.alive.first
|
37
|
+
|
38
|
+
# Associate 2 products as incompatible
|
39
|
+
Unidom::Product::ProductAssociating.associate! product_1, with: product_2, due_to: 'ICPT', ordinal: 1, quantity: 1, at: Time.now
|
40
|
+
|
41
|
+
# Find the Product Associating per the source product & the target product
|
42
|
+
associating = Unidom::Product::ProductAssociating.source_is(product_1).target_is(product_2).first
|
37
43
|
```
|
@@ -22,9 +22,9 @@ class Unidom::Product::ProductAssociating < ActiveRecord::Base
|
|
22
22
|
scope :source_is, ->(product) { where source_id: to_id(product) }
|
23
23
|
scope :target_is, ->(product) { where target_id: to_id(product) }
|
24
24
|
|
25
|
-
def self.associate!(source, target,
|
25
|
+
def self.associate!(source, with: target, due_to: 'PCKG', ordinal: 1, quantity: 1, at: Time.now)
|
26
26
|
|
27
|
-
associating = source_is(source).target_is(
|
27
|
+
associating = source_is(source).target_is(with).product_association_coded_as(due_to).valid_at.alive.first
|
28
28
|
associating.soft_destroy if associating.present?
|
29
29
|
|
30
30
|
#if associating.present?
|
@@ -34,7 +34,7 @@ class Unidom::Product::ProductAssociating < ActiveRecord::Base
|
|
34
34
|
# associating = create! source_id: to_id(source), target_id: to_id(target), product_association_code: product_association_code, ordinal: ordinal, quantity: quantity, opened_at: opened_at
|
35
35
|
#end
|
36
36
|
#associating
|
37
|
-
create! source_id: to_id(source), target_id: to_id(
|
37
|
+
create! source_id: to_id(source), target_id: to_id(with), product_association_code: due_to, ordinal: ordinal, quantity: quantity, opened_at: at
|
38
38
|
|
39
39
|
end
|
40
40
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: unidom-product
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '0
|
4
|
+
version: '1.0'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Topbit Du
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-09-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: unidom-common
|