Skip to content

Price unit inconsistency: LighterPack parser stores cents, app convention is major units #249

Description

@Angak0k

Problem

The LighterPack import parser stores price in cents, while the rest of the app treats price as major currency units. Imported prices end up ×100 too large when displayed and persisted.

Evidence

  • Parser (pkg/packs/lighterpack.go, extractItemPrice): converts $399.5039950 (cents). ExternalPackItem.Price is documented/handled as cents.
  • App convention (frontend inventory creation, js/ui/inventory.ui.js): price: parseInt(value) — stores the entered value as-is (major units, e.g. 299).
  • Display (js/public-pack.js createItemRow, mirrored in the new js/try-lighterpack.js): ${currency}${price.toFixed(2)} — assumes major units. So an imported 39950 renders as EUR39950.00 instead of €399.50.

Scope (pre-existing, not introduced by the anonymous-import feature)

This affects:

  • The existing authenticated imports: POST /v1/importfromlighterpackurl, POST /v1/importfromlighterpack (CSV), POST /v1/importfrompimpmypackurl — all go through insertExternalPack and persist cents.
  • The new anonymous flow (frontend PR Angak0k/pimpmypack-front#89) and the new POST /v1/importpack — surfaced the issue during QA but inherit the same parser convention.
  • Shared display code in public-pack.js (and replicated in try-lighterpack.js).

Decision needed

Pick the canonical unit for price and align both sides. Likely fix: make the parser emit major units (consistent with inventory creation and the toFixed(2) display), or normalize at the API boundary. Either way, audit extractItemPrice + insertExternalPack + the import display paths together.

Noted as a follow-up; intentionally left out of the current LighterPack-import PRs (#248 backend, Angak0k/pimpmypack-front#89 frontend) per QA decision.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions