import {z} from 'zod' export type SystemCountries = 'AA' | 'AB' | 'AC' | 'AD' | 'AE' | 'AF' | 'AG' | 'AH' | 'AI' | 'AJ' | 'AK' | 'AL' | 'AM' | 'AN' | 'AO' | 'AP' | 'AQ' | 'AR' | 'AS' | 'AT' | 'AU' | 'AV' | 'AW' | 'AX' | 'AY' | 'AZ' | 'BA' | 'BB' | 'BC' | 'BD' | 'BE' | 'BF' | 'BG' | 'BH' | 'BI' | 'BJ' | 'BK' | 'BL' | 'BM' | 'BN' | 'BO' | 'BP' | 'BQ' | 'BR' | 'BS' | 'BT' | 'BU' | 'BV' | 'BW' | 'BX' | 'BY' | 'BZ' | 'CA' | 'CB' | 'CC' | 'CD' | 'CE' | 'CF' | 'CG' | 'CH' | 'CI' | 'CJ' | 'CK' | 'CL' | 'CM' | 'CN' | 'CO' | 'CP' | 'CQ' | 'CR' | 'CS' | 'CT' | 'CU' | 'CV' | 'CW' | 'CX' | 'CY' | 'CZ' | 'DA' | 'DB' | 'DC' | 'DD' | 'DE' | 'DF' | 'DG' | 'DH' | 'DI' | 'DJ' | 'DK' | 'DL' | 'DM' | 'DN' | 'DO' | 'DP' | 'DQ' | 'DR' | 'DS' | 'DT' | 'DU' | 'DV' | 'DW' | 'DX' | 'DY' | 'DZ' | 'EA' | 'EB' | 'EC' | 'ED' | 'EE' | 'EF' | 'EG' | 'EH' | 'EI' | 'EJ' | 'EK' | 'EL' | 'EM' | 'EN' | 'EO' | 'EP' | 'EQ' | 'ER' | 'ES' | 'ET' | 'EU' | 'EV' | 'EW' | 'EX' | 'EY' | 'EZ' | 'FA' | 'FB' | 'FC' | 'FD' | 'FE' | 'FF' | 'FG' | 'FH' | 'FI' | 'FJ' | 'FK' | 'FL' | 'FM' | 'FN' | 'FO' | 'FP' | 'FQ' | 'FR' | 'FS' | 'FT' | 'FU' | 'FV' | 'FW' | 'FX' | 'FY' | 'FZ' | 'GA' | 'GB' | 'GC' | 'GD' | 'GE' | 'GF' | 'GG' | 'GH' | 'GI' | 'GJ' | 'GK' | 'GL' | 'GM' | 'GN' | 'GO' | 'GP' | 'GQ' | 'GR' | 'GS' | 'GT' | 'GU' | 'GV' | 'GW' | 'GX' | 'GY' | 'GZ' | 'HA' | 'HB' | 'HC' | 'HD' | 'HE' | 'HF' | 'HG' | 'HH' | 'HI' | 'HJ' | 'HK' | 'HL' | 'HM' | 'HN' | 'HO' | 'HP' | 'HQ' | 'HR' | 'HS' | 'HT' | 'HU' | 'HV' | 'HW' | 'HX' | 'HY' | 'HZ' | 'IA' | 'IB' | 'IC' | 'ID' | 'IE' | 'IF' | 'IG' | 'IH' | 'II' | 'IJ' | 'IK' | 'IL' | 'IM' | 'IN' | 'IO' | 'IP' | 'IQ' | 'IR' | 'IS' | 'IT' | 'IU' | 'IV' | 'IW' | 'IX' | 'IY' | 'IZ' | 'JA' | 'JB' | 'JC' | 'JD' | 'JE' | 'JF' | 'JG' | 'JH' | 'JI' | 'JJ' | 'JK' | 'JL' | 'JM' | 'JN' | 'JO' | 'JP' | 'JQ' | 'JR' | 'JS' | 'JT' | 'JU' | 'JV' | 'JW' | 'JX' | 'JY' | 'JZ' | 'KA' | 'KB' | 'KC' | 'KD' | 'KE' | 'KF' | 'KG' | 'KH' | 'KI' | 'KJ' | 'KK' | 'KL' | 'KM' | 'KN' | 'KO' | 'KP' | 'KQ' | 'KR' | 'KS' | 'KT' | 'KU' | 'KV' | 'KW' | 'KX' | 'KY' | 'KZ' | 'LA' | 'LB' | 'LC' | 'LD' | 'LE' | 'LF' | 'LG' | 'LH' | 'LI' | 'LJ' | 'LK' | 'LL' | 'LM' | 'LN' | 'LO' | 'LP' | 'LQ' | 'LR' | 'LS' | 'LT' | 'LU' | 'LV' | 'LW' | 'LX' | 'LY' | 'LZ' | 'MA' | 'MB' | 'MC' | 'MD' | 'ME' | 'MF' | 'MG' | 'MH' | 'MI' | 'MJ' | 'MK' | 'ML' | 'MM' | 'MN' | 'MO' | 'MP' | 'MQ' | 'MR' | 'MS' | 'MT' | 'MU' | 'MV' | 'MW' | 'MX' | 'MY' | 'MZ' | 'NA' | 'NB' | 'NC' | 'ND' | 'NE' | 'NF' | 'NG' | 'NH' | 'NI' | 'NJ' | 'NK' | 'NL' | 'NM' | 'NN' | 'NO' | 'NP' | 'NQ' | 'NR' | 'NS' | 'NT' | 'NU' | 'NV' | 'NW' | 'NX' | 'NY' | 'NZ' | 'OA' | 'OB' | 'OC' | 'OD' | 'OE' | 'OF' | 'OG' | 'OH' | 'OI' | 'OJ' | 'OK' | 'OL' | 'OM' | 'ON' | 'OO' | 'OP' | 'OQ' | 'OR' | 'OS' | 'OT' | 'OU' | 'OV' | 'OW' | 'OX' | 'OY' | 'OZ' | 'PA' | 'PB' | 'PC' | 'PD' | 'PE' | 'PF' | 'PG' | 'PH' | 'PI' | 'PJ' | 'PK' | 'PL' | 'PM' | 'PN' | 'PO' | 'PP' | 'PQ' | 'PR' | 'PS' | 'PT' | 'PU' | 'PV' | 'PW' | 'PX' | 'PY' | 'PZ' | 'QA' | 'QB' | 'QC' | 'QD' | 'QE' | 'QF' | 'QG' | 'QH' | 'QI' | 'QJ' | 'QK' | 'QL' | 'QM' | 'QN' | 'QO' | 'QP' | 'QQ' | 'QR' | 'QS' | 'QT' | 'QU' | 'QV' | 'QW' | 'QX' | 'QY' | 'QZ' | 'RA' | 'RB' | 'RC' | 'RD' | 'RE' | 'RF' | 'RG' | 'RH' | 'RI' | 'RJ' | 'RK' | 'RL' | 'RM' | 'RN' | 'RO' | 'RP' | 'RQ' | 'RR' | 'RS' | 'RT' | 'RU' | 'RV' | 'RW' | 'RX' | 'RY' | 'RZ' | 'SA' | 'SB' | 'SC' | 'SD' | 'SE' | 'SF' | 'SG' | 'SH' | 'SI' | 'SJ' | 'SK' | 'SL' | 'SM' | 'SN' | 'SO' | 'SP' | 'SQ' | 'SR' | 'SS' | 'ST' | 'SU' | 'SV' | 'SW' | 'SX' | 'SY' | 'SZ' | 'TA' | 'TB' | 'TC' | 'TD' | 'TE' | 'TF' | 'TG' | 'TH' | 'TI' | 'TJ' | 'TK' | 'TL' | 'TM' | 'TN' | 'TO' | 'TP' | 'TQ' | 'TR' | 'TS' | 'TT' | 'TU' | 'TV' | 'TW' | 'TX' | 'TY' | 'TZ' | 'UA' | 'UB' | 'UC' | 'UD' | 'UE' | 'UF' | 'UG' | 'UH' | 'UI' | 'UJ' | 'UK' | 'UL' | 'UM' | 'UN' | 'UO' | 'UP' | 'UQ' | 'UR' | 'US' | 'UT' | 'UU' | 'UV' | 'UW' | 'UX' | 'UY' | 'UZ' | 'VA' | 'VB' | 'VC' | 'VD' | 'VE' | 'VF' | 'VG' | 'VH' | 'VI' | 'VJ' | 'VK' | 'VL' | 'VM' | 'VN' | 'VO' | 'VP' | 'VQ' | 'VR' | 'VS' | 'VT' | 'VU' | 'VV' | 'VW' | 'VX' | 'VY' | 'VZ' | 'WA' | 'WB' | 'WC' | 'WD' | 'WE' | 'WF' | 'WG' | 'WH' | 'WI' | 'WJ' | 'WK' | 'WL' | 'WM' | 'WN' | 'WO' | 'WP' | 'WQ' | 'WR' | 'WS' | 'WT' | 'WU' | 'WV' | 'WW' | 'WX' | 'WY' | 'WZ' | 'XA' | 'XB' | 'XC' | 'XD' | 'XE' | 'XF' | 'XG' | 'XH' | 'XI' | 'XJ' | 'XK' | 'XL' | 'XM' | 'XN' | 'XO' | 'XP' | 'XQ' | 'XR' | 'XS' | 'XT' | 'XU' | 'XV' | 'XW' | 'XX' | 'XY' | 'XZ' | 'YA' | 'YB' | 'YC' | 'YD' | 'YE' | 'YF' | 'YG' | 'YH' | 'YI' | 'YJ' | 'YK' | 'YL' | 'YM' | 'YN' | 'YO' | 'YP' | 'YQ' | 'YR' | 'YS' | 'YT' | 'YU' | 'YV' | 'YW' | 'YX' | 'YY' | 'YZ' | 'ZA' | 'ZB' | 'ZC' | 'ZD' | 'ZE' | 'ZF' | 'ZG' | 'ZH' | 'ZI' | 'ZJ' | 'ZK' | 'ZL' | 'ZM' | 'ZN' | 'ZO' | 'ZP' | 'ZQ' | 'ZR' | 'ZS' | 'ZT' | 'ZU' | 'ZV' | 'ZW' | 'ZX' | 'ZY' | 'ZZ'; export type AddressSchemaIn = {street: string, city: string, state?: string | undefined, postal_code: string, country?: ('' | SystemCountries) | undefined, second_line?: string | undefined, name?: (string | null) | undefined}; export type TaxRegistrationNumberEntry = {type: string, number: string, region?: (string | null) | undefined}; export type TaxRegistrationNumbersSnapshot = {company?: Array | undefined, counterparty?: Array | undefined}; export type RecordTaxMetadata = {[key: string]: {[key: string]: unknown}}; export type AutoCalculateTaxMode = 'required'; export type SystemCurrencies = 'AED' | 'AFN' | 'ALL' | 'AMD' | 'ANG' | 'AOA' | 'ARS' | 'AUD' | 'AWG' | 'AZN' | 'BAM' | 'BBD' | 'BDT' | 'BGN' | 'BHD' | 'BIF' | 'BMD' | 'BND' | 'BOB' | 'BRL' | 'BSD' | 'BTN' | 'BWP' | 'BYN' | 'BZD' | 'CAD' | 'CDF' | 'CHF' | 'CLF' | 'CLP' | 'CNY' | 'COP' | 'CRC' | 'CUP' | 'CVE' | 'CZK' | 'DJF' | 'DKK' | 'DOP' | 'DZD' | 'EGP' | 'ERN' | 'ETB' | 'EUR' | 'FJD' | 'FKP' | 'GBP' | 'GEL' | 'GHS' | 'GIP' | 'GMD' | 'GNF' | 'GTQ' | 'GYD' | 'HKD' | 'HNL' | 'HTG' | 'HUF' | 'IDR' | 'ILS' | 'INR' | 'IQD' | 'IRR' | 'ISK' | 'JMD' | 'JOD' | 'JPY' | 'KES' | 'KGS' | 'KHR' | 'KMF' | 'KPW' | 'KRW' | 'KWD' | 'KYD' | 'KZT' | 'LAK' | 'LBP' | 'LKR' | 'LRD' | 'LSL' | 'LYD' | 'MAD' | 'MDL' | 'MGA' | 'MKD' | 'MMK' | 'MNT' | 'MOP' | 'MRU' | 'MUR' | 'MVR' | 'MWK' | 'MXN' | 'MYR' | 'MZN' | 'NAD' | 'NGN' | 'NIO' | 'NOK' | 'NPR' | 'NZD' | 'OMR' | 'PAB' | 'PEN' | 'PGK' | 'PHP' | 'PKR' | 'PLN' | 'PYG' | 'QAR' | 'RON' | 'RSD' | 'RUB' | 'RWF' | 'SAR' | 'SBD' | 'SCR' | 'SDG' | 'SEK' | 'SGD' | 'SHP' | 'SLL' | 'SOS' | 'SRD' | 'STN' | 'SVC' | 'SYP' | 'SZL' | 'THB' | 'TJS' | 'TMT' | 'TND' | 'TOP' | 'TRY' | 'TTD' | 'TWD' | 'TZS' | 'UAH' | 'UGX' | 'USD' | 'UYU' | 'UZS' | 'VES' | 'VND' | 'VUV' | 'WST' | 'XAF' | 'XAG' | 'XAU' | 'XCD' | 'XDR' | 'XOF' | 'XPD' | 'XPF' | 'XPT' | 'YER' | 'ZAR' | 'ZMW' | 'ZWL'; export type ItemTaxData = {code: string, rate: number | string, amount: number | string, is_taxable?: (boolean | null) | undefined, tax_exempt_amount?: (number | string | null) | undefined, vat_rate_id?: (number | null) | undefined, gst_tax_rate_id?: (number | null) | undefined, tax_metadata?: ({[key: string]: unknown} | null) | undefined}; export type PublicRecordClassificationsSchemaOut = {id: number, name: string, line_id: number, line_name: string, parent_classification_id?: (number | null) | undefined, parent_classification_line_id?: (number | null) | undefined}; export type PublicCashSaleItemIn = {tax?: (ItemTaxData | null) | undefined, custom_fields?: (Array<{[key: string]: unknown}> | null) | undefined, id?: (number | null) | undefined, item_id: number, quantity: number | string, rate: number | string, position: number, memo?: string | undefined, classifications?: Array | undefined, company_id?: (number | null) | undefined}; export type AttachmentSchemaOut = {id: number, file_name: string, file_size: number, download_url?: (string | null) | undefined, upload_url?: (string | null) | undefined, category?: string | undefined}; export type RecordStatus = 'draft' | 'posted' | 'archived'; export type PublicCashSaleSchemaUpdateIn = {bill_to_address?: (string | null) | undefined, ship_to_address?: (string | null) | undefined, billing_address?: (AddressSchemaIn | null) | undefined, shipping_address?: (AddressSchemaIn | null) | undefined, supply_date?: (string | null) | undefined, place_of_supply?: (string | null) | undefined, tax_registration_numbers?: (TaxRegistrationNumbersSnapshot | null) | undefined, tax_metadata?: (RecordTaxMetadata | null) | undefined, custom_fields?: (Array<{[key: string]: unknown}> | null) | undefined, date: string, transaction_date?: (string | null) | undefined, auto_calculate_tax?: (AutoCalculateTaxMode | null) | undefined, memo?: string | undefined, check_number?: string | undefined, company_id: number, customer_id: number, account_number?: (number | null) | undefined, currency_iso_4217_code: SystemCurrencies, exchange_rate: number | string, bank_or_undeposited_account_amount: number | string, undeposited_funds_currency?: (SystemCurrencies | null) | undefined, items?: Array | undefined, attachments?: Array | undefined, payment_method_id?: (number | null) | undefined, record_status?: RecordStatus | undefined}; export type UpdateApiPublicV1CashSalesRecordNumberArgs = {record_number: number, 'Idempotency-Key'?: string | undefined, body: PublicCashSaleSchemaUpdateIn}; export type UpdateApiPublicV1CashSalesRecordNumberOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; export const systemCountries = z.enum(["AA", "AB", "AC", "AD", "AE", "AF", "AG", "AH", "AI", "AJ", "AK", "AL", "AM", "AN", "AO", "AP", "AQ", "AR", "AS", "AT", "AU", "AV", "AW", "AX", "AY", "AZ", "BA", "BB", "BC", "BD", "BE", "BF", "BG", "BH", "BI", "BJ", "BK", "BL", "BM", "BN", "BO", "BP", "BQ", "BR", "BS", "BT", "BU", "BV", "BW", "BX", "BY", "BZ", "CA", "CB", "CC", "CD", "CE", "CF", "CG", "CH", "CI", "CJ", "CK", "CL", "CM", "CN", "CO", "CP", "CQ", "CR", "CS", "CT", "CU", "CV", "CW", "CX", "CY", "CZ", "DA", "DB", "DC", "DD", "DE", "DF", "DG", "DH", "DI", "DJ", "DK", "DL", "DM", "DN", "DO", "DP", "DQ", "DR", "DS", "DT", "DU", "DV", "DW", "DX", "DY", "DZ", "EA", "EB", "EC", "ED", "EE", "EF", "EG", "EH", "EI", "EJ", "EK", "EL", "EM", "EN", "EO", "EP", "EQ", "ER", "ES", "ET", "EU", "EV", "EW", "EX", "EY", "EZ", "FA", "FB", "FC", "FD", "FE", "FF", "FG", "FH", "FI", "FJ", "FK", "FL", "FM", "FN", "FO", "FP", "FQ", "FR", "FS", "FT", "FU", "FV", "FW", "FX", "FY", "FZ", "GA", "GB", "GC", "GD", "GE", "GF", "GG", "GH", "GI", "GJ", "GK", "GL", "GM", "GN", "GO", "GP", "GQ", "GR", "GS", "GT", "GU", "GV", "GW", "GX", "GY", "GZ", "HA", "HB", "HC", "HD", "HE", "HF", "HG", "HH", "HI", "HJ", "HK", "HL", "HM", "HN", "HO", "HP", "HQ", "HR", "HS", "HT", "HU", "HV", "HW", "HX", "HY", "HZ", "IA", "IB", "IC", "ID", "IE", "IF", "IG", "IH", "II", "IJ", "IK", "IL", "IM", "IN", "IO", "IP", "IQ", "IR", "IS", "IT", "IU", "IV", "IW", "IX", "IY", "IZ", "JA", "JB", "JC", "JD", "JE", "JF", "JG", "JH", "JI", "JJ", "JK", "JL", "JM", "JN", "JO", "JP", "JQ", "JR", "JS", "JT", "JU", "JV", "JW", "JX", "JY", "JZ", "KA", "KB", "KC", "KD", "KE", "KF", "KG", "KH", "KI", "KJ", "KK", "KL", "KM", "KN", "KO", "KP", "KQ", "KR", "KS", "KT", "KU", "KV", "KW", "KX", "KY", "KZ", "LA", "LB", "LC", "LD", "LE", "LF", "LG", "LH", "LI", "LJ", "LK", "LL", "LM", "LN", "LO", "LP", "LQ", "LR", "LS", "LT", "LU", "LV", "LW", "LX", "LY", "LZ", "MA", "MB", "MC", "MD", "ME", "MF", "MG", "MH", "MI", "MJ", "MK", "ML", "MM", "MN", "MO", "MP", "MQ", "MR", "MS", "MT", "MU", "MV", "MW", "MX", "MY", "MZ", "NA", "NB", "NC", "ND", "NE", "NF", "NG", "NH", "NI", "NJ", "NK", "NL", "NM", "NN", "NO", "NP", "NQ", "NR", "NS", "NT", "NU", "NV", "NW", "NX", "NY", "NZ", "OA", "OB", "OC", "OD", "OE", "OF", "OG", "OH", "OI", "OJ", "OK", "OL", "OM", "ON", "OO", "OP", "OQ", "OR", "OS", "OT", "OU", "OV", "OW", "OX", "OY", "OZ", "PA", "PB", "PC", "PD", "PE", "PF", "PG", "PH", "PI", "PJ", "PK", "PL", "PM", "PN", "PO", "PP", "PQ", "PR", "PS", "PT", "PU", "PV", "PW", "PX", "PY", "PZ", "QA", "QB", "QC", "QD", "QE", "QF", "QG", "QH", "QI", "QJ", "QK", "QL", "QM", "QN", "QO", "QP", "QQ", "QR", "QS", "QT", "QU", "QV", "QW", "QX", "QY", "QZ", "RA", "RB", "RC", "RD", "RE", "RF", "RG", "RH", "RI", "RJ", "RK", "RL", "RM", "RN", "RO", "RP", "RQ", "RR", "RS", "RT", "RU", "RV", "RW", "RX", "RY", "RZ", "SA", "SB", "SC", "SD", "SE", "SF", "SG", "SH", "SI", "SJ", "SK", "SL", "SM", "SN", "SO", "SP", "SQ", "SR", "SS", "ST", "SU", "SV", "SW", "SX", "SY", "SZ", "TA", "TB", "TC", "TD", "TE", "TF", "TG", "TH", "TI", "TJ", "TK", "TL", "TM", "TN", "TO", "TP", "TQ", "TR", "TS", "TT", "TU", "TV", "TW", "TX", "TY", "TZ", "UA", "UB", "UC", "UD", "UE", "UF", "UG", "UH", "UI", "UJ", "UK", "UL", "UM", "UN", "UO", "UP", "UQ", "UR", "US", "UT", "UU", "UV", "UW", "UX", "UY", "UZ", "VA", "VB", "VC", "VD", "VE", "VF", "VG", "VH", "VI", "VJ", "VK", "VL", "VM", "VN", "VO", "VP", "VQ", "VR", "VS", "VT", "VU", "VV", "VW", "VX", "VY", "VZ", "WA", "WB", "WC", "WD", "WE", "WF", "WG", "WH", "WI", "WJ", "WK", "WL", "WM", "WN", "WO", "WP", "WQ", "WR", "WS", "WT", "WU", "WV", "WW", "WX", "WY", "WZ", "XA", "XB", "XC", "XD", "XE", "XF", "XG", "XH", "XI", "XJ", "XK", "XL", "XM", "XN", "XO", "XP", "XQ", "XR", "XS", "XT", "XU", "XV", "XW", "XX", "XY", "XZ", "YA", "YB", "YC", "YD", "YE", "YF", "YG", "YH", "YI", "YJ", "YK", "YL", "YM", "YN", "YO", "YP", "YQ", "YR", "YS", "YT", "YU", "YV", "YW", "YX", "YY", "YZ", "ZA", "ZB", "ZC", "ZD", "ZE", "ZF", "ZG", "ZH", "ZI", "ZJ", "ZK", "ZL", "ZM", "ZN", "ZO", "ZP", "ZQ", "ZR", "ZS", "ZT", "ZU", "ZV", "ZW", "ZX", "ZY", "ZZ"]); export const addressSchemaOut = z.object({street: z.string(), city: z.string(), state: z.string().optional(), postal_code: z.string(), country: z.union([z.literal(""), systemCountries]).optional(), second_line: z.string().optional(), name: z.string().nullable().optional()}); export const fieldType = z.enum(["text", "number", "currency", "date", "boolean", "single_select", "multi_select", "link", "paragraph"]); export const customFieldAppliesToType = z.enum(["invoice", "bill", "direct_expense", "journal_entry", "intercompany_journal_entry", "vendor_prepayment", "vendor_credit", "vendor_payment", "vendor_refund", "customer_payment", "customer_prepayment", "customer_refund", "customer_deposit", "currency_revaluation", "contract", "fixed_asset", "customer", "vendor", "account", "company", "sales_order", "purchase_order", "cash_sale", "customer_credit", "quote"]); export const layer = z.enum(["transaction", "entry"]); export const appliesToItemSchema = z.object({type: customFieldAppliesToType, layer: layer.optional(), is_active: z.boolean().optional(), is_required: z.boolean().optional()}); export const customFieldSchemaOut = z.object({id: z.number().int(), company_id: z.number().int().nullable().optional(), company_ids: z.array(z.number().int()).nullable().optional(), name: z.string(), description: z.string().nullable(), helper_text: z.string().nullable(), field_type: fieldType, applies_to: z.array(appliesToItemSchema), default_value: z.union([z.string(), z.array(z.string())]).nullable().optional(), options: z.array(z.string()).nullable(), is_active: z.boolean().nullable()}); export const customFieldValueSchemaOut = z.object({id: z.number().int(), custom_field_id: z.number().int(), custom_field_name: z.string(), custom_field_type: z.string(), custom_field_value_id: z.number().int(), value: z.unknown(), created_at: z.string(), updated_at: z.string()}); export const customFieldValuePairOutputSchema = z.object({field: customFieldSchemaOut, value: customFieldValueSchemaOut.nullable().optional()}); export const taxRegistrationNumberEntry = z.object({type: z.string(), number: z.string(), region: z.string().nullable().optional()}); export const taxRegistrationNumbersSnapshot = z.object({company: z.array(taxRegistrationNumberEntry).optional(), counterparty: z.array(taxRegistrationNumberEntry).optional()}); export const recordTaxMetadata = z.record(z.string(), z.record(z.string(), z.unknown())); export const taxResultType = z.enum(["SALES_TAX", "VAT", "GST", "NONE"]); export const recordSalesTaxDataOut = z.object({}); export const recordVatDataOut = z.object({country: z.string().nullable().optional(), supply_date: z.string().nullable().optional(), tax_registration_numbers: taxRegistrationNumbersSnapshot.nullable().optional()}); export const gstSupplyCategory = z.enum(["INTRA_STATE", "INTER_STATE"]); export const recordGstDataOut = z.object({country: z.string().nullable().optional(), supply_category: gstSupplyCategory.nullable().optional(), place_of_supply: z.string().max(2).nullable().optional(), supply_date: z.string().nullable().optional(), tax_registration_numbers: taxRegistrationNumbersSnapshot.nullable().optional()}); export const recordNoneTaxDataOut = z.object({}); export const recordTaxContextOut = z.object({regime: taxResultType, data: z.union([recordSalesTaxDataOut, recordVatDataOut, recordGstDataOut, recordNoneTaxDataOut])}); export const integrationProviderType = z.enum(["bill_com", "ramp", "zoho", "fivetran", "stripe", "finch", "hubspot", "brex", "cubby", "avalara", "deel", "tax1099", "sitelink", "postgresql", "qlik", "power_bi", "snowflake", "avidxchange", "concur", "salesforce", "hmrc", "rippling", "monday", "airwallex", "pleo", "tipalti", "addepar", "moss", "data_warehouse", "external", "anrok", "kintsugi", "numeral"]); export const migrationProviderType = z.enum(["quickbooks", "xero", "stripe", "netsuite_rutter", "sage_50_rutter", "sage_50", "qbd"]); export const externalIntegrationSourceOut = z.object({integration_type: z.union([integrationProviderType, migrationProviderType, z.string()]), external_integration_url: z.string().nullable()}); export const integrationProviderSchemaOut = z.object({id: z.number().int(), name: z.string(), integration_type: z.union([integrationProviderType, z.string()]), logo_url: z.string().nullable().optional(), website: z.string().nullable().optional(), description: z.string().nullable().optional(), category: z.string().nullable().optional()}); export const integrationRemoteRecordSchemaOut = z.object({transactional_date: z.string().nullable().optional(), external_source: externalIntegrationSourceOut.nullable().optional(), id: z.number().int(), source_id: z.string(), connection_id: z.number().int().nullable().optional(), integration_id: z.number().int().nullable().optional(), integration_name: z.string().nullable().optional(), integration_provider: integrationProviderSchemaOut.nullable().optional(), url: z.string().nullable().optional()}); export const publicAttachmentSchemaOut = z.object({id: z.number().int(), file_name: z.string(), file_size: z.number().int(), download_url: z.string().nullable().optional()}); export const publicRecordClassificationsSchemaOut = z.object({id: z.number().int(), name: z.string(), line_id: z.number().int(), line_name: z.string(), parent_classification_id: z.number().int().nullable().optional(), parent_classification_line_id: z.number().int().nullable().optional()}); export const auditActorSchemaOut = z.object({actor_type: z.string().nullable().optional(), email: z.string().nullable().optional(), first_name: z.string().nullable().optional(), last_name: z.string().nullable().optional(), via: z.string().nullable().optional(), agent_id: z.number().int().nullable().optional(), agent_name: z.string().nullable().optional(), timestamp: z.string().nullable().optional()}); export const approverDictSchema = z.object({id: z.number().int(), first_name: z.string(), last_name: z.string(), email: z.string(), full_name: z.string(), avatar_url: z.string().nullable().optional()}); export const rejectedBySchema = z.object({id: z.number().int(), first_name: z.string(), last_name: z.string(), email: z.string(), full_name: z.string(), rejection_reason: z.string().nullable()}); export const gstComponentType = z.enum(["CGST", "SGST", "IGST", "CESS", "GST", "PST", "HST", "QST"]); export const taxFamily = z.enum(["GST", "SST"]); export const taxComponentSchema = z.object({component_type: z.union([gstComponentType, taxFamily]), rate: z.string(), amount: z.string(), region: z.string().nullable().optional(), position: z.number().int()}); export const itemTaxDataOut = z.object({code: z.string(), rate: z.string(), amount: z.string(), is_taxable: z.boolean().nullable().optional(), tax_exempt_amount: z.string().nullable().optional(), vat_rate_id: z.number().int().nullable().optional(), gst_tax_rate_id: z.number().int().nullable().optional(), tax_metadata: z.record(z.string(), z.unknown()).nullable().optional(), tax_components: z.array(taxComponentSchema).nullable().optional(), amount_with_tax: z.string().nullable().optional(), rate_name: z.string().nullable().optional(), rate_description: z.string().nullable().optional(), rate_type: z.string().nullable().optional(), tax_treatment: z.string().nullable().optional(), valid_to: z.string().nullable().optional()}); export const publicCashSaleItemOut = z.object({custom_fields: z.array(customFieldValuePairOutputSchema).optional(), classifications: z.array(publicRecordClassificationsSchemaOut).optional(), item_type: z.string().nullable().optional(), hsn_sac_code: z.string().nullable().optional(), tax: itemTaxDataOut.nullable().optional(), id: z.number().int(), item_id: z.number().int(), quantity: z.string(), rate: z.string(), position: z.number().int(), memo: z.string(), bank_or_undeposited_account_amount: z.string(), company_id: z.number().int().nullable().optional(), net_amount: z.string(), tax_amount: z.string(), gross_amount: z.string(), amount: z.string()}); export const systemCurrencies = z.enum(["AED", "AFN", "ALL", "AMD", "ANG", "AOA", "ARS", "AUD", "AWG", "AZN", "BAM", "BBD", "BDT", "BGN", "BHD", "BIF", "BMD", "BND", "BOB", "BRL", "BSD", "BTN", "BWP", "BYN", "BZD", "CAD", "CDF", "CHF", "CLF", "CLP", "CNY", "COP", "CRC", "CUP", "CVE", "CZK", "DJF", "DKK", "DOP", "DZD", "EGP", "ERN", "ETB", "EUR", "FJD", "FKP", "GBP", "GEL", "GHS", "GIP", "GMD", "GNF", "GTQ", "GYD", "HKD", "HNL", "HTG", "HUF", "IDR", "ILS", "INR", "IQD", "IRR", "ISK", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LYD", "MAD", "MDL", "MGA", "MKD", "MMK", "MNT", "MOP", "MRU", "MUR", "MVR", "MWK", "MXN", "MYR", "MZN", "NAD", "NGN", "NIO", "NOK", "NPR", "NZD", "OMR", "PAB", "PEN", "PGK", "PHP", "PKR", "PLN", "PYG", "QAR", "RON", "RSD", "RUB", "RWF", "SAR", "SBD", "SCR", "SDG", "SEK", "SGD", "SHP", "SLL", "SOS", "SRD", "STN", "SVC", "SYP", "SZL", "THB", "TJS", "TMT", "TND", "TOP", "TRY", "TTD", "TWD", "TZS", "UAH", "UGX", "USD", "UYU", "UZS", "VES", "VND", "VUV", "WST", "XAF", "XAG", "XAU", "XCD", "XDR", "XOF", "XPD", "XPF", "XPT", "YER", "ZAR", "ZMW", "ZWL"]); export const recordStatus = z.enum(["draft", "posted", "archived"]); export const coreConstantsRecordStatusRecordStatus = z.enum(["draft", "posted", "archived"]); export const customerDepositDataPublicSchema = z.object({number: z.number().int(), date: z.string(), amount: z.number(), memo: z.string(), record_status: coreConstantsRecordStatusRecordStatus}); export const publicCashSaleSchemaOut = z.object({bill_to_address: z.string(), ship_to_address: z.string(), billing_address: addressSchemaOut.nullable().optional(), shipping_address: addressSchemaOut.nullable().optional(), custom_fields: z.array(customFieldValuePairOutputSchema).optional(), supply_date: z.string().nullable(), place_of_supply: z.string().max(2).nullable().optional(), tax_registration_numbers: taxRegistrationNumbersSnapshot.nullable().optional(), tax_metadata: recordTaxMetadata.nullable().optional(), tax: recordTaxContextOut.nullable(), integration_remote_records: z.array(integrationRemoteRecordSchemaOut).optional(), attachments: z.array(publicAttachmentSchemaOut).optional(), classifications: z.array(publicRecordClassificationsSchemaOut).optional(), transaction_ids: z.array(z.number().int()), bank_match_status: z.string().nullable().optional(), reconciliation_status: z.string().nullable().optional(), created_by: auditActorSchemaOut.nullable().optional(), updated_by: auditActorSchemaOut.nullable().optional(), approval_status: z.string().nullable().optional(), next_approvers: z.array(approverDictSchema).nullable().optional(), rejected_by: rejectedBySchema.nullable().optional(), internal_id: z.number().int(), number: z.number().int(), code: z.string().nullable().optional(), items: z.array(publicCashSaleItemOut), company_id: z.number().int(), company_name: z.string(), company_currency: z.string(), customer_id: z.number().int(), customer_name: z.string(), account_number: z.number().int().nullable(), amount: z.string(), memo: z.string(), check_number: z.string(), date: z.string(), transaction_date: z.string(), currency_iso_4217_code: systemCurrencies, exchange_rate: z.string(), undeposited_funds_currency: systemCurrencies.nullable(), bank_or_undeposited_account_amount: z.string(), payment_method_id: z.number().int().nullable().optional(), record_status: recordStatus, customer_deposits: z.array(customerDepositDataPublicSchema).optional(), recurring_record_id: z.number().int().nullable().optional(), created_at: z.string(), updated_at: z.string()}); export const validateResponse = async ( schema: { readonly '~standard': { readonly validate: (value: unknown) => ({ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }) | Promise<{ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }> } }, value: unknown ): Promise => { const result = await schema['~standard'].validate(value) if (result.issues !== undefined) { const detail = result.issues .map(({ message, path }) => path?.length ? `${path.map((segment) => String(typeof segment === 'object' ? segment.key : segment)).join('.')}: ${message}` : message ) .join('; ') throw new Error(`Response does not match the schema: ${detail}`, { cause: { issues: result.issues } }) } return result.value }; /** * Update CashSale record * * PUT /public/v1/cash-sales/{record_number}/ */ export const updateApiPublicV1CashSalesRecordNumber = async (args: UpdateApiPublicV1CashSalesRecordNumberArgs, options?: UpdateApiPublicV1CashSalesRecordNumberOptions) => { const {baseUrl = "https://api.dualentry.com", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") if (args['Idempotency-Key'] != null) headers.set("Idempotency-Key", String(args['Idempotency-Key'])) const url = `${baseUrl.replace(/\/+$/, '')}/public/v1/cash-sales/${encodeURIComponent(String(args.record_number))}/${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PUT", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return validateResponse(publicCashSaleSchemaOut, await res.json()) };