syntax = "proto3";

package wix.common;

option java_multiple_files = true;
option java_package = "com.wix.common";

import "wix/api/annotations.proto";
import "wix/api/validations.proto";
import "google/protobuf/wrappers.proto";

// Common money formats.

// Money.
// Default format to use. Sufficiently compliant with majority of standards: w3c, ISO 4217, ISO 20022, ISO 8583:2003.
message Money {
    option (.wix.api.decomposition_minimum_fields) = {
        field: "value"
        field: "currency"
    };
    // For special cases, one may use just a value without currency to represent money. But:
    // - money MUST be a decimal string, as described below
    // - currency MUST be provided somewhere at the top level of your object

    // Monetary amount. Decimal string with a period as a decimal separator (e.g., 3.99). Optionally, a single (-), to indicate that the amount is negative.
    string value = 1 [(.wix.api.format) = DECIMAL_VALUE];
    // Currency code. Must be valid ISO 4217 currency code (e.g., USD).
    string currency = 2 [(.wix.api.format) = CURRENCY];
    // Monetary amount. Decimal string in local format (e.g., 1 000,30). Optionally, a single (-), to indicate that the amount is negative.
    google.protobuf.StringValue formatted_value = 3;

}
