Fix criteria for transitioning into received state

Since there can be multiple Tx confirmations for the same region, we should not
check if the number of Tx confirmations matches with the number of
regions. Instead, we should check if all regions have at least one Tx
confirmation.
This commit is contained in:
Igor Freire 2020-06-15 14:34:29 -03:00
parent c4bf6f1a90
commit aabdc11e24

View File

@ -92,7 +92,12 @@ class Order < ActiveRecord::Base
end
def received_criteria_met?
(self.tx_confirmations.count == Region.count) &&
self.tx_regions.exists?(Region::REGIONS[:north_america].id) &&
self.tx_regions.exists?(Region::REGIONS[:south_america].id) &&
self.tx_regions.exists?(Region::REGIONS[:africa].id) &&
self.tx_regions.exists?(Region::REGIONS[:europe].id) &&
self.tx_regions.exists?(Region::REGIONS[:asia_c].id) &&
self.tx_regions.exists?(Region::REGIONS[:asia_ku].id) &&
self.rx_regions.exists?(Region::REGIONS[:north_america].id) &&
self.rx_regions.exists?(Region::REGIONS[:south_america].id) &&
self.rx_regions.exists?(Region::REGIONS[:asia_c].id) &&