unidom-order 1.2 → 1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +16 -0
- data/app/models/unidom/order/concerns/as_adjusted.rb +7 -0
- data/app/models/unidom/order/concerns/as_order_placer.rb +3 -0
- data/app/models/unidom/order/concerns/as_order_taker.rb +3 -0
- data/app/models/unidom/order/order_item.rb +5 -5
- data/lib/unidom/order/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: 2a122ad78313c41f4eb11d252867052ca9e2162f
|
4
|
+
data.tar.gz: 7084f6f7a1330793c369198f84d802e60f1174b2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c769c8a144ee715e1c5002be583d90f879601b8180655118dd8bab71b51ffe5ef18819b638ee2e8318b9b9f51d106605dc4b7cf3319895c405bd42eb3c0fbe41
|
7
|
+
data.tar.gz: 9aae203adde1f5e273323251a667aff492f0f900f91f86d3499a439c38f804112ef46be78814b2b381b5d164b680afb2d1adacd4caf04e658ac6a67fb6a0270b
|
data/README.md
CHANGED
@@ -6,22 +6,34 @@
|
|
6
6
|
Unidom (UNIfied Domain Object Model) is a series of domain model engines. The Order domain model engine includes Order, Order Item, and Order Adjustment models.
|
7
7
|
Unidom (统一领域对象模型)是一系列的领域模型引擎。订单领域模型引擎包括订单、订单项和订单调整的模型。
|
8
8
|
|
9
|
+
|
10
|
+
|
9
11
|
## Recent Update
|
12
|
+
|
10
13
|
Check out the [Road Map](ROADMAP.md) to find out what's the next.
|
11
14
|
Check out the [Change Log](CHANGELOG.md) to find out what's new.
|
12
15
|
|
16
|
+
|
17
|
+
|
13
18
|
## Usage in Gemfile
|
19
|
+
|
14
20
|
```ruby
|
15
21
|
gem 'unidom-order'
|
16
22
|
```
|
17
23
|
|
24
|
+
|
25
|
+
|
18
26
|
## Run the Database Migration
|
27
|
+
|
19
28
|
```shell
|
20
29
|
rake db:migrate
|
21
30
|
```
|
22
31
|
The migration versions start with 200206.
|
23
32
|
|
33
|
+
|
34
|
+
|
24
35
|
## Call the Model
|
36
|
+
|
25
37
|
```ruby
|
26
38
|
lady = Person.create name: 'Ann'
|
27
39
|
shop = Shop.create name: 'WalMart'
|
@@ -87,7 +99,10 @@ Unidom::Order::OrderAdjustment.adjust! order, amount: 20, due_to: 'DSCT', opened
|
|
87
99
|
# Add the given adjustment into the given order
|
88
100
|
```
|
89
101
|
|
102
|
+
|
103
|
+
|
90
104
|
## Include the Concerns
|
105
|
+
|
91
106
|
```ruby
|
92
107
|
include Unidom::Order::AsAdjusted
|
93
108
|
include Unidom::Order::AsOrderPlacer
|
@@ -98,6 +113,7 @@ include Unidom::Order::AsOrderTaker
|
|
98
113
|
The As Adjusted concern do the following tasks for the includer automatically:
|
99
114
|
1. Define the has_many :adjustments macro as: ``has_many :adjustments, class_name: 'Unidom::Order::OrderAdjustment', as: :adjusted``
|
100
115
|
2. Define the #is_adjusted! method as: ``is_adjusted!(amount, due_to: 'FRGT', at: Time.now)``
|
116
|
+
3. Define the #is_adjusted? method as: ``is_adjusted?(due_to: 'FRGT', at: Time.now)``
|
101
117
|
|
102
118
|
### As Order Placer concern
|
103
119
|
The As Order Placer concern do the following tasks for the includer automatically:
|
@@ -22,6 +22,13 @@ module Unidom::Order::Concerns::AsAdjusted
|
|
22
22
|
adjustment
|
23
23
|
end
|
24
24
|
|
25
|
+
def is_adjusted?(due_to: 'FRGT', at: Time.now)
|
26
|
+
adjustments.adjustment_factor_coded_as(due_to).valid_at(now: at).alive.exists?
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
module ClassMethods
|
25
32
|
end
|
26
33
|
|
27
34
|
end
|
@@ -7,11 +7,11 @@ class Unidom::Order::OrderItem < ActiveRecord::Base
|
|
7
7
|
include Unidom::Common::Concerns::ModelExtension
|
8
8
|
include Unidom::Order::Concerns::AsAdjusted
|
9
9
|
|
10
|
-
validates :ordinal, presence: true, numericality: { only_integer: true, greater_than: 0, less_than:
|
11
|
-
validates :unit_price, presence: true, numericality: { less_than:
|
12
|
-
validates :quantity, presence: true, numericality: { less_than:
|
13
|
-
validates :purchase_amount, presence: true, numericality: { less_than:
|
14
|
-
validates :subtotal_amount, presence: true, numericality: { less_than:
|
10
|
+
validates :ordinal, presence: true, numericality: { only_integer: true, greater_than: 0, less_than: 1_000_000_000 }
|
11
|
+
validates :unit_price, presence: true, numericality: { less_than: 1_000_000_000, greater_than: 0 }
|
12
|
+
validates :quantity, presence: true, numericality: { less_than: 1_000_000_000, greater_than: 0 }
|
13
|
+
validates :purchase_amount, presence: true, numericality: { less_than: 1_000_000_000, greater_than: 0 }
|
14
|
+
validates :subtotal_amount, presence: true, numericality: { less_than: 1_000_000_000, greater_than: 0 }
|
15
15
|
|
16
16
|
belongs_to :order, class_name: 'Unidom::Order::Order'
|
17
17
|
belongs_to :ordered, polymorphic: true
|
data/lib/unidom/order/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: unidom-order
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '1.
|
4
|
+
version: '1.3'
|
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-09-
|
11
|
+
date: 2016-09-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: unidom-common
|