comee_core 0.2.29 → 0.2.31

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
  SHA256:
3
- metadata.gz: 72047b0c2028bfecffd282e07eb296dafee045265adee6f6a91ad16fa6421b2c
4
- data.tar.gz: 53092cc94dc081712712e302fe5b0c6c012b70e1f9f012f055366b91aff0a204
3
+ metadata.gz: 5b88368021252fc6b94d5d6249d242ba646fcdb299a16d3fa55bdcc11fe1129b
4
+ data.tar.gz: 05fe8866c539c134e0a563cefd2c8425e2d4c005117272fc87338b47597501c2
5
5
  SHA512:
6
- metadata.gz: 6e051f08525c5d799c2827717d15d7c4cd4d89bd59b04174519b31bd1e92e35c7a401d9cf4f40c269c1c0e062700a02293554f1334e7871ae0105039cb4f6c61
7
- data.tar.gz: d1b69af97b0d2cde39015378ffc809422a05a068540d1048c8fe452e89918147b5af627e3e546f22cdf21d83e6cbea7db546cc0c462fe128a3acb79d84c4461f
6
+ metadata.gz: 662612111fcf879502c8fe0f941d8e2f40c696a89bf78cbd5bb045a494a030266e550da48731514879f798e807e2e80fda110ec358e27bf61b5011fe14ed8d3e
7
+ data.tar.gz: 436fc32e865bc87804a5379df097c5b862cf0695e48ed236e5b53a5ed694eaf7684d96644bd8a8372af3eac975fa49aae5d547b3975e117a4fe088dd49f87a79
@@ -10,7 +10,7 @@ module Comee
10
10
 
11
11
  mappings = field_mapping.map(&:with_indifferent_access)
12
12
  order_fields = %w[order_number order_date delivery_address invoice_address]
13
- item_fields = %w[product_code product_name unit_code quantity price delivery_date]
13
+ item_fields = %w[customer_item_no customer_item_description unit_code quantity price delivery_date]
14
14
  order_dest = mappings.select { |mapping| mapping[:level] == "order" }.map { |m| m[:destination] }
15
15
  item_dest = mappings.select { |mapping| mapping[:level] == "item" }.map { |m| m[:destination] }
16
16
  order_diff = order_fields - order_dest
@@ -0,0 +1,19 @@
1
+ module Comee
2
+ module Core
3
+ class PurchaseRequisition < ApplicationRecord
4
+ # before_save :calculate_total_price
5
+
6
+ has_many :purchase_requisition_items
7
+
8
+ enum :status, {draft: 0, approved: 1}
9
+
10
+ validates :requisition_no, presence: true, uniqueness: true
11
+ validates :requisition_date, :status, presence: true
12
+
13
+ def calculate_total_price
14
+ items = PurchaseRequisitionItem.where(purchase_requisition_id: id)
15
+ self.total_price = items.sum(&:total_price)
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,24 @@
1
+ module Comee
2
+ module Core
3
+ class PurchaseRequisitionItem < ApplicationRecord
4
+ before_save :calculate_total_price
5
+ after_save :calculate_requisition_price
6
+
7
+ belongs_to :product
8
+ belongs_to :unit
9
+ belongs_to :supplier
10
+ belongs_to :purchase_requisition
11
+
12
+ validates :quantity, :price, presence: true, numericality: {greater_than_or_equal_to: 0}
13
+
14
+ def calculate_total_price
15
+ self.total_price = price * quantity
16
+ end
17
+
18
+ def calculate_requisition_price
19
+ purchase_requisition.total_price = purchase_requisition.calculate_total_price
20
+ purchase_requisition.save!
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,14 @@
1
+ class CreateComeeCorePurchaseRequisitions < ActiveRecord::Migration[7.1]
2
+ def change
3
+ create_table :comee_core_purchase_requisitions do |t|
4
+ t.string :requisition_no, null: false
5
+ t.date :requisition_date, null: false
6
+ t.string :remark
7
+ t.integer :status, null: false, default: 0
8
+ t.float :total_price, null: false, default: 0
9
+
10
+ t.timestamps
11
+ end
12
+ add_index :comee_core_purchase_requisitions, :requisition_no, unique: true
13
+ end
14
+ end
@@ -0,0 +1,27 @@
1
+ class CreateComeeCorePurchaseRequisitionItems < ActiveRecord::Migration[7.1]
2
+ def change
3
+ create_table :comee_core_purchase_requisition_items do |t|
4
+ t.references :product,
5
+ null: false,
6
+ index: {name: "product_on_ccpri_indx"},
7
+ foreign_key: {to_table: :comee_core_products}
8
+ t.references :unit,
9
+ null: false,
10
+ index: {name: "unit_on_ccpri_indx"},
11
+ foreign_key: {to_table: :comee_core_units}
12
+ t.references :supplier,
13
+ null: false,
14
+ index: {name: "supplier_on_ccpri_indx"},
15
+ foreign_key: {to_table: :comee_core_suppliers}
16
+ t.references :purchase_requisition,
17
+ null: false,
18
+ index: {name: "pr_on_ccpri_indx"},
19
+ foreign_key: {to_table: :comee_core_purchase_requisitions}
20
+ t.float :quantity, null: false
21
+ t.float :price, null: false
22
+ t.float :total_price, null: false
23
+
24
+ t.timestamps
25
+ end
26
+ end
27
+ end
@@ -1,5 +1,5 @@
1
1
  module Comee
2
2
  module Core
3
- VERSION = "0.2.29".freeze
3
+ VERSION = "0.2.31".freeze
4
4
  end
5
5
  end
@@ -8,8 +8,8 @@ FactoryBot.define do
8
8
  {source: "order_date", destination: "order_date", level: :order},
9
9
  {source: "delivery_address", destination: "delivery_address", level: :order},
10
10
  {source: "invoice_address", destination: "invoice_address", level: :order},
11
- {source: "product_code", destination: "product_code", level: :item},
12
- {source: "product_name", destination: "product_name", level: :item},
11
+ {source: "product_code", destination: "customer_item_no", level: :item},
12
+ {source: "product_name", destination: "customer_item_description", level: :item},
13
13
  {source: "unit_code", destination: "unit_code", level: :item},
14
14
  {source: "quantity", destination: "quantity", level: :item},
15
15
  {source: "price", destination: "price", level: :item},
@@ -0,0 +1,10 @@
1
+ FactoryBot.define do
2
+ factory :purchase_requisition_item, class: "Comee::Core::PurchaseRequisitionItem" do
3
+ product
4
+ unit
5
+ supplier
6
+ purchase_requisition
7
+ quantity { 10 }
8
+ price { 15 }
9
+ end
10
+ end
@@ -0,0 +1,8 @@
1
+ FactoryBot.define do
2
+ factory :purchase_requisition, class: "Comee::Core::PurchaseRequisition" do
3
+ requisition_no { Faker::Alphanumeric.alpha(number: 10) }
4
+ requisition_date { Date.current }
5
+ remark { Faker::Lorem.sentence }
6
+ status { Comee::Core::PurchaseRequisition.statuses[:draft] }
7
+ end
8
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: comee_core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.29
4
+ version: 0.2.31
5
5
  platform: ruby
6
6
  authors:
7
7
  - Henock L.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-03-06 00:00:00.000000000 Z
11
+ date: 2024-03-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: active_model_serializers
@@ -334,6 +334,8 @@ files:
334
334
  - app/models/comee/core/product_lookup.rb
335
335
  - app/models/comee/core/purchase_order.rb
336
336
  - app/models/comee/core/purchase_order_item.rb
337
+ - app/models/comee/core/purchase_requisition.rb
338
+ - app/models/comee/core/purchase_requisition_item.rb
337
339
  - app/models/comee/core/quotation_request.rb
338
340
  - app/models/comee/core/quotation_request_item.rb
339
341
  - app/models/comee/core/sales_order.rb
@@ -438,6 +440,8 @@ files:
438
440
  - db/migrate/20240125003634_create_comee_core_payment_deposits.rb
439
441
  - db/migrate/20240125044630_create_comee_core_payments.rb
440
442
  - db/migrate/20240303191625_add_amount_paid_field_to_invoice.rb
443
+ - db/migrate/20240314111117_create_comee_core_purchase_requisitions.rb
444
+ - db/migrate/20240314111307_create_comee_core_purchase_requisition_items.rb
441
445
  - lib/comee/core.rb
442
446
  - lib/comee/core/engine.rb
443
447
  - lib/comee/core/version.rb
@@ -476,6 +480,8 @@ files:
476
480
  - spec/factories/comee/core/products.rb
477
481
  - spec/factories/comee/core/purchase_order_items.rb
478
482
  - spec/factories/comee/core/purchase_orders.rb
483
+ - spec/factories/comee/core/purchase_requisition_items.rb
484
+ - spec/factories/comee/core/purchase_requisitions.rb
479
485
  - spec/factories/comee/core/quotation_request_items.rb
480
486
  - spec/factories/comee/core/quotation_requests.rb
481
487
  - spec/factories/comee/core/sales_order_items.rb
@@ -511,7 +517,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
511
517
  - !ruby/object:Gem::Version
512
518
  version: '0'
513
519
  requirements: []
514
- rubygems_version: 3.5.3
520
+ rubygems_version: 3.5.6
515
521
  signing_key:
516
522
  specification_version: 4
517
523
  summary: An engine for the COMee ERP.