import { HOST, Paginacion, paginacionToSearchParams, Paging, } from "./common.js"; export interface OrderDto { SituacionOrden?: null | string; Date: string; Total: number; TotalDiscount?: number; PaidTotal?: number; FinancialSurcharge?: number; WarehouseCode?: null | string; SellerCode?: null | string; TransportCode?: null | string; SaleConditionCode?: number; InvoiceCounterfoil?: number; PriceListNumber?: number; AgreedWithSeller?: boolean; IvaIncluded?: boolean; InternalTaxIncluded?: boolean; OrderID: string; OrderNumber: string; ValidateTotalWithPaidTotal?: boolean; Comment?: null | string; Customer: CustomerDto; CancelOrder?: boolean; OrderItems: OrderItemDto[]; Shipping?: null | ShippingDto; CashPayment?: null | CashPaymentDto; CashPayments?: CashPaymentDto[] | null; Payments?: PaymentDto[] | null; } export interface CustomerDto { CustomerID: number; Code?: null | string; DocumentType?: null | string; DocumentNumber?: null | string; IVACategoryCode: string; PayInternalTax?: boolean; User: string; Email: string; FirstName?: null | string; LastName?: null | string; BusinessName?: null | string; Street?: null | string; HouseNumber?: null | string; Floor?: null | string; Apartment?: null | string; City?: null | string; ProvinceCode: string; PostalCode?: null | string; PhoneNumber1?: null | string; PhoneNumber2?: null | string; Bonus?: number; MobilePhoneNumber?: null | string; WebPage?: null | string; BusinessAddress?: null | string; Comments?: null | string; NumberListPrice?: number; Removed?: boolean; DateUpdate?: string; Disable?: string; } export interface OrderItemDto { ProductCode: string; SKUCode?: null | string; VariantCode?: null | string; Description: string; VariantDescription?: null | string; Quantity: number; UnitPrice: number; DiscountPercentage?: number; } export interface ShippingDto { ShippingID: number; ShippingCode?: null | string; Street?: null | string; HouseNumber?: null | string; Floor?: null | string; Apartment?: null | string; City?: null | string; ProvinceCode?: null | string; PostalCode?: null | string; PhoneNumber1?: null | string; PhoneNumber2?: null | string; ShippingCost?: number; DeliversMonday?: null | string; DeliversTuesday?: null | string; DeliversWednesday?: null | string; DeliversThursday?: null | string; DeliversFriday?: null | string; DeliversSaturday?: null | string; DeliversSunday?: null | string; DeliveryHours?: null | string; } export interface CashPaymentDto { PaymentID?: number; PaymentMethod: string; PaymentTotal?: number; } export interface PaymentDto { PaymentId: number; TransactionDate: string; AuthorizationCode?: null | string; TransactionNumber?: null | string; Installments: number; InstallmentAmount: number; Total: number; CardCode: string; CardPlanCode: string; VoucherNo: number; CardPromotionCode?: null | string; } export interface OrderResponse {} export async function order( token: string, order: OrderDto ): Promise { const res = await fetch(`${HOST}/api/Aperture/order`, { method: "POST", headers: { accesstoken: token, "content-type": "application/json", }, body: JSON.stringify(order), }); const json = await res.json(); console.debug(json); if (!json.isOk) { throw new Error(`Tango: ${json.Message}`); } return json; }