-
Notifications
You must be signed in to change notification settings - Fork 2
Attaching national footnotes to measures
Current process:
You should use data migrations, check this one for an example.
Manual, legacy process goes as follows:
-
Add footnote record into db/chief/static_national_data_insert.sql , e.g.:
insert into footnotes /* 200 00 */(footnote_type_id,footnote_id,validity_start_date,validity_end_date,national) values ('XX','YYY',str_to_date('1971-12-31', '%Y-%m-%d'),NULL,1);
-
Add footnote_description_period into same file, e.g.:
insert into footnote_description_periods /* 200 05 */(footnote_description_period_sid,footnote_type_id,footnote_id,validity_start_date,national) values (-101,'XX','YYY',str_to_date('1971-12-31', '%Y-%m-%d'),1); ```
-
Create footnote_description entry (mind footnote_description_period_sid):
insert into footnote_descriptions /* 200 10 */(footnote_description_period_sid,language_id,footnote_type_id,footnote_id,description,national) values (-184,'EN','XX','YYY','Due to CHIEF being unable to process an additional code with two different duty rates, imports should be declared under the same numeric additional codes but replacing the 'A' with an 'X', to obtain exemption from the anti-dumping duty where the conditions under footnote CD387 are met.',1); ```
According to the description we are adding footnote for measures that already have footnote CD387 (noted in the description).
-
Find measure_sid entries which should have new national measure attached:
select measure_sid from footnote_association_measures where footnote_type_id = 'CD' and footnote_id = '387';
or
FootnoteAssociationMeasure.where(footnote_type_id: 'CD', footnote_id: '387').select(:measure_sid).all
-
Create as many footnote_association_measure entries as needed, e.g.:
insert into footnote_association_measures /* 43020 */ (measure_sid, footnote_type_id, footnote_id, national) values (<measure_sid>,'XX','YYY',1);
-
Create a migration that adds (and removes) these entries.