Skip to content

[CT-16] Implement Cancellation Policy Enforcer for Flexible/Moderate/Strict policies in Rust #1033

@devwums

Description

@devwums

Problem

Cancellation policy enforcement is inconsistently applied across booking types. Different refund amounts are computed in different places with no single codified source of truth.

Proposed Solution

Create contracts/cntr/cancellation_policy.rs defining #[derive(Debug, PartialEq, Clone)] pub enum CancellationPolicy { Flexible, Moderate, Strict } and implementing pub fn apply_policy(policy: CancellationPolicy, hours_before_start: u64, amount_stroops: i128) -> i128. Rules — Flexible: always 100% refund. Moderate: 100% if 48h+, 50% if 24–47h, 0% if <24h. Strict: 100% if 96h+, 0% otherwise. Integer arithmetic only. All implementation must live inside contracts/cntr/.

Acceptance Criteria

  • File at contracts/cntr/cancellation_policy.rs
  • All 3 policies implemented correctly
  • CancellationPolicy derives Debug, PartialEq, Clone
  • Flexible always returns amount_stroops
  • At least 9 unit tests (3 per policy, one per refund rule per policy)
  • No floating-point arithmetic
  • Compiles with cargo test

Metadata

Metadata

Assignees

Labels

Stellar WaveIssues in the Stellar wave program

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions