Skip to content

Implement price/weight normalization behavior #16

@Narnach

Description

@Narnach

Status: rough draft

We've got country-specific price/weight normalization logic implemented in Questionmark's Hoard system for the Netherlands and (IIRC) Belgium. A PR can start by extracting the logic and sharing it.

Design idea:

  • Barcodes must be able to self-identify the country they are intended for. This breaks down into official rules and our own QM-specific rules. Speculative: implement GTIN::Base#country with official rules and possibly see if we can get this merged into upstream barcodevalidation when we have a working implementation.
    • Our custom classes may not be able to deterministically return a country.
  • Implement GTIN::Base#normalize(country: self.country) which we can use to implement normalization rules. Probably use a helper class per country. Return true/false based on whether normalization could happen or not. We can implement a #normalize! version that raises an error when we don't know the country or are unable to normalize.
    • The optional country argument helps to provide external information about the country a barcode "belongs" to.
  • Implement a #normalized? method that can check if it's normalized or not. I'm unsure what's desired behavior for barcodes that we don't know the normalization behavior for. Do we also need to implement #can_normalize? to make this deterministic?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions