comee_core 0.2.1 → 0.2.3

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: 2d7cf157e4f4751fc575616de0c6828c89b2fff51cf7dcd28347feb7f668ad6b
4
- data.tar.gz: 1dac2167d8e7419c2312ec89cf8e8276f56ed1ca6ef0ac6a71e24ec432cec1bf
3
+ metadata.gz: c3e3cec335fce496f7b2a857329c5c098631310a7bcfa3d2e21a62fc38041c56
4
+ data.tar.gz: 3dc1d1f162ea1179e5f51f5ab0213a264a336b9400f7af90b7b1fa998f638340
5
5
  SHA512:
6
- metadata.gz: 88c434b7eb17e6dba7c24911369d03128f0eaeed66409a5e6c1bce86b1648948ce07d6e4472c12c2bc3ada0aad59c79c8a9644921cb977c873c48b8aaab2bbec
7
- data.tar.gz: 6307f0083025d5473b9a7bf14a1f43070bf4590e8a2c890070e203cc64842fc8c692dc721ea248aed3c606321962df6bf372269aabbf4e9bb6a7a8adcdca1367
6
+ metadata.gz: 561f02819a07e98ba47fe8d0b522c54639b201d29fb2ba7720eae53e86e7de480ad06d86c16f49b316157ce5cbcbca15c3620bd121cbf91b253b424910a896b7
7
+ data.tar.gz: fe59c449c4d1120992b3cb2c5d0cde23f3fe84945b58b9e74e766b0ea8bd4ddab6c4ebe78324c9ffc66e9bcdef22e89fd1933d8a055e58fb13b55790fccd766b
@@ -1,27 +1,18 @@
1
1
  module Comee
2
2
  module Core
3
3
  class Invoice < ApplicationRecord
4
- before_save :update_invoice_total
5
4
  belongs_to :sales_order
5
+ belongs_to :pod
6
6
  has_many :invoice_items
7
7
 
8
8
  has_noticed_notifications model_name: "Comee::Core::Notification"
9
9
 
10
10
  enum :status, {draft: 0, approved: 1}
11
- enum :payment_status, {not_settled: 0, settled: 1}
11
+ enum :payment_status, {not_paid: 0, partially_paid: 1, fully_paid: 2, overpaid: 3}
12
12
 
13
13
  validates :invoice_no, presence: true, uniqueness: true
14
14
  validates :date_issued, :payment_term, :status, :payment_status, presence: true
15
- validates :additional_charges, :total_price, numericality: {greater_than_or_equal_to: 0, allow_nil: true}
16
-
17
- delegate(:order_number, to: :sales_order)
18
-
19
- def update_invoice_total
20
- self.additional_charges ||= 0
21
- self.total_price ||= 0
22
- self.total_price -= additional_charges_was if additional_charges_was && additional_charges_changed?
23
- self.total_price += additional_charges
24
- end
15
+ validates :total_price, numericality: {greater_than_or_equal_to: 0, allow_nil: true}
25
16
 
26
17
  def self.ransackable_attributes(_auth_object = nil)
27
18
  %w[
@@ -2,21 +2,13 @@ module Comee
2
2
  module Core
3
3
  class InvoiceItem < ApplicationRecord
4
4
  before_save { self.total_price = unit_price * quantity }
5
- after_save :update_invoice_total
6
5
 
7
- belongs_to :sales_order_item
6
+ belongs_to :shipment_instruction_item
8
7
  belongs_to :invoice
8
+ belongs_to :unit
9
9
 
10
10
  validates :quantity, :unit_price, presence: true, numericality: {greater_than: 0}
11
11
  validates :total_price, numericality: {greater_than_or_equal_to: 0, allow_nil: true}
12
-
13
- delegate(:product_code, to: :sales_order_item)
14
- delegate(:product_name, to: :sales_order_item)
15
-
16
- def update_invoice_total
17
- invoice.total_price = InvoiceItem.where(invoice: invoice).map(&:total_price).sum
18
- invoice.save!
19
- end
20
12
  end
21
13
  end
22
14
  end
@@ -3,6 +3,7 @@ module Comee
3
3
  class Pod < ApplicationRecord
4
4
  enum :status, {draft: 0, confirmed: 1, signed: 2}
5
5
  has_many :shipment_instruction_items
6
+ has_many :invoices
6
7
 
7
8
  validates :reference_no, :status, presence: true
8
9
  end
@@ -6,13 +6,14 @@ class CreateComeeCoreInvoices < ActiveRecord::Migration[7.0]
6
6
  null: false,
7
7
  index: {name: "co_on_cci_indx"},
8
8
  foreign_key: {to_table: :comee_core_sales_orders}
9
- t.date :date_issued, null: false
10
- t.string :ship_name
11
- t.date :delivery_date
12
- t.string :voyage_no
13
- t.float :additional_charges
9
+ t.references :pod,
10
+ null: false,
11
+ index: {name: "pod_on_cci_indx"},
12
+ foreign_key: {to_table: :comee_core_pods}
13
+ t.date :date_issued
14
+ t.date :due_date
14
15
  t.float :total_price
15
- t.string :payment_term, null: false
16
+ t.string :payment_term
16
17
  t.integer :notifications_sent
17
18
  t.integer :status, null: false, default: 0
18
19
  t.integer :payment_status, null: false, default: 0
@@ -1,13 +1,17 @@
1
1
  class CreateComeeCoreInvoiceItems < ActiveRecord::Migration[7.0]
2
2
  def change
3
3
  create_table :comee_core_invoice_items do |t|
4
- t.references :sales_order_item,
4
+ t.references :shipment_instruction_item,
5
5
  null: false,
6
- index: {name: "soi_on_ccii_indx"},
7
- foreign_key: {to_table: :comee_core_sales_order_items}
6
+ index: {name: "sii_on_ccii_indx"},
7
+ foreign_key: {to_table: :comee_core_shipment_instruction_items}
8
+ t.references :unit,
9
+ null: false,
10
+ index: {name: "unit_on_ccii_indx"},
11
+ foreign_key: {to_table: :comee_core_units}
8
12
  t.float :quantity, null: false
9
13
  t.float :unit_price, null: false
10
- t.float :total_price, null: false
14
+ t.float :total_price
11
15
  t.references :invoice,
12
16
  null: false,
13
17
  index: {name: "invoice_on_ccii_indx"},
@@ -1,5 +1,5 @@
1
1
  module Comee
2
2
  module Core
3
- VERSION = "0.2.1".freeze
3
+ VERSION = "0.2.3".freeze
4
4
  end
5
5
  end
@@ -1,9 +1,10 @@
1
1
  FactoryBot.define do
2
2
  factory :invoice_item, class: "Comee::Core::InvoiceItem" do
3
- sales_order_item
3
+ shipment_instruction_item
4
+ unit
4
5
  quantity { 10 }
5
6
  unit_price { 5 }
6
- total_price { 50 }
7
+ total_price { quantity * unit_price }
7
8
  invoice
8
9
  end
9
10
  end
@@ -2,15 +2,13 @@ FactoryBot.define do
2
2
  factory :invoice, class: "Comee::Core::Invoice" do
3
3
  invoice_no { Faker::Alphanumeric.alpha(number: 8) }
4
4
  sales_order
5
+ pod
5
6
  date_issued { Date.current }
6
- ship_name { Faker::Name.name }
7
- delivery_date { Date.current.advance(days: -7) }
8
- voyage_no { Faker::Alphanumeric.alpha(number: 10) }
9
- additional_charges { 0 }
7
+ due_date { Date.current.advance(days: 10) }
10
8
  total_price { 0 }
11
9
  payment_term { Faker::Lorem.sentence }
12
10
  notifications_sent { 0 }
13
11
  status { Comee::Core::Invoice.statuses[:draft] }
14
- payment_status { 0 }
12
+ payment_status { Comee::Core::Invoice.payment_statuses[:not_paid] }
15
13
  end
16
14
  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.1
4
+ version: 0.2.3
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-01-22 00:00:00.000000000 Z
11
+ date: 2024-01-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: active_model_serializers
@@ -405,8 +405,6 @@ files:
405
405
  - db/migrate/20230813041307_create_comee_core_product_lookups.rb
406
406
  - db/migrate/20230813235946_create_comee_core_master_prices.rb
407
407
  - db/migrate/20230814151601_create_comee_core_client_prices.rb
408
- - db/migrate/20230915205522_create_comee_core_invoices.rb
409
- - db/migrate/20230915205648_create_comee_core_invoice_items.rb
410
408
  - db/migrate/20230929115336_create_comee_core_order_sources.rb
411
409
  - db/migrate/20230929130910_create_comee_core_client_orders.rb
412
410
  - db/migrate/20231003073316_create_comee_core_inventories.rb
@@ -422,9 +420,11 @@ files:
422
420
  - db/migrate/20231206082503_create_comee_core_unit_conversions.rb
423
421
  - db/migrate/20231207153420_create_comee_core_shipment_items.rb
424
422
  - db/migrate/20231207235542_create_comee_core_item_statuses.rb
425
- - db/migrate/20240103074619_create_comee_core_pods.rb
423
+ - db/migrate/20240104074619_create_comee_core_pods.rb
426
424
  - db/migrate/20240104131607_create_comee_core_shipment_instructions.rb
427
425
  - db/migrate/20240104143246_create_comee_core_shipment_instruction_items.rb
426
+ - db/migrate/20240105205522_create_comee_core_invoices.rb
427
+ - db/migrate/20240105205648_create_comee_core_invoice_items.rb
428
428
  - db/migrate/20240109185749_create_comee_core_transport_availability.rb
429
429
  - db/migrate/20240109185931_create_comee_core_time_slots.rb
430
430
  - db/migrate/20240111112140_create_comee_core_pickup_schedules.rb