Class: Cats::Core::Receipt

Inherits:
ApplicationRecord show all
Defined in:
app/models/cats/core/receipt.rb

Instance Method Summary collapse

Instance Method Details

#set_unitObject



17
18
19
20
21
22
23
# File 'app/models/cats/core/receipt.rb', line 17

def set_unit
  return if unit

  return unless receipt_authorization

  self.unit = receipt_authorization.unit
end

#validate_quantityObject



25
26
27
28
29
30
31
# File 'app/models/cats/core/receipt.rb', line 25

def validate_quantity
  return unless quantity && unit && receipt_authorization

  receipts = Receipt.where(receipt_authorization: receipt_authorization)
  losses = LostCommodity.where(receipt_authorization: receipt_authorization)
  ValidationUtil.validate_quantity(self, "receipt_authorization", receipts + losses, "authorized")
end