domain tier

domain-billing

Subscription and billing for Rust applications

Subscription and billing for Rust applications

Tierdomain
Roleunclassified (baselined)
Pathcrates/domain/billing
Edition2021
Targetsdomain_billing
Public items77 across 0 modules
Tests51

What it is for

Subscription and billing library crates for Rust applications.

This crate provides types for managing subscriptions, plans, invoices, and billing cycles.

Capabilities

BillingError

Subscription and billing library crates for Rust applications.

Item
pub enum BillingError

BillingInterval

Subscription and billing library crates for Rust applications.

Item
pub enum BillingInterval
BillingInterval :: fn fmt(& self, f : & mut std::fmt::Formatter <'_>) -> std::fmt::Result
BillingInterval :: const fn days(& self) -> u32

Invoice:Invoice

Subscription and billing library crates for Rust applications.

Item
pub struct Invoice

Invoice:apply

Subscription and billing library crates for Rust applications.

Item
Invoice :: fn apply_payment(& mut self, amount : Decimal) -> Result <Decimal>

Invoice:finalize

Subscription and billing library crates for Rust applications.

Item
Invoice :: fn finalize(& mut self) -> Result <()>

Invoice:has

Subscription and billing library crates for Rust applications.

Item
Invoice :: fn has_payments(& self) -> bool

Invoice:is

Subscription and billing library crates for Rust applications.

Item
Invoice :: fn is_past_due(& self) -> bool

Invoice:mark

Subscription and billing library crates for Rust applications.

Item
Invoice :: fn mark_paid(& mut self) -> Result <()>
Invoice :: fn mark_uncollectible(& mut self) -> Result <()>

Invoice:new

Subscription and billing library crates for Rust applications.

Item
Invoice :: fn new(number : impl Into <String>, customer_id : PartyId) -> Self
Invoice :: fn new_payable(number : impl Into <String>, vendor_id : PartyId) -> Self

Invoice:payment

Subscription and billing library crates for Rust applications.

Item
Invoice :: fn payment_progress(& self) -> Decimal

Invoice:recalculate

Subscription and billing library crates for Rust applications.

Item
Invoice :: fn recalculate(& mut self)

Invoice:void

Subscription and billing library crates for Rust applications.

Item
Invoice :: fn void(& mut self) -> Result <()>

Invoice:with

Subscription and billing library crates for Rust applications.

Item
Invoice :: fn with_direction(mut self, direction : InvoiceDirection) -> Self
Invoice :: fn with_line_item(mut self, item : InvoiceLineItem) -> Self
Invoice :: fn with_tax(mut self, tax : Decimal) -> Self
Invoice :: fn with_due_date(mut self, due : DateTime <Utc>) -> Self
Invoice :: fn with_journal_entry(mut self, journal_entry_id : Uuid) -> Self

InvoiceDirection

Subscription and billing library crates for Rust applications.

Item
pub enum InvoiceDirection
InvoiceDirection :: fn fmt(& self, f : & mut std::fmt::Formatter <'_>) -> std::fmt::Result

InvoiceLineItem

Subscription and billing library crates for Rust applications.

Item
pub struct InvoiceLineItem
InvoiceLineItem :: fn new(description : impl Into <String>, quantity : u32, unit_price : Decimal) -> Self
InvoiceLineItem :: fn with_tax_rate(mut self, tax_rate : Decimal) -> Self
InvoiceLineItem :: fn with_currency(mut self, currency : impl Into <String>) -> Self

InvoiceStatus

Subscription and billing library crates for Rust applications.

Item
pub enum InvoiceStatus
InvoiceStatus :: fn fmt(& self, f : & mut std::fmt::Formatter <'_>) -> std::fmt::Result
InvoiceStatus :: fn can_accept_payment(& self) -> bool
InvoiceStatus :: fn is_terminal(& self) -> bool

Payment:Payment

Subscription and billing library crates for Rust applications.

Item
pub struct Payment

Payment:apply

Subscription and billing library crates for Rust applications.

Item
Payment :: fn apply_to_invoice(& mut self, invoice_id : Uuid, amount : Decimal,) -> Result <PaymentApplication>

Payment:has

Subscription and billing library crates for Rust applications.

Item
Payment :: fn has_unapplied(& self) -> bool

Payment:is

Subscription and billing library crates for Rust applications.

Item
Payment :: fn is_fully_applied(& self) -> bool

Payment:new

Subscription and billing library crates for Rust applications.

Item
Payment :: fn new(payer_id : PartyId, amount : Decimal) -> Self

Payment:refund

Subscription and billing library crates for Rust applications.

Item
Payment :: fn refund(& mut self) -> Result <()>

Payment:unapply

Subscription and billing library crates for Rust applications.

Item
Payment :: fn unapply_from_invoice(& mut self, invoice_id : Uuid) -> Result <Decimal>

Payment:void

Subscription and billing library crates for Rust applications.

Item
Payment :: fn void(& mut self) -> Result <()>

Payment:with

Subscription and billing library crates for Rust applications.

Item
Payment :: fn with_method(mut self, method : PaymentMethod) -> Self
Payment :: fn with_reference(mut self, reference : impl Into <String>) -> Self
Payment :: fn with_currency(mut self, currency : impl Into <String>) -> Self
Payment :: fn with_received_at(mut self, received_at : DateTime <Utc>) -> Self
Payment :: fn with_notes(mut self, notes : impl Into <String>) -> Self
Payment :: fn with_journal_entry(mut self, journal_entry_id : Uuid) -> Self

PaymentApplication

Subscription and billing library crates for Rust applications.

Item
pub struct PaymentApplication
PaymentApplication :: fn new(payment_id : Uuid, invoice_id : Uuid, amount : Decimal) -> Self

PaymentMethod

Subscription and billing library crates for Rust applications.

Item
pub enum PaymentMethod
PaymentMethod :: fn fmt(& self, f : & mut std::fmt::Formatter <'_>) -> std::fmt::Result

PaymentStatus

Subscription and billing library crates for Rust applications.

Item
pub enum PaymentStatus
PaymentStatus :: fn fmt(& self, f : & mut std::fmt::Formatter <'_>) -> std::fmt::Result
PaymentStatus :: fn can_apply(& self) -> bool
PaymentStatus :: fn is_terminal(& self) -> bool

Plan

Subscription and billing library crates for Rust applications.

Item
pub struct Plan
Plan :: fn new(slug : impl Into <String>, name : impl Into <String>, price : Decimal, interval : BillingInterval,) -> Self
Plan :: fn with_description(mut self, desc : impl Into <String>) -> Self
Plan :: fn with_trial(mut self, days : u32) -> Self
Plan :: fn with_feature(mut self, feature : impl Into <String>) -> Self
Plan :: fn with_currency(mut self, currency : impl Into <String>) -> Self
Plan :: fn monthly_price(& self) -> Decimal

Result

Subscription and billing library crates for Rust applications.

Item
pub type Result<T>: std::result::Result <T, BillingError>

Subscription

Subscription and billing library crates for Rust applications.

Item
pub struct Subscription
Subscription :: fn new(customer_id : PartyId, plan_id : Uuid, period_end : DateTime <Utc>) -> Self
Subscription :: fn with_trial(mut self, trial_end : DateTime <Utc>) -> Self
Subscription :: fn cancel(& mut self) -> Result <()>
Subscription :: fn cancel_now(& mut self) -> Result <()>
Subscription :: fn pause(& mut self) -> Result <()>
Subscription :: fn resume(& mut self) -> Result <()>
Subscription :: fn mark_past_due(& mut self)
Subscription :: fn is_trialing(& self) -> bool
Subscription :: fn days_remaining(& self) -> i64

SubscriptionStatus

Subscription and billing library crates for Rust applications.

Item
pub enum SubscriptionStatus
SubscriptionStatus :: fn fmt(& self, f : & mut std::fmt::Formatter <'_>) -> std::fmt::Result
SubscriptionStatus :: fn is_active(& self) -> bool
SubscriptionStatus :: fn is_terminal(& self) -> bool

UsageRecord

Subscription and billing library crates for Rust applications.

Item
pub struct UsageRecord
UsageRecord :: fn new(subscription_id : Uuid, metric : impl Into <String>, quantity : u64) -> Self

How to use it

No examples/ target and no doctest in this crate's rustdoc. The tests listed under Verification are the closest executable usage.

Module structure

No public modules: the crate root is its whole surface.

Public surface

`crate root`

ItemWhat it is
pub enum BillingErrorErrors that can occur with billing operations.
pub type Result<T>: std::result::Result <T, BillingError>Result type for billing operations.
pub enum BillingIntervalBilling interval.
BillingInterval :: fn fmt(& self, f : & mut std::fmt::Formatter <'_>) -> std::fmt::Result
BillingInterval :: const fn days(& self) -> u32Returns the number of days in this interval.
pub struct PlanA billing plan.
Plan :: fn new(slug : impl Into <String>, name : impl Into <String>, price : Decimal, interval : BillingInterval,) -> SelfCreates a new plan.
Plan :: fn with_description(mut self, desc : impl Into <String>) -> SelfSets the description.
Plan :: fn with_trial(mut self, days : u32) -> SelfSets the trial period.
Plan :: fn with_feature(mut self, feature : impl Into <String>) -> SelfAdds a feature.
Plan :: fn with_currency(mut self, currency : impl Into <String>) -> SelfSets the currency.
Plan :: fn monthly_price(& self) -> DecimalReturns the monthly equivalent price.
pub enum SubscriptionStatusSubscription status.
SubscriptionStatus :: fn fmt(& self, f : & mut std::fmt::Formatter <'_>) -> std::fmt::Result
SubscriptionStatus :: fn is_active(& self) -> boolReturns true if the subscription is usable.
SubscriptionStatus :: fn is_terminal(& self) -> boolReturns true if the subscription is in a terminal state.
pub struct SubscriptionA subscription.
Subscription :: fn new(customer_id : PartyId, plan_id : Uuid, period_end : DateTime <Utc>) -> SelfCreates a new subscription
Subscription :: fn with_trial(mut self, trial_end : DateTime <Utc>) -> SelfCreates a subscription with a trial.
Subscription :: fn cancel(& mut self) -> Result <()>Cancels the subscription at period end.
Subscription :: fn cancel_now(& mut self) -> Result <()>Cancels the subscription immediately.
Subscription :: fn pause(& mut self) -> Result <()>Pauses the subscription.
Subscription :: fn resume(& mut self) -> Result <()>Resumes a paused subscription.
Subscription :: fn mark_past_due(& mut self)Marks the subscription as past due.
Subscription :: fn is_trialing(& self) -> boolReturns true if currently in trial.
Subscription :: fn days_remaining(& self) -> i64Returns days remaining in current period.
pub enum InvoiceStatusInvoice status.
InvoiceStatus :: fn fmt(& self, f : & mut std::fmt::Formatter <'_>) -> std::fmt::Result
InvoiceStatus :: fn can_accept_payment(& self) -> boolReturns true if the invoice can accept payments.
InvoiceStatus :: fn is_terminal(& self) -> boolReturns true if the invoice is in a terminal state.
pub enum InvoiceDirectionInvoice direction for AR/AP classification.
InvoiceDirection :: fn fmt(& self, f : & mut std::fmt::Formatter <'_>) -> std::fmt::Result
pub struct InvoiceLineItemAn invoice line item.
InvoiceLineItem :: fn new(description : impl Into <String>, quantity : u32, unit_price : Decimal) -> SelfCreates a new line item.
InvoiceLineItem :: fn with_tax_rate(mut self, tax_rate : Decimal) -> SelfSets the tax rate and recalculates amounts.
InvoiceLineItem :: fn with_currency(mut self, currency : impl Into <String>) -> SelfSets the currency.
pub struct InvoiceAn invoice.
Invoice :: fn new(number : impl Into <String>, customer_id : PartyId) -> SelfCreates a new invoice (AR by default)
Invoice :: fn new_payable(number : impl Into <String>, vendor_id : PartyId) -> SelfCreates a new AP invoice (bill/payable).
Invoice :: fn with_direction(mut self, direction : InvoiceDirection) -> SelfSets the invoice direction.
Invoice :: fn with_line_item(mut self, item : InvoiceLineItem) -> SelfAdds a line item and recalculates totals.
Invoice :: fn with_tax(mut self, tax : Decimal) -> SelfSets the tax amount (overrides line item taxes).
Invoice :: fn with_due_date(mut self, due : DateTime <Utc>) -> SelfSets the due date.
Invoice :: fn with_journal_entry(mut self, journal_entry_id : Uuid) -> SelfSets the posted journal entry ID for ledger integration.
Invoice :: fn recalculate(& mut self)Recalculates totals from line items.
Invoice :: fn finalize(& mut self) -> Result <()>Finalizes the invoice (Draft -> Open).
Invoice :: fn apply_payment(& mut self, amount : Decimal) -> Result <Decimal>Applies a payment amount to this invoice
Invoice :: fn mark_paid(& mut self) -> Result <()>Marks the invoice as fully paid (bypasses payment tracking).
Invoice :: fn void(& mut self) -> Result <()>Voids the invoice.
Invoice :: fn mark_uncollectible(& mut self) -> Result <()>Marks the invoice as uncollectible.
Invoice :: fn is_past_due(& self) -> boolReturns true if the invoice is past due.
Invoice :: fn has_payments(& self) -> boolReturns true if the invoice has any payments applied.
Invoice :: fn payment_progress(& self) -> DecimalReturns the payment progress as a percentage (0.0 to 1.0).
pub struct UsageRecordUsage record for metered billing.
UsageRecord :: fn new(subscription_id : Uuid, metric : impl Into <String>, quantity : u64) -> SelfCreates a new usage record.
pub enum PaymentMethodPayment method type.
PaymentMethod :: fn fmt(& self, f : & mut std::fmt::Formatter <'_>) -> std::fmt::Result
pub enum PaymentStatusPayment status.
PaymentStatus :: fn fmt(& self, f : & mut std::fmt::Formatter <'_>) -> std::fmt::Result
PaymentStatus :: fn can_apply(& self) -> boolReturns true if the payment can be applied to invoices.
PaymentStatus :: fn is_terminal(& self) -> boolReturns true if the payment is in a terminal state.
pub struct PaymentA payment received from a customer.
Payment :: fn new(payer_id : PartyId, amount : Decimal) -> SelfCreates a new payment.
Payment :: fn with_method(mut self, method : PaymentMethod) -> SelfSets the payment method.
Payment :: fn with_reference(mut self, reference : impl Into <String>) -> SelfSets the external reference.
Payment :: fn with_currency(mut self, currency : impl Into <String>) -> SelfSets the currency.
Payment :: fn with_received_at(mut self, received_at : DateTime <Utc>) -> SelfSets the received date.
Payment :: fn with_notes(mut self, notes : impl Into <String>) -> SelfSets notes.
Payment :: fn with_journal_entry(mut self, journal_entry_id : Uuid) -> SelfSets the posted journal entry ID.
Payment :: fn apply_to_invoice(& mut self, invoice_id : Uuid, amount : Decimal,) -> Result <PaymentApplication>Applies a portion of this payment to an invoice
Payment :: fn unapply_from_invoice(& mut self, invoice_id : Uuid) -> Result <Decimal>Removes an application from this payment.
Payment :: fn has_unapplied(& self) -> boolReturns true if this payment has unapplied funds.
Payment :: fn is_fully_applied(& self) -> boolReturns true if this payment is fully applied.
Payment :: fn void(& mut self) -> Result <()>Voids this payment.
Payment :: fn refund(& mut self) -> Result <()>Marks the payment as refunded.
pub struct PaymentApplicationA record of payment applied to an invoice.
PaymentApplication :: fn new(payment_id : Uuid, invoice_id : Uuid, amount : Decimal) -> SelfCreates a new payment application.

No pub use re-exports: every item above is declared in this crate.

Boundary

Reaches into foundation, identity.

Shares tier domain with 41 other crates: domain-agreements, domain-ai-report, domain-catalog, domain-classify, domain-comments, domain-competitive-intel, domain-contact, domain-conversation-engine, … (41 total).

_What this crate deliberately does NOT own is a judgment. No committed registry records one for it, so none is stated here._

Where it sits

Tier (ontology)domain
Architectural role (taxonomy)unclassified (baselined)
Locationcrates/domain/billing
Vocabulary in force (lexicon)current

Tier flow. Which tiers this crate's own edges cross.

flowchart LR
  n_domain["domain"] --> n_foundation["foundation"]
  n_domain["domain"] --> n_identity["identity"]

Dependencies

Runtime, in this workspace.

CrateTierOptionalOnly on
`foundation-basemodels`foundationnoalways
`foundation-money`foundationnoalways
`identity-parties`identitynoalways

Runtime, from outside the workspace.

CrateRequirementFeaturesOptionalOnly on
chrono^0.4serdenoalways
rust_decimal^1serdenoalways
serde^1derivenoalways
serde_json^1noalways
thiserror^2noalways
uuid^1v4, v7, serde, jsnoalways

Development, from outside the workspace.

CrateRequirementFeaturesOptionalOnly on
tokio^1fullnoalways

Build. None.

Depended on by. 1 workspace crate.

Signal flow — what reaches this crate, and what it reaches.

flowchart LR
  n_application_billing["application-billing"] -->|uses| SELF
  SELF["domain-billing"]
  SELF -->|runtime| n_foundation_basemodels["foundation-basemodels"]
  SELF -->|runtime| n_foundation_money["foundation-money"]
  SELF -->|runtime| n_identity_parties["identity-parties"]
  classDef self fill:#1f883d,stroke:#1f883d,color:#fff;
  class SELF self;

Feature flags

No Cargo features are defined: every capability is unconditional, so no consumer can receive a half-wired crate.

Targets

KindNameSource
libdomain_billing`src/lib.rs`

Error model

Error typeNamed by
BillingErrorResult

Operational characteristics

PropertyEvidence
async public surfacenone detected
async runtimenone detected
database accessnone detected
network I/Onone detected
unsafe codenone detected
environment variablesnone detected

No unsafe block, unsafe fn, unsafe impl or unsafe trait was found by the parser anywhere in this crate's source.

Configuration

No environment variable is read with a literal name anywhere in this crate. A variable whose key is computed at run time cannot be listed here, and is not claimed to be absent.

1 workspace crate depends on this one: application-billing.

Verification

KindCount
Unit tests51
Integration tests0
Examples0
Doctests0

Evidence by module. How often each public module is named by something executable.

ModuleTestsExamplesConsumers
crate root1501

What the tests establish, by name:

Documentation coverage

MeasureDocumentedTotal
Public items with rustdoc7177
Public modules with a //! block00
pie showData
    title Public items with rustdoc
    "Documented" : 71
    "No rustdoc detected" : 6

Metrics

MetricValue
Rust source files1
Source lines1680
Code lines1262
Public API items77
Public modules0
Tests51
Examples0
Cargo features0
Direct runtime dependencies9
Workspace reverse dependencies1
pie showData
    title Public API by kind
    "enum" : 7
    "method" : 62
    "struct" : 7
    "type alias" : 1
pie showData
    title Rust source composition
    "Code" : 1262
    "Blank or comment" : 418

Generation

Rendered by tools-corpus corpus readme from repository evidence alone, renderer schema 2, lexicon current. No model, network service or database was consulted. Regenerate with tools-corpus corpus readme --write; verify with --check.

All domain · Manual