comee_core 0.2.44 → 0.2.46

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: c0a5388d85c1ae2d3c4c16843203f97ae1eb4f43887e6fc9ce7e54d851844077
4
- data.tar.gz: f35b9ca46c598a6929c59c5b8a2fe9cf0eb2f244cd41392a0bf2af7fe752459b
3
+ metadata.gz: 320ff819758bf27f27b9082927bfe52b2a42bb77af6399fee2d67b221bab47a2
4
+ data.tar.gz: 19c9b9896bf83b0f231a9e5ac9b3327dff3545b356f87d13d84108755beecf0d
5
5
  SHA512:
6
- metadata.gz: b699bf44a44dd78cb2ab70795a342aa930b235706950978d5547b5caf1354b51211ec6c774619ad58f748859bd6d9a8a76acb99631d563a66bba973bb401bd1c
7
- data.tar.gz: 7a454118edcdf24e1ff36f538a48c05bc96179ba50ecd55a4dc116b0324a2d7b8b6c4cdd3a102c40291d9009a85814acf821f2a5fa1c7426b71a6cfd04f7c113
6
+ metadata.gz: 4a106d96bbed3e53f31e8a32b7db634ecc45641c749a1b465654084f47f731b02da69166212580a6fbd20cd9fdcb2580d2ebd79788dd5901c5a7e6e652a169ef
7
+ data.tar.gz: a01ddba01a4b2498f50ea1c525585afb3d03f7d9cb0e153ee49d363212a6fed9caf04ba53099f48f90279f88315bf73a656dccbabb85341b1f09ca7bd3ef36ed
@@ -1,9 +1,12 @@
1
1
  module Comee
2
2
  module Core
3
3
  class PurchaseOrder < ApplicationRecord
4
+ before_save :total_price
5
+
4
6
  belongs_to :supplier
5
7
  has_many :purchase_order_items
6
8
 
9
+ validates :po_number, presence: true, uniqueness: true
7
10
  validates :order_date, :delivery_address, :status, :delivery_date, presence: true
8
11
  enum status: {
9
12
  draft: 0,
@@ -12,6 +15,12 @@ module Comee
12
15
  confirmed: 3,
13
16
  canceled: 4
14
17
  }
18
+
19
+ def total_price
20
+ items = PurchaseOrderItem.where(purchase_order_id: id)
21
+ self.total_price = items.sum(&:total_price)
22
+ end
23
+
15
24
  def self.ransackable_attributes(_auth_object = nil)
16
25
  %w[
17
26
  id
@@ -1,6 +1,7 @@
1
1
  class CreateComeeCorePurchaseOrders < ActiveRecord::Migration[7.1]
2
2
  def change
3
3
  create_table :comee_core_purchase_orders do |t|
4
+ t.string :po_number, null: false
4
5
  t.references :supplier,
5
6
  null: false,
6
7
  index: {name: "suppliers_on_ccpo_indx"},
@@ -9,8 +10,10 @@ class CreateComeeCorePurchaseOrders < ActiveRecord::Migration[7.1]
9
10
  t.integer :status, default: 0
10
11
  t.string :delivery_address, null: false
11
12
  t.date :delivery_date, null: false
13
+ t.string :terms
12
14
 
13
15
  t.timestamps
14
16
  end
17
+ add_index :comee_core_purchase_orders, :po_number, unique: true
15
18
  end
16
19
  end
@@ -0,0 +1,5 @@
1
+ class AddTotalPriceToPurchaseOrder < ActiveRecord::Migration[7.1]
2
+ def change
3
+ add_column :comee_core_purchase_orders, :total_price, :float, default: 0
4
+ end
5
+ end
@@ -1,5 +1,5 @@
1
1
  module Comee
2
2
  module Core
3
- VERSION = "0.2.44".freeze
3
+ VERSION = "0.2.46".freeze
4
4
  end
5
5
  end
@@ -1,9 +1,11 @@
1
1
  FactoryBot.define do
2
2
  factory :purchase_order, class: "Comee::Core::PurchaseOrder" do
3
+ po_number { Faker::Alphanumeric.alpha(number: 20) }
3
4
  supplier
4
5
  order_date { Date.current }
5
6
  status { 0 }
6
7
  delivery_address { "Korsu warehouse address" }
7
8
  delivery_date { Date.current.advance(days: 10) }
9
+ terms { Faker::Lorem.sentence }
8
10
  end
9
11
  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.44
4
+ version: 0.2.46
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-26 00:00:00.000000000 Z
11
+ date: 2024-03-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: active_model_serializers
@@ -439,6 +439,7 @@ files:
439
439
  - db/migrate/20240314111117_create_comee_core_purchase_requisitions.rb
440
440
  - db/migrate/20240314111307_create_comee_core_purchase_requisition_items.rb
441
441
  - db/migrate/20240325155406_create_comee_core_purchase_order_item_diffs.rb
442
+ - db/migrate/20240328033103_add_total_price_to_purchase_order.rb
442
443
  - lib/comee/core.rb
443
444
  - lib/comee/core/engine.rb
444
445
  - lib/comee/core/version.rb