unidom-price 1.3.2 → 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: 46531b567b8cfff0265600f010c4ba03a3971738
4
- data.tar.gz: 8dee7197a057b31cf8b2f8b68607c21e5ebb6ecc
3
+ metadata.gz: 80da85d95daaa8a3a9c5706166a46ec644c59671
4
+ data.tar.gz: e063e9eaec1279176f577c96bc475116a1d152fc
5
5
  SHA512:
6
- metadata.gz: 7176041cb4dd40db7dea61147d55a3d37a906c0947feb1db91cb24207dc8d24b8ae82525b25db6f28f418d653610f47adaccc95ffc9ea6dbfc10e45ad3ea3388
7
- data.tar.gz: cc871c3f717eec016ddd88aae37da6f32ec4c3eafd788cf82039d1ebc00cbad12a17dade65033fd959ed4a0cd43c65085175acc73946b4ea32675ab49de2b433
6
+ metadata.gz: f961a8ed4d3e809cc2a0bd3cc1613180465b12884049d8d14296f709000e26b053f689319a5a279d1069adc1f08635c9df509b4325bd8a60e5ab41fed700bf4c
7
+ data.tar.gz: 1fdd125fad782c690bc4f9a086120e10b44e324b71984da3350f22d9f7ae6ec0bb1857f71b26af36547e4b5c2d29f02fcdce3d6fcc524b79e6fa83fd33391112
data/README.md CHANGED
@@ -89,3 +89,14 @@ The As Priced concern do the following tasks for the includer automatically:
89
89
  1. Define the has_many :pricings macro as: ``has_many :pricings, class_name: 'Unidom::Price::Price', as: :pricer``
90
90
  2. Define the #price! method as: ``price!(it, amount, at: Time.now)``
91
91
  3. Define the #price? method as: ``price?(it, at: Time.now)``
92
+
93
+
94
+
95
+ ## Enum codes
96
+
97
+ ### Calculation enum code
98
+
99
+ ```ruby
100
+ Unidom::Price::Calculation::AMOUNT
101
+ Unidom::Price::Calculation::PERCENTAGE
102
+ ```
@@ -1,10 +1,13 @@
1
1
  # Price 是价格。
2
+ # pricing: 基价(Base)、折扣成分、额外收费成分、厂商建议价。
3
+ # charging: 一次性收费、重复性收费、使用率收费。
2
4
 
3
5
  class Unidom::Price::Price < Unidom::Price::ApplicationRecord
4
6
 
5
7
  self.table_name = 'unidom_prices'
6
8
 
7
9
  include Unidom::Common::Concerns::ModelExtension
10
+ include ProgneTapera::EnumCode
8
11
 
9
12
  validates :amount, presence: true, numericality: { less_than: 1000000000, greater_than: 0 }
10
13
 
@@ -14,6 +17,8 @@ class Unidom::Price::Price < Unidom::Price::ApplicationRecord
14
17
  scope :priced_by, ->(pricer) { where pricer: pricer }
15
18
  scope :priced_is, ->(priced) { where priced: priced }
16
19
 
20
+ code :calculation, Unidom::Price::Calculation
21
+
17
22
  def self.price!(priced, amount: 0, pricer: nil, calculation_code: 'AMNT', pricing_code: 'BASE', charging_code: 'ONCE', opened_at: Time.now)
18
23
  price = priced_is(priced).calculation_coded_as(calculation_code).pricing_coded_as(pricing_code).charging_coded_as(charging_code).valid_at.alive.first
19
24
  if price.present?
@@ -0,0 +1,7 @@
1
+ class Unidom::Price::Calculation < ActiveRecord::Type::Value
2
+
3
+ include ProgneTapera::EnumConfig
4
+
5
+ enum :unidom_calculation
6
+
7
+ end
@@ -1,15 +1,15 @@
1
1
  <!DOCTYPE html>
2
2
  <html>
3
3
  <head>
4
- <title>Price</title>
5
- <%= stylesheet_link_tag "price/application", media: "all" %>
4
+ <title>Unidom Price</title>
5
+ <%= stylesheet_link_tag 'unidom/price/application', media: "all" %>
6
6
  <%= csrf_meta_tags %>
7
7
  </head>
8
8
  <body>
9
9
 
10
10
  <%= yield %>
11
11
 
12
- <%= javascript_include_tag 'price/application' %>
12
+ <%= javascript_include_tag 'unidom/price/application' %>
13
13
 
14
14
  </body>
15
15
  </html>
data/config/enum.yml ADDED
@@ -0,0 +1,7 @@
1
+ enum:
2
+
3
+ unidom_calculation:
4
+ amount:
5
+ code: AMNT
6
+ percentage:
7
+ code: PCTG
@@ -0,0 +1,6 @@
1
+ 'zh-CN':
2
+ enum:
3
+
4
+ unidom_calculation:
5
+ amount: 金额
6
+ percentage: 百分比
@@ -1,3 +1,5 @@
1
+ require 'unidom/common/yaml_helper'
2
+
1
3
  module Unidom
2
4
  module Price
3
5
 
@@ -5,6 +7,10 @@ module Unidom
5
7
 
6
8
  isolate_namespace ::Unidom::Price
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 Price
3
- VERSION = '1.3.2'.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-price
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.2
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-11-12 00:00:00.000000000 Z
11
+ date: 2016-12-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: unidom-common
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: progne_tapera
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0.3'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0.3'
27
41
  description: Unidom (UNIfied Domain Object Model) is a series of domain model engines.
28
42
  The Price domain model engine includes Pricing and its relative models. Unidom (统一领域对象模型)是一系列的领域模型引擎。价格领域模型引擎包括定价及其相关的模型。
29
43
  email:
@@ -46,7 +60,10 @@ files:
46
60
  - app/models/unidom/price/concerns/as_priced.rb
47
61
  - app/models/unidom/price/concerns/as_pricer.rb
48
62
  - app/models/unidom/price/price.rb
63
+ - app/types/unidom/price/calculation.rb
49
64
  - app/views/layouts/unidom/price/application.html.erb
65
+ - config/enum.yml
66
+ - config/locales/enum.zh-CN.yml
50
67
  - config/routes.rb
51
68
  - db/migrate/20020301000000_create_unidom_prices.rb
52
69
  - lib/tasks/price_tasks.rake