unidom-order 1.3.3 → 1.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c8698024aa710976d4888ef36bdd2e93727937cf
4
- data.tar.gz: 0c3d619e542fcdc5ab321903d795b15aaba08f66
3
+ metadata.gz: 2d1fa66d2364b60de3450cfe90fc68f9f72c2db8
4
+ data.tar.gz: e2adc0a6972748779bcf763951bfa2098900f612
5
5
  SHA512:
6
- metadata.gz: e895ce053c3203cd6c4ed293e2961d095906ebb75a81a6bd5b0c14a92a22892abe91efd571323b53ee4c495ea6fbc39833f532fbe540817e15c1aacf4a33d0ea
7
- data.tar.gz: b82a3401b9158d656f5c078332df2c2ab0ff7b01eb4efd0f027e39485229222ff14c8804b077843d689d22166800e11253cace3188233960023c51575ff9dc71
6
+ metadata.gz: f7b20de05ccbe2922ed4e7152419c84557fd4732c69e518a7a3c1abe6658af14c845ffafa592e11ffea60665b7c2cf4741334bac8a92b499684d2813a469bf88
7
+ data.tar.gz: 34f2db87779651a16dff3d2402ba482c5dabdd04cb6fda6fb11af14386376766cda62670321029a9e9b352a81de318b298029b12b7cd77ef0a60fd0588363be2
data/README.md CHANGED
@@ -126,3 +126,18 @@ The As Order Placer concern do the following tasks for the includer automaticall
126
126
 
127
127
  The As Order Taker concern do the following tasks for the includer automatically:
128
128
  1. Define the has_many :taken_orders macro as: ``has_many :taken_orders, class_name: 'Unidom::Order::Order', as: :taker``
129
+
130
+
131
+
132
+ ## Enum codes
133
+
134
+ ### Adjustment Factor enum code 调整因素
135
+
136
+ ```ruby
137
+ Unidom::Order::AdjustmentFactor::DISCOUNT_ADJUSTMENT # 折扣调整
138
+ Unidom::Order::AdjustmentFactor::SURCHARGE_ADJUSTMENT # 额外费调整
139
+ Unidom::Order::AdjustmentFactor::SALES_TAX # 销售税
140
+ Unidom::Order::AdjustmentFactor::SHIPPING_AND_HANDLING_CHARGES # 装运和处理费
141
+ Unidom::Order::AdjustmentFactor::FEE # 手续费
142
+ Unidom::Order::AdjustmentFactor::MISCELLANEOUS_CHARGE # 杂项收费
143
+ ```
@@ -1,3 +1,4 @@
1
+ ##
1
2
  # Order 是订单。
2
3
 
3
4
  class Unidom::Order::Order < Unidom::Order::ApplicationRecord
@@ -1,3 +1,4 @@
1
+ ##
1
2
  # Order Adjustment 是订单调整项。
2
3
 
3
4
  class Unidom::Order::OrderAdjustment < Unidom::Order::ApplicationRecord
@@ -5,6 +6,7 @@ class Unidom::Order::OrderAdjustment < Unidom::Order::ApplicationRecord
5
6
  self.table_name = 'unidom_order_adjustments'
6
7
 
7
8
  include Unidom::Common::Concerns::ModelExtension
9
+ include ProgneTapera::EnumCode
8
10
 
9
11
  validates :amount, presence: true, numericality: { less_than: 1000000000, greater_than: -1000000000 }
10
12
 
@@ -12,6 +14,8 @@ class Unidom::Order::OrderAdjustment < Unidom::Order::ApplicationRecord
12
14
 
13
15
  scope :adjusted_is, ->(adjusted) { where adjusted: adjusted }
14
16
 
17
+ code :adjustment_factor, Unidom::Order::AdjustmentFactor
18
+
15
19
  def self.adjust!(adjusted, amount: 0, due_to: 'FRGT', opened_at: Time.now)
16
20
  query = adjusted_is(adjusted).adjustment_factor_coded_as(due_to).valid_at(now: opened_at).alive
17
21
  adjustment = query.first
@@ -1,3 +1,4 @@
1
+ ##
1
2
  # Order Item 是订单项。
2
3
 
3
4
  class Unidom::Order::OrderItem < Unidom::Order::ApplicationRecord
@@ -0,0 +1,9 @@
1
+ # Adjustment Factor 是调整因素。
2
+
3
+ class Unidom::Order::AdjustmentFactor < ActiveRecord::Type::Value
4
+
5
+ include ProgneTapera::EnumConfig
6
+
7
+ enum :unidom_adjustment_factor
8
+
9
+ end
data/config/enum.yml ADDED
@@ -0,0 +1,15 @@
1
+ enum:
2
+
3
+ unidom_adjustment_factor:
4
+ discount_adjustment:
5
+ code: DSCT
6
+ surcharge_adjustment:
7
+ code: SCHG
8
+ sales_tax:
9
+ code: SLTX
10
+ shipping_and_handling_charges:
11
+ code: SPHD
12
+ fee:
13
+ code: FEES
14
+ miscellaneous_charge:
15
+ code: MISC
@@ -0,0 +1,10 @@
1
+ 'zh-CN':
2
+ enum:
3
+
4
+ unidom_adjustment_factor:
5
+ discount_adjustment: 折扣调整
6
+ surcharge_adjustment: 额外费调整
7
+ sales_tax: 销售税
8
+ shipping_and_handling_charges: 装运和处理费
9
+ fee: 手续费
10
+ miscellaneous_charge: 杂项收费
@@ -1,3 +1,5 @@
1
+ require 'unidom/common/yaml_helper'
2
+
1
3
  module Unidom
2
4
  module Order
3
5
 
@@ -5,6 +7,10 @@ module Unidom
5
7
 
6
8
  isolate_namespace ::Unidom::Order
7
9
 
10
+ initializer :load_config_initializers do |app|
11
+ Unidom::Common::YamlHelper.load_enum config: app.config, root: config.root
12
+ end
13
+
8
14
  initializer :append_migrations do |app|
9
15
  config.paths['db/migrate'].expanded.each { |expanded_path| app.config.paths['db/migrate'] << expanded_path } unless app.root.to_s.match root.to_s
10
16
  end
@@ -1,5 +1,5 @@
1
1
  module Unidom
2
2
  module Order
3
- VERSION = '1.3.3'.freeze
3
+ VERSION = '1.4'.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.3.3
4
+ version: '1.4'
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-12-05 00:00:00.000000000 Z
11
+ date: 2016-12-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: unidom-common
@@ -50,7 +50,10 @@ files:
50
50
  - app/models/unidom/order/order.rb
51
51
  - app/models/unidom/order/order_adjustment.rb
52
52
  - app/models/unidom/order/order_item.rb
53
+ - app/types/unidom/order/adjustment_factor.rb
53
54
  - app/views/layouts/unidom/order/application.html.erb
55
+ - config/enum.yml
56
+ - config/locales/enum.zh-CN.yml
54
57
  - config/routes.rb
55
58
  - db/migrate/20020601000000_create_unidom_orders.rb
56
59
  - db/migrate/20020602000000_create_unidom_order_items.rb