Technomics / readflexfile

An R package to read the Flex File data format.
GNU General Public License v3.0
2 stars 1 forks source link

EndItem and OrderOrLot not filling in where where is a sublot #28

Closed ahjames11 closed 3 years ago

ahjames11 commented 3 years ago

For FlexFiles with UnitOrSublots, the EndItem and OrderOrLot names are not joining in. This can be seen in the following code for such files.

readflexfile::read_flexfile(path) %>%
  readflexfile::allocate_flexfile(.) %>%
  readflexfile::flatten_data(.) %>%
  group_by(atd_or_fac, unit_or_sublot_id, end_item_id, end_item_name, order_or_lot_id, order_or_lot_name) %>%
  summarise(value_dollars = sum(value_dollars, na.rm = TRUE))
ahjames11 commented 3 years ago

Problem occurs because EndItem and OrderOrLot ables are joined before the UnitOrSublots table. So there is an NA for ID and the name cannot be joined in.

Reordering the joins in the flatten_data.flexfile() function corrects this.