unidom-shipment 0.1 → 0.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: 24ac5171783e30f48c2c858aeb53c5977c6aa6cf
4
- data.tar.gz: b367e8a32f7723ccc3cc6266ab2bf391ff4d7d15
3
+ metadata.gz: db3f11fd844936751b8ec3bf6ae4d46ccebbe400
4
+ data.tar.gz: dcda5f4ca3a5aa23138a5e7f5d04288246466399
5
5
  SHA512:
6
- metadata.gz: 0d9176a827d2b0dbe1f19289b80012a842200b0cfd06f5e4e22e9933d919f4b003fa1a4755b04c4da29fe813d9c77e729494688befceaba89e151319f91b2e2d
7
- data.tar.gz: 9329363695116d5f69d2a66154d5f33915d5e3d775ac0c1dc67ac30425cb80436be76dbe52c5f7f15d18b5a062c095268ef8e7a606b8859e48db51acc3a56519
6
+ metadata.gz: 996c0d30c181ea7c578dddd67c1931d63b6304d4899cbf8d136ccb7df14808e3f659f6f919c54932d77a6bfd7ef410a8f7b243c0c3815a7f4c19436d2fa04113
7
+ data.tar.gz: 7df87e7d26546a25c87acdc1e72aafd6f068780ccb5b5b60a2e7376de6a0eb9dff1b58c8ed722dc3fbdabc3438031af5d6733d1594c93bb98e5e4ab4697d8da3
data/README.md CHANGED
@@ -38,4 +38,9 @@ The migration versions start with 200210.
38
38
  shipment = Unidom::Shipment::Shipment.valid_at.alive.first
39
39
  shipment_item = Unidom::Shipment::ShipmentItem.valid_at.alive.first
40
40
  shipment_items = shipment.items
41
+ inventory_item = Unidom::Inventory::GroupedInventoryItem.valid_at.alive.first
42
+
43
+ shipment_package = Unidom::Shipment::ShipmentPackage.valid_at.alive.first
44
+ shipment_package_item = shipment_package.items.create! shipment_item: shipment_item, quantity: 10
45
+ shipment_receipt = shipment_package.receipts.create! shipped: shipment_item.shipped, store_item: inventory_item
41
46
  ```
@@ -11,4 +11,6 @@ class Unidom::Shipment::ShipmentItem < Unidom::Shipment::ApplicationRecord
11
11
  belongs_to :shipment, class_name: 'Unidom::Shipment::Shipment'
12
12
  belongs_to :shipped, polymorphic: true
13
13
 
14
+ has_many :package_items, class_name: 'Unidom::Shipment::ShipmentPackageItem'
15
+
14
16
  end
@@ -0,0 +1,14 @@
1
+ # Shipment Package 是装运包裹。
2
+ # #items 是包裹项。
3
+ # #receipts 是收据。
4
+
5
+ class Unidom::Shipment::ShipmentPackage < Unidom::Shipment::ApplicationRecord
6
+
7
+ self.table_name = 'unidom_shipment_packages'
8
+
9
+ include Unidom::Common::Concerns::ModelExtension
10
+
11
+ has_many :items, class_name: 'Unidom::Shipment::ShipmentPackageItem', foreign_key: :package_id
12
+ has_many :receipts, class_name: 'Unidom::Shipment::ShipmentReceipt', foreign_key: :package_id
13
+
14
+ end
@@ -0,0 +1,14 @@
1
+ # Shipment Package Item 是装运包裹内容。
2
+
3
+ class Unidom::Shipment::ShipmentPackageItem < Unidom::Shipment::ApplicationRecord
4
+
5
+ self.table_name = 'unidom_shipment_package_items'
6
+
7
+ include Unidom::Common::Concerns::ModelExtension
8
+
9
+ validates :quantity, presence: true, numericality: { greater_than: 0, less_than: 1_000_000_000 }
10
+
11
+ belongs_to :package, class_name: 'Unidom::Shipment::ShipmentPackage'
12
+ belongs_to :shipment_item, class_name: 'Unidom::Shipment::ShipmentItem'
13
+
14
+ end
@@ -0,0 +1,23 @@
1
+ # Shipment Receipt 是装运收据。
2
+ # #package 是装运包裹。
3
+ # #shipped 是被装运的产品、货物等。
4
+ # #store_item 是对应存储的项。
5
+
6
+ class Unidom::Shipment::ShipmentReceipt < Unidom::Shipment::ApplicationRecord
7
+
8
+ self.table_name = 'unidom_shipment_receipts'
9
+
10
+ include Unidom::Common::Concerns::ModelExtension
11
+
12
+ validates :accepted_quantity, presence: true, numericality: { greater_than_or_equal_to: 0, less_than: 1_000_000_000 }
13
+ validates :rejected_quantity, presence: true, numericality: { greater_than_or_equal_to: 0, less_than: 1_000_000_000 }
14
+
15
+ belongs_to :package, class_name: 'Unidom::Shipment::ShipmentPackage'
16
+ belongs_to :shipped, polymorphic: true
17
+ belongs_to :store_item, polymorphic: true
18
+
19
+ before_validation do
20
+ self.received_at = Time.now if received_at.blank?
21
+ end
22
+
23
+ end
@@ -0,0 +1,22 @@
1
+ class CreateUnidomShipmentPackages < ActiveRecord::Migration
2
+
3
+ def change
4
+
5
+ create_table :unidom_shipment_packages, id: :uuid do |t|
6
+
7
+ t.text :instruction
8
+ t.text :description
9
+
10
+ t.column :state, 'char(1)', null: false, default: 'C'
11
+ t.datetime :opened_at, null: false, default: ::Time.utc(1970)
12
+ t.datetime :closed_at, null: false, default: ::Time.utc(3000)
13
+ t.boolean :defunct, null: false, default: false
14
+ t.jsonb :notation, null: false, default: {}
15
+
16
+ t.timestamps null: false
17
+
18
+ end
19
+
20
+ end
21
+
22
+ end
@@ -0,0 +1,30 @@
1
+ class CreateUnidomShipmentPackageItems < ActiveRecord::Migration
2
+
3
+ def change
4
+
5
+ create_table :unidom_shipment_package_items, id: :uuid do |t|
6
+
7
+ t.references :package, type: :uuid, null: false
8
+ t.references :shipment_item, type: :uuid, null: false
9
+
10
+ t.decimal :quantity, null: false, default: 0.0, precision: 12, scale: 2
11
+
12
+ t.text :instruction
13
+ t.text :description
14
+
15
+ t.column :state, 'char(1)', null: false, default: 'C'
16
+ t.datetime :opened_at, null: false, default: ::Time.utc(1970)
17
+ t.datetime :closed_at, null: false, default: ::Time.utc(3000)
18
+ t.boolean :defunct, null: false, default: false
19
+ t.jsonb :notation, null: false, default: {}
20
+
21
+ t.timestamps null: false
22
+
23
+ end
24
+
25
+ add_index :unidom_shipment_package_items, :package_id
26
+ add_index :unidom_shipment_package_items, :shipment_item_id
27
+
28
+ end
29
+
30
+ end
@@ -0,0 +1,38 @@
1
+ class CreateUnidomShipmentReceipts < ActiveRecord::Migration
2
+
3
+ def change
4
+
5
+ create_table :unidom_shipment_receipts, id: :uuid do |t|
6
+
7
+ t.references :package, type: :uuid, null: false
8
+ t.references :shipped, type: :uuid, null: false,
9
+ polymorphic: { null: false, default: '', limit: 200 }
10
+ t.references :store_item, type: :uuid, null: false,
11
+ polymorphic: { null: false, default: '', limit: 200 }
12
+
13
+ t.decimal :accepted_quantity, null: false, default: 0.0, precision: 12, scale: 2
14
+ t.decimal :rejected_quantity, null: false, default: 0.0, precision: 12, scale: 2
15
+
16
+ t.datetime :received_at, null: false, default: nil
17
+
18
+ t.text :rejection_reason
19
+ t.text :instruction
20
+ t.text :description
21
+
22
+ t.column :state, 'char(1)', null: false, default: 'C'
23
+ t.datetime :opened_at, null: false, default: ::Time.utc(1970)
24
+ t.datetime :closed_at, null: false, default: ::Time.utc(3000)
25
+ t.boolean :defunct, null: false, default: false
26
+ t.jsonb :notation, null: false, default: {}
27
+
28
+ t.timestamps null: false
29
+
30
+ end
31
+
32
+ add_index :unidom_shipment_receipts, :package_id
33
+ add_index :unidom_shipment_receipts, :shipped_id
34
+ add_index :unidom_shipment_receipts, :store_item_id
35
+
36
+ end
37
+
38
+ end
@@ -1,5 +1,5 @@
1
1
  module Unidom
2
2
  module Shipment
3
- VERSION = '0.1'.freeze
3
+ VERSION = '0.2'.freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: unidom-shipment
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.1'
4
+ version: '0.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: 2016-09-17 00:00:00.000000000 Z
11
+ date: 2016-09-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: unidom-common
@@ -46,10 +46,16 @@ files:
46
46
  - app/models/unidom/shipment/application_record.rb
47
47
  - app/models/unidom/shipment/shipment.rb
48
48
  - app/models/unidom/shipment/shipment_item.rb
49
+ - app/models/unidom/shipment/shipment_package.rb
50
+ - app/models/unidom/shipment/shipment_package_item.rb
51
+ - app/models/unidom/shipment/shipment_receipt.rb
49
52
  - app/views/layouts/unidom/shipment/application.html.erb
50
53
  - config/routes.rb
51
54
  - db/migrate/20021001000000_create_unidom_shipments.rb
52
55
  - db/migrate/20021002000000_create_unidom_shipment_items.rb
56
+ - db/migrate/20021011000000_create_unidom_shipment_packages.rb
57
+ - db/migrate/20021012000000_create_unidom_shipment_package_items.rb
58
+ - db/migrate/20021013000000_create_unidom_shipment_receipts.rb
53
59
  - lib/tasks/shipment_tasks.rake
54
60
  - lib/unidom/shipment.rb
55
61
  - lib/unidom/shipment/engine.rb