Permalink
Browse files

Date assignment clarification.

  • Loading branch information...
1 parent 9d42600 commit 0133a7d11c9bc7d3a8f4932ede023d112e941a94 @saulius saulius committed Dec 11, 2012
Showing with 12 additions and 1 deletion.
  1. +5 −0 app/models/measure.rb
  2. +7 −1 lib/chief_transformer/operations/mfcm_delete.rb
View
@@ -292,6 +292,7 @@ class Measure < Sequel::Model
delegate :related_to_measure_type?, :meursing?, :non_meursing?, :export_refund?, :export_refund_agricultural?, to: :adco_type, prefix: :adco_type, allow_nil: true
delegate :quota_order_number_origin_present?, :blank?, to: :quota_order_number, prefix: true, allow_nil: true
delegate :base_regulation_not_completely_abrogated?, to: :modification_regulation, prefix: true, allow_nil: true
+ delegate :validity_end_date, to: :goods_nomenclature, prefix: true, allow_nil: true
def regulation_is_not_replaced?
RegulationReplacement.where(replaced_regulation_id: measure_generating_regulation_id,
@@ -582,6 +583,10 @@ def suspended?
def suspending_regulation
full_temporary_stop_regulation.presence || measure_partial_temporary_stop
end
+
+ def associated_to_non_open_ended_gono?
+ goods_nomenclature.present? && goods_nomenclature.validity_end_date.present?
+ end
end
@@ -9,7 +9,13 @@ def process
.valid_to(record.fe_tsmp)
.not_terminated
.each do |measure|
- end_date = (measure.goods_nomenclature.present? && measure.goods_nomenclature.validity_end_date.present? && record.fe_tsmp > measure.goods_nomenclature.validity_end_date) ? measure.goods_nomenclature.validity_end_date : record.fe_tsmp
+ end_date = if (measure.associated_to_non_open_ended_gono? &&
+ record.fe_tsmp > measure.goods_nomenclature_validity_end_date)
+ measure.goods_nomenclature_validity_end_date
+ else
+ record.fe_tsmp
+ end
+
measure.update validity_end_date: end_date
end
end

0 comments on commit 0133a7d

Please sign in to comment.