Sha256: de88c9412aabc201ea9062632b99a0d1d43b8b8377cd21665d348e98e19079fd
Contents?: true
Size: 686 Bytes
Versions: 4
Compression:
Stored size: 686 Bytes
Contents
module Comee module Core class WarehouseShipmentItem < ApplicationRecord after_create :update_inventory_and_sales_order_item belongs_to :warehouse_shipment belongs_to :sales_order_item validates :quantity, presence: true def update_inventory_and_sales_order_item update_inventory(sales_order_item.product_id, quantity) sales_order_item.update_quantity_en_route(quantity) end def update_inventory(product_id, quantity_change) inventory = Inventory.find_by(product_id: product_id) return unless inventory inventory.quantity -= quantity_change inventory.save end end end end
Version data entries
4 entries across 4 versions & 1 rubygems