/**
 * Paypal Server SDKLib
 *
 * This file was automatically generated by APIMATIC v3.0 ( https://www.apimatic.io ).
 */

import { array, lazy, object, optional, Schema } from '../schema';
import { ExchangeRate, exchangeRateSchema } from './exchangeRate';
import { Money, moneySchema } from './money';
import { PlatformFee, platformFeeSchema } from './platformFee';

/** The detailed breakdown of the capture activity. This is not available for transactions that are in pending state. */
export interface SellerReceivableBreakdown {
  /** The currency and amount for a financial transaction, such as a balance or payment due. */
  grossAmount: Money;
  /** The currency and amount for a financial transaction, such as a balance or payment due. */
  paypalFee?: Money;
  /** The currency and amount for a financial transaction, such as a balance or payment due. */
  paypalFeeInReceivableCurrency?: Money;
  /** The currency and amount for a financial transaction, such as a balance or payment due. */
  netAmount?: Money;
  /** The currency and amount for a financial transaction, such as a balance or payment due. */
  receivableAmount?: Money;
  /** The exchange rate that determines the amount to convert from one currency to another currency. */
  exchangeRate?: ExchangeRate;
  /** An array of platform or partner fees, commissions, or brokerage fees that associated with the captured payment. */
  platformFees?: PlatformFee[];
}

export const sellerReceivableBreakdownSchema: Schema<SellerReceivableBreakdown> = object(
  {
    grossAmount: ['gross_amount', lazy(() => moneySchema)],
    paypalFee: ['paypal_fee', optional(lazy(() => moneySchema))],
    paypalFeeInReceivableCurrency: [
      'paypal_fee_in_receivable_currency',
      optional(lazy(() => moneySchema)),
    ],
    netAmount: ['net_amount', optional(lazy(() => moneySchema))],
    receivableAmount: ['receivable_amount', optional(lazy(() => moneySchema))],
    exchangeRate: ['exchange_rate', optional(lazy(() => exchangeRateSchema))],
    platformFees: [
      'platform_fees',
      optional(array(lazy(() => platformFeeSchema))),
    ],
  }
);
