ledgerweave

    Deterministic multi-source business ledger reconciliation and exception attribution.

    ledger
    reconciliation
    data-quality
    csv
    Download zip
    Version
    0.3.0
    License
    Apache-2.0
    Last updated
    yesterday
    Downloads
    3

    Dependencies

    #LedgerWeave 项目申报书

    基本信息

    • 项目名称:LedgerWeave:多源业务流水对账与异常归因引擎
    • 参赛者:苏楗轶
    • 联系方式:2821775174@qq.com
    • GitHub 仓库链接:https://github.com/sujy123456/project_3
    • 项目方向:MoonBit 数据处理与业务应用基础设施
    • 是否为移植项目:否

    项目简介

    LedgerWeave 是以 MoonBit 实现的多源业务流水对账与异常归因引擎,面向需要核对订单、支付、退款和调整流水的业务系统、数据平台与运营工具。项目以整数最小货币单位处理金额,基于确定性规则识别重复标识、无效金额和币种、未知订单、付款超期、取消订单付款、退款超额、少收、多收和长期未结清等问题,并输出订单余额、异常记录和复核结论。除基础对账外,项目提供输入质量剖析、支付分配计划、复核案例工作流、账龄与账户/币种指标,以及 CSV 和 Markdown 审计导出能力,便于接入 CLI、批处理任务和后续业务系统。

    核心功能范围

    • 提供订单、支付、退款、调整四类强类型流水模型;金额统一使用整数最小单位,避免浮点金额误差;
    • 提供确定性对账入口 reconcile(...),计算订单应收、实收、退款、调整与未结清余额;
    • 校验重复 ID、空引用、非法金额、非法币种、未知订单、币种不一致、付款时效和取消订单付款等输入与业务规则;
    • 识别少收、多收、退款超实收、逾期未结清等异常,并给出严重级别和可追踪归因;
    • 支持 CSV 导入订单、支付、退款和调整流水,提供可直接运行的最小示例和原生 CLI;
    • 提供按异常代码、严重级别、币种、账户和账龄聚合的分析指标;
    • 提供支付分配与匹配计划,覆盖精确付款、部分付款、超额付款、未知订单付款、币种冲突和作废付款;
    • 提供复核案例的优先级、归属、状态流转、处理结论与超期检查;
    • 提供输入质量报告、复核队列、分配计划及 CSV/Markdown 审计导出;
    • 提供 MoonBit 回归测试、CSV 端到端示例及 GitHub Actions 检查、构建、测试流程。

    移植或参考说明

    • 原创/移植情况:项目的领域模型、对账规则、异常归因、支付分配、质量审计、复核工作流和导出实现均为本仓库原创实现,不是对其他项目的移植或简单封装。
    • 参考与依赖:运行时使用公开依赖 moonbitlang/async@0.21.3 支持 CLI 文件读取;其来源与 Apache-2.0 许可证已在仓库 THIRD_PARTY_NOTICES.md 中记录。CI 使用 hustcer/setup-moonbit@v1 安装 MoonBit,亦已记录其 MIT 许可证与用途。
    • 本项目许可证:Apache License 2.0(OSI 认可),许可证全文位于仓库 LICENSE。
    • 兼容性说明:项目未复制第三方业务代码、数据集或素材;示例流水均为合成数据,不含个人、真实财务或生产数据。

    #安装、运行与示例

    环境要求:MoonBit 工具链,moonc >= 0.10.14。本项目以 moonc v0.10.14 验证。

    moon update moon check --target native moon test --target native moon build --target native

    仓库包含可直接执行的 CSV 最小样例:

    moon run --target native cmd/main -- \ examples/csv/orders.csv examples/csv/payments.csv \ examples/csv/refunds.csv examples/csv/adjustments.csv 40

    该示例会输出订单余额和异常报告。样例故意包含未知订单付款与已取消订单付款,因此结果为 REVIEW REQUIRED;这是对异常归因路径的可复现验证,而非命令失败。

    作为库使用时,调用 @ledgerweave.reconcile(input, policy, current_day) 获取 ReconciliationResult,再按需使用指标、分配、质量审计、复核队列与 CSV/Markdown 导出 API。详见 架构说明 与 申报书。

    #测试、CI 与质量边界

    GitHub Actions 在每次 push 与 pull request 上执行格式检查、依赖更新、原生检查、测试、构建、CSV 端到端示例和包元数据检查。项目以提供的输入和显式策略进行确定性对账;不连接银行、不发起资金操作、不提供税务或审计合规结论。

    #开源许可证与第三方信息

    本项目使用 Apache License 2.0,属于 OSI 认可的开源许可证。运行时依赖、CI 依赖及其许可证来源见 THIRD_PARTY_NOTICES.md。

    AccountTotal

    pub(all) struct AccountTotal {
    account_id : String
    order_count : Int
    expected_minor : Int
    captured_minor : Int
    refunded_minor : Int
    outstanding_minor : Int
    } derive(Eq,
    Debug
    )

    AdjustmentDirection

    pub(all) enum AdjustmentDirection {
    Credit
    Debit
    } derive(Eq,
    Debug
    )

    AdjustmentRecord

    pub(all) struct AdjustmentRecord {
    id : String
    order_id : String
    currency : String
    amount_minor : Int
    day : Int
    direction : AdjustmentDirection
    reason : String
    } derive(Eq,
    Debug
    )

    AgeBucket

    pub(all) struct AgeBucket {
    label : String
    order_count : Int
    outstanding_minor : Int
    } derive(Eq,
    Debug
    )

    AllocationPlan

    pub(all) struct AllocationPlan {
    allocations : Array[PaymentAllocation]
    unallocated_minor : Int
    allocated_minor : Int
    ignored_minor : Int
    valid : Bool
    } derive(Eq,
    Debug
    )

    AllocationState

    pub(all) enum AllocationState {
    Applied
    UnmatchedPayment
    OverAllocation
    CurrencyConflict
    IgnoredPayment
    } derive(Eq,
    Debug
    )

    AssignmentRule

    pub(all) struct AssignmentRule {
    code : FindingCode
    owner : String
    } derive(Eq,
    Debug
    )

    CodeCount

    pub(all) struct CodeCount {
    code : FindingCode
    count : Int
    } derive(Eq,
    Debug
    )

    CurrencyTotal

    pub(all) struct CurrencyTotal {
    currency : String
    order_count : Int
    expected_minor : Int
    captured_minor : Int
    refunded_minor : Int
    outstanding_minor : Int
    } derive(Eq,
    Debug
    )

    Finding

    pub(all) struct Finding {
    code : FindingCode
    severity : Severity
    record_kind : RecordKind
    record_id : String
    order_id : String
    message : String
    } derive(Eq,
    Debug
    )

    FindingCode

    pub(all) enum FindingCode {
    DuplicateOrderId
    DuplicatePaymentId
    DuplicateRefundId
    DuplicateAdjustmentId
    InvalidAmount
    InvalidCurrency
    UnknownOrder
    CurrencyMismatch
    PaymentAfterDeadline
    PaymentForCancelledOrder
    RefundExceedsPayment
    Overpaid
    Underpaid
    OpenPastDue
    PaymentVoided
    MissingReference
    } derive(Eq,
    Debug
    )

    FindingMetrics

    pub(all) struct FindingMetrics {
    total : Int
    info : Int
    warning : Int
    error : Int
    blocking : Int
    } derive(Eq,
    Debug
    )

    FindingQuery

    pub(all) struct FindingQuery {
    minimum_severity : Severity
    code : FindingCode?
    order_id : String?
    record_kind : RecordKind?
    } derive(Eq,
    Debug
    )

    InputQualityReport

    pub(all) struct InputQualityReport {
    orders : SourceProfile
    payments : SourceProfile
    refunds : SourceProfile
    adjustments : SourceProfile
    issues : Array[QualityIssue]
    ready : Bool
    } derive(Eq,
    Debug
    )

    LedgerInput

    pub(all) struct LedgerInput {
    orders : Array[OrderRecord]
    payments : Array[PaymentRecord]
    refunds : Array[RefundRecord]
    adjustments : Array[AdjustmentRecord]
    } derive(Eq,
    Debug
    )

    MatchingCandidate

    pub(all) struct MatchingCandidate {
    payment_id : String
    order_id : String
    score : Int
    reason : String
    } derive(Eq,
    Debug
    )

    OrderBalance

    pub(all) struct OrderBalance {
    order_id : String
    expected_minor : Int
    captured_minor : Int
    refunded_minor : Int
    adjustments_minor : Int
    outstanding_minor : Int
    resolution : Resolution
    } derive(Eq,
    Debug
    )

    OrderRecord

    pub(all) struct OrderRecord {
    id : String
    account_id : String
    currency : String
    amount_minor : Int
    created_day : Int
    status : OrderStatus
    } derive(Eq,
    Debug
    )

    OrderStatus

    pub(all) enum OrderStatus {
    Pending
    Paid
    Cancelled
    Refunded
    } derive(Eq,
    Debug
    )

    PaymentAllocation

    pub(all) struct PaymentAllocation {
    payment_id : String
    order_id : String
    currency : String
    allocated_minor : Int
    state : AllocationState
    note : String
    } derive(Eq,
    Debug
    )

    PaymentRecord

    pub(all) struct PaymentRecord {
    id : String
    order_id : String
    currency : String
    amount_minor : Int
    received_day : Int
    status : PaymentStatus
    } derive(Eq,
    Debug
    )

    PaymentStatus

    pub(all) enum PaymentStatus {
    Captured
    Voided
    Failed
    } derive(Eq,
    Debug
    )

    Policy

    pub(all) struct Policy {
    allowed_currencies : Array[String]
    amount_tolerance_minor : Int
    max_payment_lag_days : Int
    max_open_age_days : Int
    permit_cancelled_payment : Bool
    } derive(Eq,
    Debug
    )

    QualityIssue

    pub(all) struct QualityIssue {
    source : SourceKind
    row_number : Int
    record_id : String
    order_id : String
    code : QualityIssueCode
    severity : Severity
    message : String
    } derive(Eq,
    Debug
    )

    QualityIssueCode

    pub(all) enum QualityIssueCode {
    BlankIdentifier
    BlankAccount
    BlankReference
    UnsupportedCurrency
    NonPositiveAmount
    NegativeDay
    DuplicateIdentifier
    OrphanReference
    MissingReason
    InvalidStatusCombination
    FutureDatedRecord
    } derive(Eq,
    Debug
    )

    ReconciliationResult

    pub(all) struct ReconciliationResult {
    balances : Array[OrderBalance]
    findings : Array[Finding]
    valid : Bool
    } derive(Eq,
    Debug
    )

    RecordKind

    pub(all) enum RecordKind {
    Order
    Payment
    Refund
    Adjustment
    } derive(Eq,
    Debug
    )

    LedgerWeave's stable domain vocabulary. Amounts are always integer minor units.

    RefundRecord

    pub(all) struct RefundRecord {
    id : String
    order_id : String
    currency : String
    amount_minor : Int
    refunded_day : Int
    reason : String
    } derive(Eq,
    Debug
    )

    Resolution

    pub(all) enum Resolution {
    Settled
    AwaitingPayment
    OverCollected
    RefundRisk
    NeedsReview
    } derive(Eq,
    Debug
    )

    ResolutionCount

    pub(all) struct ResolutionCount {
    resolution : Resolution
    count : Int
    } derive(Eq,
    Debug
    )

    ResultMetrics

    pub(all) struct ResultMetrics {
    finding_metrics : FindingMetrics
    settled_orders : Int
    awaiting_payment_orders : Int
    over_collected_orders : Int
    refund_risk_orders : Int
    review_orders : Int
    expected_minor : Int
    captured_minor : Int
    refunded_minor : Int
    outstanding_minor : Int
    } derive(Eq,
    Debug
    )

    ReviewCase

    pub(all) struct ReviewCase {
    case_id : String
    finding : Finding
    priority : Int
    state : ReviewState
    owner : String
    opened_day : Int
    updated_day : Int
    decision : ReviewDecision
    resolution_note : String
    } derive(Eq,
    Debug
    )

    ReviewDecision

    pub(all) enum ReviewDecision {
    ConfirmedIssue
    DataCorrection
    BusinessException
    FalsePositive
    NoDecision
    } derive(Eq,
    Debug
    )

    ReviewQueue

    pub(all) struct ReviewQueue {
    cases : Array[ReviewCase]
    next_sequence : Int
    } derive(Eq,
    Debug
    )

    ReviewState

    pub(all) enum ReviewState {
    Open
    Investigating
    Resolved
    Dismissed
    } derive(Eq,
    Debug
    )

    ReviewSummary

    pub(all) struct ReviewSummary {
    open : Int
    investigating : Int
    resolved : Int
    dismissed : Int
    unassigned : Int
    overdue : Int
    } derive(Eq,
    Debug
    )

    Severity

    pub(all) enum Severity {
    Info
    Warning
    Error
    } derive(Eq,
    Debug
    )

    SourceKind

    pub(all) enum SourceKind {
    OrdersSource
    PaymentsSource
    RefundsSource
    AdjustmentsSource
    } derive(Eq,
    Debug
    )

    SourceProfile

    pub(all) struct SourceProfile {
    source : SourceKind
    record_count : Int
    blank_identifier_count : Int
    duplicate_identifier_count : Int
    invalid_amount_count : Int
    blank_reference_count : Int
    orphan_reference_count : Int
    invalid_currency_count : Int
    future_day_count : Int
    } derive(Eq,
    Debug
    )

    abs_int

    fn abs_int(value : Int) -> Int

    age_bucket_label

    fn age_bucket_label(age_days : Int) -> String

    allocate_payments

    fn allocate_payments(input : LedgerInput, result : ReconciliationResult) -> AllocationPlan

    allocated_for_order

    fn allocated_for_order(allocations : Array[PaymentAllocation], order_id : String) -> Int

    allocation_plan_is_consistent

    fn allocation_plan_is_consistent(plan : AllocationPlan) -> Bool

    allocation_state_label

    fn allocation_state_label(state : AllocationState) -> String

    allocations_for_order

    fn allocations_for_order(allocations : Array[PaymentAllocation], order_id : String) -> Array[PaymentAllocation]

    allocations_for_payment

    fn allocations_for_payment(allocations : Array[PaymentAllocation], payment_id : String) -> Array[PaymentAllocation]

    assign_case

    fn assign_case(queue : ReviewQueue, wanted : String, owner : String, updated_day : Int) -> ReviewQueue

    auto_assign

    fn auto_assign(queue : ReviewQueue, rules : Array[AssignmentRule], updated_day : Int) -> ReviewQueue

    balance_age

    fn balance_age(input : LedgerInput, order_id : String, current_day : Int) -> Int?

    balances_above_outstanding

    fn balances_above_outstanding(balances : Array[OrderBalance], threshold_minor : Int) -> Array[OrderBalance]

    balances_below_outstanding

    fn balances_below_outstanding(balances : Array[OrderBalance], threshold_minor : Int) -> Array[OrderBalance]

    best_candidate

    fn best_candidate(input : LedgerInput, payment : PaymentRecord) -> MatchingCandidate?

    blocking_quality_issues

    fn blocking_quality_issues(report : InputQualityReport) -> Array[QualityIssue]

    can_transition

    fn can_transition(from : ReviewState, to : ReviewState) -> Bool

    candidate_score

    fn candidate_score(payment : PaymentRecord, order : OrderRecord) -> Int

    captured_payment_amount

    fn captured_payment_amount(payment : PaymentRecord) -> Int

    case_age

    fn case_age(case : ReviewCase, current_day : Int) -> Int

    cases_for_order

    fn cases_for_order(cases : Array[ReviewCase], order_id : String) -> Array[ReviewCase]

    cases_for_owner

    fn cases_for_owner(cases : Array[ReviewCase], owner : String) -> Array[ReviewCase]

    cases_for_state

    fn cases_for_state(cases : Array[ReviewCase], state : ReviewState) -> Array[ReviewCase]

    clean_input

    fn clean_input() -> LedgerInput

    contains_string

    fn contains_string(items : Array[String], wanted : String) -> Bool

    count_balances_by_resolution

    fn count_balances_by_resolution(balances : Array[OrderBalance], resolution : Resolution) -> Int

    count_findings_by_code

    fn count_findings_by_code(findings : Array[Finding], code : FindingCode) -> Int

    count_string

    fn count_string(items : Array[String], wanted : String) -> Int

    csv_escape

    fn csv_escape(value : String) -> String

    decide_case

    fn decide_case(queue : ReviewQueue, wanted : String, decision : ReviewDecision, note : String, updated_day : Int) -> ReviewQueue

    default_policy

    fn default_policy() -> Policy

    demo_input

    fn demo_input() -> LedgerInput

    A deliberately mixed fixture used by the executable demo and integration tests.

    empty_allocation_plan

    fn empty_allocation_plan() -> AllocationPlan

    empty_finding_metrics

    fn empty_finding_metrics() -> FindingMetrics

    empty_input

    fn empty_input() -> LedgerInput

    empty_input_quality_report

    fn empty_input_quality_report() -> InputQualityReport

    empty_result_metrics

    fn empty_result_metrics() -> ResultMetrics

    empty_review_queue

    fn empty_review_queue() -> ReviewQueue

    empty_review_summary

    fn empty_review_summary() -> ReviewSummary

    empty_source_profile

    fn empty_source_profile(source : SourceKind) -> SourceProfile

    enqueue_finding

    fn enqueue_finding(queue : ReviewQueue, finding : Finding, opened_day : Int) -> ReviewQueue

    enqueue_findings

    fn enqueue_findings(queue : ReviewQueue, findings : Array[Finding], opened_day : Int) -> ReviewQueue

    error_findings

    fn error_findings(findings : Array[Finding]) -> Array[Finding]

    excess_for_payment

    fn excess_for_payment(allocations : Array[PaymentAllocation], payment_id : String) -> Int

    export_is_safe_csv

    fn export_is_safe_csv(text : String) -> Bool

    filter_findings

    fn filter_findings(findings : Array[Finding], query : FindingQuery) -> Array[Finding]

    find_balance

    fn find_balance(balances : Array[OrderBalance], order_id : String) -> OrderBalance?

    find_case_index

    fn find_case_index(cases : Array[ReviewCase], wanted : String) -> Int

    find_order

    fn find_order(input : LedgerInput, order_id : String) -> OrderRecord?

    find_review_case

    fn find_review_case(cases : Array[ReviewCase], wanted : String) -> ReviewCase?

    finding_code_counts

    fn finding_code_counts(findings : Array[Finding]) -> Array[CodeCount]

    finding_code_label

    fn finding_code_label(value : FindingCode) -> String

    finding_metrics

    fn finding_metrics(findings : Array[Finding]) -> FindingMetrics

    findings_for_kind

    fn findings_for_kind(findings : Array[Finding], kind : RecordKind) -> Array[Finding]

    findings_for_order

    fn findings_for_order(findings : Array[Finding], order_id : String) -> Array[Finding]

    ignored_allocations

    fn ignored_allocations(plan : AllocationPlan) -> Array[PaymentAllocation]

    input_quality_report_is_consistent

    fn input_quality_report_is_consistent(report : InputQualityReport) -> Bool

    inspect_input_quality

    fn inspect_input_quality(input : LedgerInput, policy : Policy, current_day : Int) -> InputQualityReport

    is_blank

    fn is_blank(value : String) -> Bool

    is_eligible_payment

    fn is_eligible_payment(payment : PaymentRecord) -> Bool

    is_healthy

    fn is_healthy(result : ReconciliationResult) -> Bool

    is_overdue

    fn is_overdue(case : ReviewCase, current_day : Int, max_age_days : Int) -> Bool

    is_terminal_state

    fn is_terminal_state(state : ReviewState) -> Bool

    make_finding

    fn make_finding(code : FindingCode, severity : Severity, record_kind : RecordKind, record_id : String, order_id : String, message : String) -> Finding

    matching_candidates

    fn matching_candidates(input : LedgerInput, payment : PaymentRecord) -> Array[MatchingCandidate]

    max_outstanding_balance

    fn max_outstanding_balance(balances : Array[OrderBalance]) -> OrderBalance?

    min_outstanding_balance

    fn min_outstanding_balance(balances : Array[OrderBalance]) -> OrderBalance?

    new_review_case

    fn new_review_case(finding : Finding, sequence : Int, opened_day : Int) -> ReviewCase

    open_cases

    fn open_cases(cases : Array[ReviewCase]) -> Array[ReviewCase]

    outstanding_by_age

    fn outstanding_by_age(input : LedgerInput, result : ReconciliationResult, current_day : Int) -> Array[AgeBucket]

    over_allocations

    fn over_allocations(plan : AllocationPlan) -> Array[PaymentAllocation]

    overdue_cases

    fn overdue_cases(cases : Array[ReviewCase], current_day : Int, max_age_days : Int) -> Array[ReviewCase]

    parse_adjustments_csv

    fn parse_adjustments_csv(text : String) -> Array[AdjustmentRecord]

    parse_csv

    fn parse_csv(text : String) -> Array[Array[String]]

    that the normal validation stage reports rather than causing partial mutation.

    parse_day

    fn parse_day(text : String) -> Int

    Parses a non-negative day number for command adapters. Invalid input becomes zero.

    parse_ledger_csv

    fn parse_ledger_csv(orders : String, payments : String, refunds : String, adjustments : String) -> LedgerInput

    parse_orders_csv

    fn parse_orders_csv(text : String) -> Array[OrderRecord]

    parse_payments_csv

    fn parse_payments_csv(text : String) -> Array[PaymentRecord]

    parse_refunds_csv

    fn parse_refunds_csv(text : String) -> Array[RefundRecord]

    payment_matches_order

    fn payment_matches_order(payment : PaymentRecord, order : OrderRecord) -> Bool

    priority_for_severity

    fn priority_for_severity(severity : Severity) -> Int

    priority_label

    fn priority_label(priority : Int) -> String

    quality_issue

    fn quality_issue(source : SourceKind, row_number : Int, record_id : String, order_id : String, code : QualityIssueCode, message : String) -> QualityIssue

    quality_issue_code_label

    fn quality_issue_code_label(code : QualityIssueCode) -> String

    quality_issues_for_code

    fn quality_issues_for_code(report : InputQualityReport, code : QualityIssueCode) -> Array[QualityIssue]

    quality_issues_for_source

    fn quality_issues_for_source(report : InputQualityReport, source : SourceKind) -> Array[QualityIssue]

    quality_score

    fn quality_score(result : ReconciliationResult) -> Int

    quality_severity

    fn quality_severity(code : QualityIssueCode) -> Severity

    queue_from_result

    fn queue_from_result(result : ReconciliationResult, opened_day : Int) -> ReviewQueue

    reconcile

    fn reconcile(input : LedgerInput, policy : Policy, current_day : Int) -> ReconciliationResult

    remaining_expected

    fn remaining_expected(balance : OrderBalance) -> Int

    render_account_totals_csv

    fn render_account_totals_csv(totals : Array[AccountTotal]) -> String

    render_age_buckets_csv

    fn render_age_buckets_csv(buckets : Array[AgeBucket]) -> String

    render_allocation_csv

    fn render_allocation_csv(plan : AllocationPlan) -> String

    render_allocation_plan

    fn render_allocation_plan(plan : AllocationPlan) -> String

    render_audit_bundle

    fn render_audit_bundle(input : LedgerInput, result : ReconciliationResult, current_day : Int) -> String

    render_balances

    fn render_balances(result : ReconciliationResult) -> String

    render_code_counts_markdown

    fn render_code_counts_markdown(counts : Array[CodeCount]) -> String

    render_currency_totals_csv

    fn render_currency_totals_csv(totals : Array[CurrencyTotal]) -> String

    render_findings

    fn render_findings(result : ReconciliationResult) -> String

    render_findings_csv

    fn render_findings_csv(findings : Array[Finding]) -> String

    render_metrics_markdown

    fn render_metrics_markdown(metrics : ResultMetrics) -> String

    render_quality_issues_csv

    fn render_quality_issues_csv(report : InputQualityReport) -> String

    render_quality_report

    fn render_quality_report(report : InputQualityReport) -> String

    render_review_case

    fn render_review_case(case : ReviewCase) -> String

    render_review_queue

    fn render_review_queue(queue : ReviewQueue) -> String

    render_review_queue_csv

    fn render_review_queue_csv(queue : ReviewQueue) -> String

    render_summary

    fn render_summary(result : ReconciliationResult) -> String

    reopen_case

    fn reopen_case(queue : ReviewQueue, wanted : String, updated_day : Int) -> ReviewQueue

    resolution_counts

    fn resolution_counts(result : ReconciliationResult) -> Array[ResolutionCount]

    resolution_label

    fn resolution_label(value : Resolution) -> String

    resolution_rank

    fn resolution_rank(resolution : Resolution) -> Int

    result_metrics

    fn result_metrics(result : ReconciliationResult) -> ResultMetrics

    review_decision_label

    fn review_decision_label(decision : ReviewDecision) -> String

    review_queue_is_consistent

    fn review_queue_is_consistent(queue : ReviewQueue) -> Bool

    review_state_label

    fn review_state_label(state : ReviewState) -> String

    review_summary

    fn review_summary(queue : ReviewQueue, current_day : Int, max_age_days : Int) -> ReviewSummary

    set_case_priority

    fn set_case_priority(queue : ReviewQueue, wanted : String, priority : Int, updated_day : Int) -> ReviewQueue

    settled_balances

    fn settled_balances(balances : Array[OrderBalance]) -> Array[OrderBalance]

    severity_label

    fn severity_label(value : Severity) -> String

    severity_rank

    fn severity_rank(severity : Severity) -> Int

    sort_balances_by_outstanding

    fn sort_balances_by_outstanding(balances : Array[OrderBalance]) -> Array[OrderBalance]

    sort_cases_by_priority

    fn sort_cases_by_priority(cases : Array[ReviewCase]) -> Array[ReviewCase]

    sort_findings_by_severity

    fn sort_findings_by_severity(findings : Array[Finding]) -> Array[Finding]

    source_kind_label

    fn source_kind_label(source : SourceKind) -> String

    source_profile_is_consistent

    fn source_profile_is_consistent(profile : SourceProfile) -> Bool

    sum_adjustments

    fn sum_adjustments(input : LedgerInput, order_id : String) -> Int

    sum_captured

    fn sum_captured(input : LedgerInput, order_id : String) -> Int

    sum_refunded

    fn sum_refunded(input : LedgerInput, order_id : String) -> Int

    totals_by_account

    fn totals_by_account(input : LedgerInput, result : ReconciliationResult) -> Array[AccountTotal]

    totals_by_currency

    fn totals_by_currency(input : LedgerInput, result : ReconciliationResult) -> Array[CurrencyTotal]

    transition_case

    fn transition_case(queue : ReviewQueue, wanted : String, target : ReviewState, updated_day : Int) -> ReviewQueue

    unmatched_allocations

    fn unmatched_allocations(plan : AllocationPlan) -> Array[PaymentAllocation]

    validate

    fn validate(input : LedgerInput, policy : Policy) -> Array[Finding]

    warning_or_higher_findings

    fn warning_or_higher_findings(findings : Array[Finding]) -> Array[Finding]