feat(invoice-escrow): add custom fee schedule per invoice category - #269
Open
richardgittest wants to merge 1 commit into
Open
Conversation
- Add InvoiceCategory enum (Standard, Factoring, Reverse, Government) - Add CategoryFeeSchedule struct with fee_bps field - Add StorageKey::CategoryFee(InvoiceCategory) for per-category storage - Add EscrowData.category and EscrowData.effective_fee_bps fields - Add set_category_fee (admin-only) and get_category_fee_schedule (view) - Resolve effective_fee_bps at create_escrow time: category override > global - record_payment now uses data.effective_fee_bps (immutable after creation) - Add CategoryFeeNotFound = 19 error variant - Fix pre-existing duplicate discriminant bug (InvalidPayer was 15 = Paused) - Extend escrow_created event with category and effective_fee_bps fields - Add category_fee_set event emitted on set_category_fee - Add 19 new unit tests covering all new code paths - Update all existing test call-sites with new category parameter - Merge upstream/dev additions: whitelist, TTL management, escrow_status_changed
|
@richardgittest Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
Contributor
|
@richardgittest |
Contributor
|
Hi @richardgittest! 👋 Thanks for your PR. CI checks are failing (2 failing checks). Please check the test failures and update your branch. |
Contributor
|
Hi @richardgittest, please rebase on dev to resolve conflicts in |
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.
Summary
Implements custom fee schedule per invoice category in
contracts/invoice-escrow.Closes the linked issue.
Changes
types.rsInvoiceCategoryenum:Standard,Factoring,Reverse,GovernmentCategoryFeeSchedule { fee_bps: u32 }structStorageKey::CategoryFee(InvoiceCategory)variantcategory: InvoiceCategoryandeffective_fee_bps: u32fields toEscrowDataerrors.rsInvalidPayerwas= 15, same asPaused) — bumped to16,InvalidDueDateto17CategoryFeeNotFound = 19storage.rsget_category_fee,set_category_fee,remove_category_feehelpers (instance storage)events.rscategory_fee_set(category, old_fee_bps, new_fee_bps)eventescrow_createdsignature withcategory(asu32) andeffective_fee_bpsescrow_status_changedeventlib.rsset_category_fee— admin-only, validatesfee_bps ≤ 10_000, emitscat_fee_setget_category_fee_schedule— view returning schedule orCategoryFeeNotFoundcreate_escrow— accepts newcategory: InvoiceCategoryparam; resolves and stampseffective_fee_bps(category override > global default)record_payment— usesdata.effective_fee_bps(immutable, stamped at creation)fund_escrowandescrow_status_changedcallstest.rscreate_escrowcall-sites updated with newcategoryparamescrow_createddataset_category_fee(success, auth, invalid bps, max/zero, overwrite, event),get_category_fee_schedule(not found, independence), fee resolution (global fallback, override, precedence, all 4 categories),record_paymentwith category fee (immutability after creation, zero-fee), event field verificationWhat was tested
create_escrowcall-sites compile with the newcategoryparameterCloses #76