comee_core 0.3.22 → 0.3.23
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/models/comee/core/sales_order_item.rb +25 -2
- data/app/serializers/comee/core/sales_order_item_serializer.rb +1 -1
- data/db/migrate/20240706160902_add_change_fields_to_sales_order_item.rb +6 -0
- data/lib/comee/core/version.rb +1 -1
- data/spec/factories/comee/core/sales_order_items.rb +5 -3
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1555e4a26a902509533422b46943bf5a6532fe9204c22f8b9f9e8e9576ba9414
|
4
|
+
data.tar.gz: d89f51d3c5385c1a709446455e542575dcc0466963f6ec51342d4a21af9549e0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 81928ddaec6a3bb0a3b44ec4f1243d9ec9dec84272764ba2c5ef0c0c52aa82b9b1bd26583370a4a7bf7503c103bdb66bfb5aee1d89f99680a93e181d45c86904
|
7
|
+
data.tar.gz: 0d0ba19b1ee9825b8756e5e2a2d9157b6410600f8a68a176dcdcb15c179f54a205527d3f9e5896a0721a110d789b9fc05bc8634d3773b7a711e18e258de428c8
|
@@ -3,8 +3,7 @@ module Comee
|
|
3
3
|
class SalesOrderItem < ApplicationRecord
|
4
4
|
default_scope { order(serial_no: :asc) }
|
5
5
|
|
6
|
-
before_save :calculate_total_price
|
7
|
-
before_save :calculate_handover_date
|
6
|
+
before_save :calculate_total_price, :calculate_handover_date, :calculate_price_change, :calculate_quantity_change
|
8
7
|
after_save :update_sales_order
|
9
8
|
after_save :update_sales_order_purchase_status, if: proc { |item| item.fully_processed? }
|
10
9
|
after_destroy :update_sales_order
|
@@ -42,6 +41,30 @@ module Comee
|
|
42
41
|
sales_order.save!
|
43
42
|
end
|
44
43
|
|
44
|
+
def calculate_price_change
|
45
|
+
return if customer_order_item.unit_id == unit_id && customer_order_item.price == price
|
46
|
+
|
47
|
+
if customer_order_item.unit_id == unit_id
|
48
|
+
self.price_diff = price - customer_order_item.price
|
49
|
+
else
|
50
|
+
service = CustomerOrderService.new
|
51
|
+
co_price = service.convert_price(customer_order_item.price, customer_order_item.unit_id, unit_id)
|
52
|
+
self.price_diff = price - co_price
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def calculate_quantity_change
|
57
|
+
return if customer_order_item.unit_id == unit_id && customer_order_item.quantity == quantity
|
58
|
+
|
59
|
+
if customer_order_item.unit_id == unit_id
|
60
|
+
self.quantity_diff = quantity - customer_order_item.quantity
|
61
|
+
else
|
62
|
+
service = CustomerOrderService.new
|
63
|
+
co_quantity = service.convert_quantity(customer_order_item.quantity, customer_order_item.unit_id, unit_id)
|
64
|
+
self.quantity_diff = quantity - co_quantity
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
45
68
|
def quantity_remaining
|
46
69
|
quantity - (quantity_delivered + quantity_canceled)
|
47
70
|
end
|
@@ -3,7 +3,7 @@ module Comee
|
|
3
3
|
class SalesOrderItemSerializer < ActiveModel::Serializer
|
4
4
|
attributes :id, :serial_no, :customer_item_no, :customer_item_description, :quantity, :quantity_delivered, :quantity_canceled,
|
5
5
|
:price, :handover_date, :delivery_date, :eb_number, :lead_time, :comment, :action_note, :purchase_order_item_id,
|
6
|
-
:total_price, :canceled, :processing_status, :additional_details, :created_at
|
6
|
+
:price_diff, :quantity_diff, :total_price, :canceled, :processing_status, :additional_details, :created_at
|
7
7
|
belongs_to :sales_order
|
8
8
|
belongs_to :customer_order_item
|
9
9
|
belongs_to :source
|
@@ -0,0 +1,6 @@
|
|
1
|
+
class AddChangeFieldsToSalesOrderItem < ActiveRecord::Migration[7.1]
|
2
|
+
def change
|
3
|
+
add_column :comee_core_sales_order_items, :price_diff, :float, null: true, default: 0
|
4
|
+
add_column :comee_core_sales_order_items, :quantity_diff, :float, null: true, default: 0
|
5
|
+
end
|
6
|
+
end
|
data/lib/comee/core/version.rb
CHANGED
@@ -5,14 +5,16 @@ FactoryBot.define do
|
|
5
5
|
association :customer_order_item, :with_inventory
|
6
6
|
source factory: :fulfillment_center
|
7
7
|
product
|
8
|
-
unit
|
8
|
+
unit { customer_order_item.unit }
|
9
9
|
purchase_order_item { nil }
|
10
10
|
customer_item_no { Faker::Alphanumeric.alpha(number: 10) }
|
11
11
|
customer_item_description { Faker::Lorem.sentence }
|
12
|
-
quantity {
|
12
|
+
quantity { customer_order_item.quantity }
|
13
|
+
quantity_diff { 0 }
|
13
14
|
quantity_delivered { 0 }
|
14
15
|
quantity_canceled { 0 }
|
15
|
-
price {
|
16
|
+
price { customer_order_item.price }
|
17
|
+
price_diff { 0 }
|
16
18
|
total_price { quantity * price }
|
17
19
|
delivery_date { Date.current.advance(months: 1) }
|
18
20
|
handover_date { Date.current }
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: comee_core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.23
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Henock L.
|
@@ -535,6 +535,7 @@ files:
|
|
535
535
|
- db/migrate/20240702151519_add_vat_to_purchase_order.rb
|
536
536
|
- db/migrate/20240702181613_add_vat_to_invoice.rb
|
537
537
|
- db/migrate/20240703204755_add_currency_to_master_price.rb
|
538
|
+
- db/migrate/20240706160902_add_change_fields_to_sales_order_item.rb
|
538
539
|
- lib/comee/core.rb
|
539
540
|
- lib/comee/core/engine.rb
|
540
541
|
- lib/comee/core/version.rb
|