openmeterio / openmeter

Metering and Billing for AI, API and DevOps. Collect and aggregate millions of usage events in real-time and enable usage-based billing.
https://openmeter.io
Apache License 2.0
1.14k stars 68 forks source link

feat: totals calculations #1896

Closed turip closed 4 days ago

turip commented 5 days ago

Overview

Add line and invoice total calculations.

Contents:


type Totals struct {
    // Amount is the total amount value of the line before taxes, discounts and commitments
    Amount alpacadecimal.Decimal `json:"amount"`
    // ChargesTotal is the amount of value of the line that are due to additional charges
    ChargesTotal alpacadecimal.Decimal `json:"chargesTotal"`
    // DiscountsTotal is the amount of value of the line that are due to discounts
    DiscountsTotal alpacadecimal.Decimal `json:"discountsTotal"`

    // TaxesInclusiveTotal is the total amount of taxes that are included in the line
    TaxesInclusiveTotal alpacadecimal.Decimal `json:"taxesInclusiveTotal"`
    // TaxesExclusiveTotal is the total amount of taxes that are excluded from the line
    TaxesExclusiveTotal alpacadecimal.Decimal `json:"taxesExclusiveTotal"`
    // TaxesTotal is the total amount of taxes that are included in the line
    TaxesTotal alpacadecimal.Decimal `json:"taxesTotal"`

    // Total is the total amount value of the line after taxes, discounts and commitments
    Total alpacadecimal.Decimal `json:"total"`
}

Notes for reviewer