"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const sequelize_1=require("sequelize");class gatewayPayout extends sequelize_1.Model{static initModel(e){return gatewayPayout.init({id:{type:sequelize_1.DataTypes.UUID,defaultValue:sequelize_1.DataTypes.UUIDV4,primaryKey:!0,allowNull:!1},merchantId:{type:sequelize_1.DataTypes.UUID,allowNull:!1,validate:{isUUID:{args:4,msg:"merchantId: Must be a valid UUID"}}},transactionId:{type:sequelize_1.DataTypes.UUID,allowNull:!0},payoutId:{type:sequelize_1.DataTypes.STRING(64),allowNull:!1},amount:{type:sequelize_1.DataTypes.DECIMAL(30,8),allowNull:!1,get(){const e=this.getDataValue("amount");return e?parseFloat(e.toString()):0}},currency:{type:sequelize_1.DataTypes.STRING(20),allowNull:!1},walletType:{type:sequelize_1.DataTypes.STRING(20),allowNull:!1,defaultValue:"FIAT"},status:{type:sequelize_1.DataTypes.ENUM("PENDING","PROCESSING","COMPLETED","FAILED","CANCELLED"),allowNull:!1,defaultValue:"PENDING"},periodStart:{type:sequelize_1.DataTypes.DATE,allowNull:!1},periodEnd:{type:sequelize_1.DataTypes.DATE,allowNull:!1},grossAmount:{type:sequelize_1.DataTypes.DECIMAL(30,8),allowNull:!1,defaultValue:0,get(){const e=this.getDataValue("grossAmount");return e?parseFloat(e.toString()):0}},feeAmount:{type:sequelize_1.DataTypes.DECIMAL(30,8),allowNull:!1,defaultValue:0,get(){const e=this.getDataValue("feeAmount");return e?parseFloat(e.toString()):0}},netAmount:{type:sequelize_1.DataTypes.DECIMAL(30,8),allowNull:!1,defaultValue:0,get(){const e=this.getDataValue("netAmount");return e?parseFloat(e.toString()):0}},paymentCount:{type:sequelize_1.DataTypes.INTEGER,allowNull:!1,defaultValue:0},refundCount:{type:sequelize_1.DataTypes.INTEGER,allowNull:!1,defaultValue:0},metadata:{type:sequelize_1.DataTypes.JSON,allowNull:!0,get(){const e=this.getDataValue("metadata");return"string"==typeof e?JSON.parse(e):e}}},{sequelize:e,modelName:"gatewayPayout",tableName:"gateway_payout",timestamps:!0,indexes:[{name:"PRIMARY",unique:!0,using:"BTREE",fields:[{name:"id"}]},{name:"gatewayPayoutIdUnique",unique:!0,using:"BTREE",fields:[{name:"payoutId"}]},{name:"gatewayPayoutMerchantIdFkey",using:"BTREE",fields:[{name:"merchantId"}]},{name:"gatewayPayoutTransactionIdFkey",using:"BTREE",fields:[{name:"transactionId"}]},{name:"gatewayPayoutStatusIdx",using:"BTREE",fields:[{name:"status"}]}]})}static associate(e){gatewayPayout.belongsTo(e.gatewayMerchant,{as:"merchant",foreignKey:"merchantId",onDelete:"CASCADE",onUpdate:"CASCADE"});gatewayPayout.belongsTo(e.transaction,{as:"transaction",foreignKey:"transactionId",onDelete:"SET NULL",onUpdate:"CASCADE"})}}exports.default=gatewayPayout;