
export type AllowanceItemInput = {
    // 流水
    ItemSeq: number,
    // 商品名稱
    ItemName: string,
    // 數量
    ItemCount: number,
    // 單位
    ItemWord: string,
    // 單價
    ItemPrice: number,
    // 稅別
    // 1: 應稅
    // 2: 零稅率
    // 3: 免稅
    ItemTaxType: "1" | "2" | "3",
    // 商品小計算
    ItemAmount: number,
}

export type AllowanceInput = {
    // 特店編號
    MerchantID: string,
    // 發票號碼
    InvoiceNo: string,
    // 發票日期
    InvoiceDate: string,
    // 通知類別
    AllowanceNotify: "S" | "E" | "A" | "N",
    // 客戶名稱
    CustomerName: string,
    // 通知電子郵件信箱
    NotifyMail: string,
    // 通知手機號碼
    NotifyPhone: string,
    // 折讓金額
    AllowanceAmount: number,
    Items: AllowanceItemInput[]
}


export type AllowanceResp = {
    MerchantID: string,
    RqHeader: {
        Timestamp: string,
    }
    TransCode: number,
    TransMsg: string,
    Data: string,
    DecryptData: {
        RtnCode: number,
        RtnMsg: string,
        IA_Allow_No: string,
        IA_Invoice_No: string,
        IA_Date: string,
        IA_Remain_Allowance_Amt: string,
    }
}


export type AllowanceInvalidInput = {
    MerchantID: string,
    InvoiceNo: string,
    AllowanceNo: string,
    Reason: string,
}

export type AllowanceInvalidResp = RepModel & {
    DecryptData: {
        RtnCode: number,
        RtnMsg: string,
        IA_Allow_No: string,
    }
}

export type AllowanceQueryInput = {
    // 特店編號
    MerchantID: string,
    // 查詢類別
    // 0: 依折讓單號
    // 1: 依發票號碼 + 發票日期
    // 2: 依發票號碼 + 發票折讓
    SearchType: "0" | "1" | "2"

    // 折讓單號
    AllowanceNo: string,
    // 發票號碼
    InvoiceNo: string,
    // 發票日期
    Date: string
}

export type AllowanceInfo = {
    ChannelPartner?: "1",
    // 折讓單號
    IA_Allow_No: string,
    // 折讓聯絡信箱
    IA_Check_Send_Mail: string,
    // 折讓日期
    IA_Date: string,
    // 折讓品項
    Items: {
        // 流水
        ItemSeq: number,
        // 商品名稱
        ItemName: string,
        // 商品數量
        ItemCount: number,
        // 商品單位
        ItemWord: string,
        // 商品單價
        ItemPrice: number,
        // 商品營業稅額
        ItemRateAmt: number,
        // 1: 應稅
        // 2: 零稅率
        // 3: 免稅
        ItemTaxType: "1" | "2" | "3",
        // 商品合計
        ItemAmount: number,
    }[],
    // 折讓IP
    IA_AP: string,
    // 買受人統編
    IA_Identifier: string,
    // 折讓作廢狀態
    // 0: 未作廢
    // 1: 已作廢
    IA_Invalid_Status: "0" | "1",
    // 發票開立時間
    IA_Invoice_Issue_Date: string,
    // 發票號碼
    IA_Invoice_No: string,
    // 通知的Email
    IA_Send_Mail: string,
    // 通知的手機號碼
    IA_Send_Phone: string,
    // 營業稅額合計
    IA_Tax_Amount: number,
    // 1: 一般稅額
    // 2: 特種稅額
    // 3: 免稅
    // 4: 應稅(特種稅率)
    IA_Tax_Type: "1" | "2" | "3"| "4"
    // 金額合計(含稅)
    IA_Total_Amount: number,
    IA_Upload_Date: string,
    // 0: 未上傳
    // 1: 已上傳
    IA_Upload_Status: "0" | "1",
    // 客戶名稱
    IIS_Customer_Name: string,

}

export type AllowanceQueryOutput = {
    RtnCode: number,
    RtnMsg: string,
    AllowanceInfo: AllowanceInfo[]
}


export type GetAllowanceInvalidInput = {
    MerchantID: string,
    InvoiceNo: string,
    AllowanceNo: string,
}

export type GetAllowanceInvalidOutput = {
    RtnCode: number,
    RtnMsg: string,
    AI_Allow_Date : string,
    AI_Allow_No : string,
    AI_Buyer_Identifier : string,
    AI_Date : string,
    AI_Invoice_No : string,
    AI_Mer_ID : string,
    Reason : string,
    AI_Seller_Identifier : string,
    AI_Upload_Date : string,
    /**
     * 上傳狀態
     *  0: 未上傳
     *  1: 已上傳
     */
    AI_Upload_Status : "0" | "1",
}
