Files
sendico/api/proto/common/money/v1/money.proto
2026-02-18 20:38:08 +01:00

41 lines
1.3 KiB
Protocol Buffer

syntax = "proto3";
package common.money.v1;
option go_package = "github.com/tech/sendico/pkg/proto/common/money/v1;moneyv1";
// Decimal represents an exact decimal value encoded as a string to avoid
// floating-point precision loss.
message Decimal {
// value is the decimal string representation (e.g. "123.45").
string value = 1;
}
// Money pairs a decimal amount with a currency code.
message Money {
// amount is the decimal string representation.
string amount = 1;
// currency is the ISO 4217 currency code (e.g. "USD", "EUR").
string currency = 2;
}
// RoundingMode specifies how to round monetary calculations.
enum RoundingMode {
// ROUNDING_MODE_UNSPECIFIED is the default zero value.
ROUNDING_MODE_UNSPECIFIED = 0;
// ROUND_HALF_EVEN rounds to the nearest even digit (banker's rounding).
ROUND_HALF_EVEN = 1;
// ROUND_HALF_UP rounds halves away from zero.
ROUND_HALF_UP = 2;
// ROUND_DOWN truncates towards zero.
ROUND_DOWN = 3;
}
// CurrencyMeta describes the precision and rounding rules for a currency.
message CurrencyMeta {
// code is the ISO 4217 currency code.
string code = 1;
// decimals is the number of minor-unit digits (e.g. 2 for USD, 0 for JPY).
uint32 decimals = 2;
// rounding is the preferred rounding mode for this currency.
RoundingMode rounding = 3;
}