Inheritance of measures by declarable records from parent

Hello
Question for @matt_bitzesty please.
I’m informed that the source data XML uses an inheritance structure. For example, declarable commodity 03 06 11 10 10 lacks its own data, and it is assumed it inherits this data form its non-declarable parent 03 06 11 10.

However, when I query the JSON service, it looks like you have done the heavy lifting already, and show the inherited measures against the child:
https://www.trade-tariff.service.gov.uk/api/v2/commodities/0306111010

While the parent is not found at either
https://www.trade-tariff.service.gov.uk/api/v2/commodities/03061110
or
https://www.trade-tariff.service.gov.uk/api/v2/commodities/0306111000

Could you confirm that you’ve applied the inheritance as we suspect? If so, could you point to the file on github from which we can understand your logic?

Many thanks

Hi @Daniel.Clarke.WiseTech

Yes we display the inherited measures on the child commodity codes.

It’s not very pretty logic, basically traversing back up the tree to find all the com codes then finding all the measures for these codes, then deduplicating them.

The parent code would not be a commodity code but a heading or a subheading (which doesn’t have its own page, it’s displayed on the heading page) so the URL structure would change to https://www.trade-tariff.service.gov.uk/api/v2/headings/0306

We don’t display the subheadings as a page because you cannot declare against them.

This is only needed if you are importing the HMRC CDS bulk dataset, in terms of the code here is where we do that: https://github.com/bitzesty/trade-tariff-backend/blob/master/app/models/concerns/declarable.rb#L6
and then the uptree for a commodity is here: https://github.com/bitzesty/trade-tariff-backend/blob/a5301568b565ab7cc64acba9e7f7c7efeea6a49e/app/models/commodity.rb#L91

1 Like