fix: use costco-go NetDiscounts utility, bump dep to v0.3.9#23
Merged
Conversation
…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 Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ 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
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes
Replaces the manual discount-netting logic in the Costco provider with the new
costco-go v0.3.9NetDiscountsutility.Problem
The previous
provider.goreimplemented discount matching locally and was still emitting:on warehouse receipt
21134301000462605131128. The coupon referenced/AAA BATTERYbut the parent item was namedAA/AAA BATTERY— a partial-description mismatch not handled by the existing exact-match fallback.Solution
costco-go v0.3.9shipsNetDiscounts([]ReceiptItem) ([]ReceiptItem, []ReceiptItem)which handles this with a three-level matching strategy (item-number → exact-desc → substring/contains). This PR:costco-gofromv0.3.6→v0.3.9provider.gowith 2 linesstringsimportChecklist
go test ./... -race)go mod tidy)