Skip to content

feat(invoice): add invoice status counts and get_counts API#40

Merged
K1NGD4VID merged 19 commits into
TrusTrove:mainfrom
Ce-Royals:get_invoice_count_by_status
Jul 3, 2026
Merged

feat(invoice): add invoice status counts and get_counts API#40
K1NGD4VID merged 19 commits into
TrusTrove:mainfrom
Ce-Royals:get_invoice_count_by_status

Conversation

@Ce-Royals

Copy link
Copy Markdown
Contributor

closes #6

Title
Add invoice status counts and get_counts read API

Summary
This change adds persistent invoice status counts to the invoice contract so the frontend can display counts per status without loading all invoices.

What changed
Added DataKey::StatusCount(u32) to types.rs
Added InvoiceStatus::as_str() helper for stable status name keys
Added get_counts(env) -> Map<String, u64> in lib.rs
Persistently incremented Created count when invoices are created
Updated move_status_index() to decrement the previous status count and increment the new status count on every status transition
Added helper functions:
increment_status_count
decrement_status_count
read_status_count
Added unit test test_get_counts_updates_through_lifecycle in test.rs
Acceptance criteria satisfied
get_counts returns a map of status name to count
It is read-only and requires no auth
Counts are stored and updated on transitions
Unit test verifies counts through full lifecycle
Files changed
lib.rs
types.rs
test.rs

@drips-wave

drips-wave Bot commented Jun 23, 2026

Copy link
Copy Markdown

@Ce-Royals 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! 🚀

Learn more about application limits

@K1NGD4VID

Copy link
Copy Markdown
Contributor

Resolve conflict @Ce-Royals

@Ce-Royals Ce-Royals force-pushed the get_invoice_count_by_status branch from c8c5c84 to 7619c5f Compare June 24, 2026 15:34
@K1NGD4VID

Copy link
Copy Markdown
Contributor

Fix Ci Error @Ce-Royals

Ce-Royals and others added 17 commits June 29, 2026 14:55
- String::from_slice -> String::from_str for &str input
- Fix try_invoke_contract arg type (pass tuple, not Val)
- Add missing expiry_window_set event emission
- Add extend_instance_ttl to initialize
- Remove all self:: prefixes from free function calls
- Replace all manual .persistent().set()+extend_ttl() with persistent_set
- Use persistent_set in add_supported_asset, expire_listing,
  extend_status_index, increment/decrement_status_count
…y_status

# Conflicts:
#	contracts/invoice/src/lib.rs
#	contracts/invoice/src/types.rs
@K1NGD4VID K1NGD4VID merged commit 9251afe into TrusTrove:main Jul 3, 2026
1 check failed
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.

feat(invoice): add get_invoice_count_by_status read function

2 participants