unidom-order 1.4.1 → 1.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 01a8d08f48da45e3f69d83854fb7b62f75638160
4
- data.tar.gz: ec8f32394c74a15518b8ff6179a76770310c988e
3
+ metadata.gz: e091e23d5b3eb27ad6a15956f79901c6cc293127
4
+ data.tar.gz: 242b53a3e93e89b0ae87957c241acd016a15c572
5
5
  SHA512:
6
- metadata.gz: 9f3788cd64f303519346a8d3bf5063d158e4364fceb6a04286a280e118ef4a0e208670024784cf3605437ddd4d201cd9ebbc7657cb54438dd37178e40e893633
7
- data.tar.gz: 59afcf91a336e94f77b35bc9c1a549c5f57b275523bdaab0790d2bb7af5ea08a0b66ffdb63d53b7567081cdd68814dc90810731e889beee04ef0fa6d53720be2
6
+ metadata.gz: 4a1f3ca8d004687a472626259f5400dcaf8a2b5924c1eaf5cb0e5f1d4f15cf37cfbd53613ae2eb0b39908842f59b25704258b569a8f13edf112bde597d2c06a3
7
+ data.tar.gz: 389637997d93c82734639e617a805757b50f4263298fe241637422eb88749cc9a6fdc658fb03f956c7999d01980db3f35e5697cb336373ea6a9fba7888daa27d
data/README.md CHANGED
@@ -112,19 +112,24 @@ include Unidom::Order::AsOrderTaker
112
112
 
113
113
  ### As Adjusted concern
114
114
 
115
- The As Adjusted concern do the following tasks for the includer automatically:
116
- 1. Define the has_many :adjustments macro as: ``has_many :adjustments, class_name: 'Unidom::Order::OrderAdjustment', as: :adjusted``
117
- 2. Define the #is_adjusted! method as: ``is_adjusted!(amount, due_to: 'FRGT', at: Time.now)``
115
+ The As Adjusted concern do the following tasks for the includer automatically:
116
+
117
+ 1. Define the has_many :adjustments macro as: ``has_many :adjustments, class_name: 'Unidom::Order::OrderAdjustment', as: :adjusted``
118
+
119
+ 2. Define the #is_adjusted! method as: ``is_adjusted!(amount, due_to: 'FRGT', at: Time.now)``
120
+
118
121
  3. Define the #is_adjusted? method as: ``is_adjusted?(due_to: 'FRGT', at: Time.now)``
119
122
 
120
123
  ### As Order Placer concern
121
124
 
122
- The As Order Placer concern do the following tasks for the includer automatically:
125
+ The As Order Placer concern do the following tasks for the includer automatically:
126
+
123
127
  1. Define the has_many :placed_orders macro as: ``has_many :placed_orders, class_name: 'Unidom::Order::Order', as: :placer``
124
128
 
125
129
  ### As Order Taker concern
126
130
 
127
- The As Order Taker concern do the following tasks for the includer automatically:
131
+ The As Order Taker concern do the following tasks for the includer automatically:
132
+
128
133
  1. Define the has_many :taken_orders macro as: ``has_many :taken_orders, class_name: 'Unidom::Order::Order', as: :taker``
129
134
 
130
135
 
@@ -141,3 +146,19 @@ Unidom::Order::AdjustmentFactor::SHIPPING_AND_HANDLING_CHARGES # 装运和处理
141
146
  Unidom::Order::AdjustmentFactor::FEE # 手续费
142
147
  Unidom::Order::AdjustmentFactor::MISCELLANEOUS_CHARGE # 杂项收费
143
148
  ```
149
+
150
+
151
+
152
+ ## Disable the Model & Migration
153
+
154
+ If you only need the app components other than models, the migrations should be neglected, and the models should not be loaded.
155
+ ```ruby
156
+ # config/initializers/unidom.rb
157
+ Unidom::Common.configure do |options|
158
+
159
+ options[:neglected_namespaces] = %w{
160
+ Unidom::Order
161
+ }
162
+
163
+ end
164
+ ```
@@ -1,3 +1,6 @@
1
+ ##
2
+ # Application controller 是模块内所有控制器的基类。
3
+
1
4
  class Unidom::Order::ApplicationController < ActionController::Base
2
5
  protect_from_forgery with: :exception
3
6
  end
@@ -1,2 +1,5 @@
1
+ ##
2
+ # Application job 是模块内所有异步任务的基类。
3
+
1
4
  class Unidom::Order::ApplicationJob < ActiveJob::Base
2
5
  end
@@ -1,3 +1,6 @@
1
+ ##
2
+ # Application mailer 是模块内所有电子邮件发送类的基类。
3
+
1
4
  class Unidom::Order::ApplicationMailer < ActionMailer::Base
2
5
  default from: 'from@example.com'
3
6
  layout 'mailer'
@@ -1,3 +1,6 @@
1
+ ##
2
+ # Application record 是模块内所有模型的抽象基类。
3
+
1
4
  class Unidom::Order::ApplicationRecord < ActiveRecord::Base
2
5
  self.abstract_class = true
3
6
  end
@@ -20,4 +20,4 @@ class Unidom::Order::Order < Unidom::Order::ApplicationRecord
20
20
  scope :placed_by, ->(placer) { where placer: placer }
21
21
  scope :taken_by, ->(taker) { where taker: taker }
22
22
 
23
- end
23
+ end unless Unidom::Common::Neglection.namespace_neglected? 'Unidom::Order::Order'
@@ -16,6 +16,9 @@ class Unidom::Order::OrderAdjustment < Unidom::Order::ApplicationRecord
16
16
 
17
17
  code :adjustment_factor, Unidom::Order::AdjustmentFactor
18
18
 
19
+ ##
20
+ # 对订单或者订单项 adjusted 进行调整。调整金额为 amount ,缺省为 0 。调整原因是 due_to ,缺省是 FRGT 。调整时间是 opened_at ,缺省为当前时间。如:
21
+ # Unidom::Order::OrderAdjustment.adjust! order, amount: 7.90, due_to: 'LTAX'
19
22
  def self.adjust!(adjusted, amount: 0, due_to: 'FRGT', opened_at: Time.now)
20
23
  query = adjusted_is(adjusted).adjustment_factor_coded_as(due_to).valid_at(now: opened_at).alive
21
24
  adjustment = query.first
@@ -32,4 +35,4 @@ class Unidom::Order::OrderAdjustment < Unidom::Order::ApplicationRecord
32
35
  adjustment
33
36
  end
34
37
 
35
- end
38
+ end unless Unidom::Common::Neglection.namespace_neglected? 'Unidom::Order::OrderAdjustment'
@@ -22,6 +22,9 @@ class Unidom::Order::OrderItem < Unidom::Order::ApplicationRecord
22
22
  scope :ordered_is, ->(ordered) { where ordered: ordered }
23
23
  scope :placed_by, ->(placer) { where placer: placer }
24
24
 
25
+ ##
26
+ # 订购商品 ordered ,放入订单 of 。订购者为 by ,缺省为订单的下单者。单价为 unit_price ,缺省值为 0 。数量为 quantity ,缺省值为 1。如:
27
+ # Unidom::Order::OrderItem.order! coca_cola, of: order, by: current_person, unit_price: 3.50, quantity: 2
25
28
  def self.order!(ordered, of: nil, by: of.placer, unit_price: 0, quantity: 1)
26
29
  item = of.items.ordered_is(ordered).placed_by(by).valid_at.alive.first
27
30
  if item.present?
@@ -36,4 +39,4 @@ class Unidom::Order::OrderItem < Unidom::Order::ApplicationRecord
36
39
  end
37
40
  end
38
41
 
39
- end
42
+ end unless Unidom::Common::Neglection.namespace_neglected? 'Unidom::Order::OrderItem'
@@ -1,7 +1,7 @@
1
1
  <!DOCTYPE html>
2
2
  <html>
3
3
  <head>
4
- <title>Order</title>
4
+ <title>Unidom Order</title>
5
5
  <%= stylesheet_link_tag "unidom/order/application", media: "all" %>
6
6
  <%= csrf_meta_tags %>
7
7
  </head>
@@ -1,5 +1,5 @@
1
1
  module Unidom
2
2
  module Order
3
- VERSION = '1.4.1'.freeze
3
+ VERSION = '1.4.2'.freeze
4
4
  end
5
5
  end
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.1
4
+ version: 1.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Topbit Du
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-01-03 00:00:00.000000000 Z
11
+ date: 2017-01-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: unidom-common
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.8'
19
+ version: '1.9'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '1.8'
26
+ version: '1.9'
27
27
  description: Unidom (UNIfied Domain Object Model) is a series of domain model engines.
28
28
  The Order domain model engine includes Order, Order Item, and Order Adjustment models.
29
29
  Unidom (统一领域对象模型)是一系列的领域模型引擎。订单领域模型引擎包括订单、订单项和订单调整的模型。