comee_core 0.2.1 → 0.2.2

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: dee86ba54d03d24746b9bee9206b141b1fe630e4f25197073e6da4b400a4bbca
4
+ data.tar.gz: 8626a1eebf4ee8ad7f236e5832598f5a41ee3cc3a5c9d0238d307f3a219062fb
5
5
  SHA512:
6
- metadata.gz: 88c434b7eb17e6dba7c24911369d03128f0eaeed66409a5e6c1bce86b1648948ce07d6e4472c12c2bc3ada0aad59c79c8a9644921cb977c873c48b8aaab2bbec
7
- data.tar.gz: 6307f0083025d5473b9a7bf14a1f43070bf4590e8a2c890070e203cc64842fc8c692dc721ea248aed3c606321962df6bf372269aabbf4e9bb6a7a8adcdca1367
6
+ metadata.gz: 6a140b4c3860bc2c115297768421772b749a9ca23560027b2f2e3d7bee0a63c60397badc4b4aea3d12ab85edb7161289c9c4cb2387cea8f9da1efd5616671a03
7
+ data.tar.gz: c9b452eaedcf75e2a42265dfd4eed794f32b7fbce5febacf51014716ca2c13aae0509bc7f698760d3ab47268def7fc928255bdc33b3e11e9fc7981d73cf09518
@@ -1,27 +1,17 @@
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
6
5
  has_many :invoice_items
7
6
 
8
7
  has_noticed_notifications model_name: "Comee::Core::Notification"
9
8
 
10
9
  enum :status, {draft: 0, approved: 1}
11
- enum :payment_status, {not_settled: 0, settled: 1}
10
+ enum :payment_status, {not_paid: 0, partially_paid: 1, fully_paid: 2, overpaid: 3}
12
11
 
13
12
  validates :invoice_no, presence: true, uniqueness: true
14
13
  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
14
+ validates :total_price, numericality: {greater_than_or_equal_to: 0, allow_nil: true}
25
15
 
26
16
  def self.ransackable_attributes(_auth_object = nil)
27
17
  %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
@@ -6,13 +6,10 @@ 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.date :date_issued
10
+ t.date :due_date
14
11
  t.float :total_price
15
- t.string :payment_term, null: false
12
+ t.string :payment_term
16
13
  t.integer :notifications_sent
17
14
  t.integer :status, null: false, default: 0
18
15
  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.2".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
@@ -3,14 +3,11 @@ FactoryBot.define do
3
3
  invoice_no { Faker::Alphanumeric.alpha(number: 8) }
4
4
  sales_order
5
5
  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 }
6
+ due_date { Date.current.advance(days: 10) }
10
7
  total_price { 0 }
11
8
  payment_term { Faker::Lorem.sentence }
12
9
  notifications_sent { 0 }
13
10
  status { Comee::Core::Invoice.statuses[:draft] }
14
- payment_status { 0 }
11
+ payment_status { Comee::Core::Invoice.payment_statuses[:not_paid] }
15
12
  end
16
13
  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.2
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