Class: Cats::Core::ReceiptTransaction
Constant Summary
Constants inherited
from Transaction
Transaction::COMMITTED, Transaction::DRAFT, Transaction::STATUSES
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Transaction
#set_status
Class Method Details
.ransackable_associations(_auth_object = nil) ⇒ Object
62
63
64
65
66
67
|
# File 'app/models/cats/core/receipt_transaction.rb', line 62
def self.ransackable_associations(_auth_object = nil)
%w[
receipt_authorization
destination
]
end
|
.ransackable_attributes(_auth_object = nil) ⇒ Object
50
51
52
53
54
55
56
57
58
59
60
|
# File 'app/models/cats/core/receipt_transaction.rb', line 50
def self.ransackable_attributes(_auth_object = nil)
%w[
destination_id
quantity
receipt_authorization_id
receipt_number
status
transaction_date
unit_id
]
end
|
Instance Method Details
#set_unit ⇒ Object
18
19
20
21
22
23
24
|
# File 'app/models/cats/core/receipt_transaction.rb', line 18
def set_unit
return if unit
return unless receipt_authorization
self.unit = receipt_authorization.unit
end
|
#validate_quantity ⇒ Object
33
34
35
36
37
38
|
# File 'app/models/cats/core/receipt_transaction.rb', line 33
def validate_quantity
return unless quantity && destination && receipt_authorization
transactions = ReceiptTransaction.where(receipt_authorization: receipt_authorization)
ValidationUtil.validate_quantity(self, "receipt_authorization", transactions, "authorized")
end
|
#validate_receipt ⇒ Object
26
27
28
29
30
31
|
# File 'app/models/cats/core/receipt_transaction.rb', line 26
def validate_receipt
return unless receipt_authorization
status = receipt_authorization.status
errors.add(:receipt_authorization, "must be confirmed.") if status == ReceiptAuthorization::AUTHORIZED
end
|