Skip to content

fix: use costco-go NetDiscounts utility, bump dep to v0.3.9#23

Merged
eshaffer321 merged 1 commit into
mainfrom
fix/use-costco-go-net-discounts
May 27, 2026
Merged

fix: use costco-go NetDiscounts utility, bump dep to v0.3.9#23
eshaffer321 merged 1 commit into
mainfrom
fix/use-costco-go-net-discounts

Conversation

@eshaffer321
Copy link
Copy Markdown
Owner

Changes

Replaces the manual discount-netting logic in the Costco provider with the new costco-go v0.3.9 NetDiscounts utility.

Problem

The previous provider.go reimplemented discount matching locally and was still emitting:

[WARN] found orphaned discount with no matching parent item discount_item=379938 parent_item_ref=AAA BATTERY discount_amount=-2.5

on warehouse receipt 21134301000462605131128. The coupon referenced /AAA BATTERY but the parent item was named AA/AAA BATTERY — a partial-description mismatch not handled by the existing exact-match fallback.

Solution

costco-go v0.3.9 ships NetDiscounts([]ReceiptItem) ([]ReceiptItem, []ReceiptItem) which handles this with a three-level matching strategy (item-number → exact-desc → substring/contains). This PR:

  • Bumps costco-go from v0.3.6v0.3.9
  • Replaces ~55 lines of manual netting in provider.go with 2 lines
  • Removes the now-unused strings import
  • Adds a regression test for the partial-description case

Checklist

  • Tests passing (go test ./... -race)
  • go.mod / go.sum updated (go mod tidy)
  • Regression test added for the failing receipt

…3.9 (#23)

Replace the manual three-level discount-netting logic in the Costco
provider with the new costco-go NetDiscounts utility (released in
v0.3.9).

The previous code reimplemented matching in provider.go and was still
missing the substring/contains fallback for cases like a coupon
referencing '/AAA BATTERY' when the parent item is 'AA/AAA BATTERY'.
That's now handled in the library itself.

Changes:
- go.mod: costco-go v0.3.6 → v0.3.9
- provider.go: replace ~55 lines of manual netting with 2 lines calling
  costcogo.NetDiscounts; remove unused 'strings' import
- provider_test.go: add partial-description-match regression test

Fixes the WARN 'found orphaned discount' seen on receipt
21134301000462605131128 (AAA battery coupon).
@codecov
Copy link
Copy Markdown

codecov Bot commented May 27, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 56.29%. Comparing base (71053f2) to head (26ceeb8).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main      #23      +/-   ##
==========================================
- Coverage   56.41%   56.29%   -0.12%     
==========================================
  Files          43       43              
  Lines        4807     4794      -13     
==========================================
- Hits         2712     2699      -13     
  Misses       1931     1931              
  Partials      164      164              
Flag Coverage Δ
unittests 56.29% <100.00%> (-0.12%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
internal/adapters/providers/costco/provider.go 39.41% <100.00%> (-4.31%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@eshaffer321 eshaffer321 merged commit 710f851 into main May 27, 2026
14 checks passed
@eshaffer321 eshaffer321 deleted the fix/use-costco-go-net-discounts branch May 27, 2026 02:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant