import { useI18n } from 'vue-i18n' import { isAfterJuly28 } from '@/utils/dateUtils' import { useFilters } from '../../../composables/useFilters' import { computed } from 'vue' export const useReportConst = () => { const { t } = useI18n() const { numberFormat } = useFilters() const groupCurrency1 = (type: string) => { if (type == 'GBP') return '£' if (type == 'USD') return '$' if (type == 'EUR') return '€' if (type == 'USC') return '¢' return '$' } const groupTypeName = (type: string | number) => { if (type == '1') return t('AccountType.ClassicAccount') if (type == '2') return t('AccountType.SeniorAccount') if (type == '3') return isAfterJuly28() ? '--' : t('AccountType.AgencyAccount') if (type == '5') return t('AccountType.SpeedAccount') if (type == '6') return t('AccountType.SpeedAccount') if (type == '7') return t('AccountType.StandardAccount') if (type == '8') return t('AccountType.CentAccount') return '--' } const platformOptions = [ { text: 'MT4', value: 'MT4' }, { text: 'MT5', value: 'MT5' }, ] const customTypeList = computed(() => [ { text: t('AccountType.ClassicAccount'), value: 1 }, { text: t('AccountType.ClassicAccount'), value: 2 }, !isAfterJuly28() ? { text: t('AccountType.ClassicAccount'), value: 3 } : '', { text: t('AccountType.ClassicAccount'), value: 7 }, { text: t('AccountType.ClassicAccount'), value: 8 }, ].filter((v) => !!v)) const columnList = computed(() => ({ '1': [ { prop: 'ibNo', label: t('Label.AttributionNumber') }, { prop: 'login', label: t('Label.TradingAccount') }, { prop: 'name', label: t('Label.Name') }, { prop: 'deposit', label: t('Label.Deposit'), formatter: ({ row }) => { return `${groupCurrency1(row.currency)}${numberFormat(row.deposit ?? '0')}` }, }, { prop: 'withdrawal', label: t('Label.Withdrawals'), formatter: ({ row }) => { return `${groupCurrency1(row.currency)}${numberFormat(row.withdrawal ?? '0')}` }, }, { prop: 'credit', label: t('Label.Credit'), formatter: ({ row }) => { return `${groupCurrency1(row.currency)}${numberFormat(row.credit ?? '0')}` }, }, { prop: 'closeTime', label: t('Label.CloseTime') }, ], '2': [ { prop: 'ibNo', label: t('Label.AttributionNumber') }, { prop: 'login', label: t('Label.TradingAccount') }, { prop: 'groupType', label: t('Label.Type'), type: 'tag', tagMap: { 1: t('AccountType.ClassicAccount'), 2: t('AccountType.SeniorAccount'), 3: !isAfterJuly28() ? t('AccountType.AgencyAccount') : '', 4: t('AccountType.ProfessionalAccount'), 5: t('AccountType.SpeedAccount'), 6: t('AccountType.SpeedAccount'), 7: t('AccountType.StandardAccount'), 8: t('AccountType.CentAccount'), }, }, { prop: 'symbol', label: t('Label.Varieties') }, { prop: 'volume', label: t('Label.Volume'), formatter: ({ row }) => { return `${numberFormat(row.volume ?? '0')}/${t('Label.Lot')}` }, }, { prop: 'rebateAmount', label: t('Label.rebateAmount'), formatter: ({ row }) => { return `${groupCurrency1(row.currency)}${numberFormat(row.rebateAmount ?? '0')}` }, }, { prop: 'rebatePoint', label: t('Label.rebatePoint'), formatter: ({ row }) => { return `${groupCurrency1(row.currency)}${numberFormat(row.rebatePoint ?? '0')}/${t('Label.Lot')}` }, }, { prop: 'commissionAmount', label: t('Label.commissionAmount'), formatter: ({ row }) => { return `${groupCurrency1(row.currency)}${numberFormat(row.commissionAmount ?? '0')}` }, }, { prop: 'commissionPoint', label: t('Label.commissionPoint'), formatter: ({ row }) => { return `${groupCurrency1(row.currency)}${numberFormat(row.commissionPoint ?? '0')}/${t('Label.Lot')}` }, }, { prop: 'openTime', label: t('Label.OpenTime') }, { prop: 'closeTime', label: t('Label.CloseTime') }, ], '3_1': [ { prop: 'ibNo', label: t('Label.AttributionNumber') }, { prop: 'login', label: t('Label.TradingAccount') }, { prop: 'order', label: t('Label.OrderNumber') }, { prop: 'platform', label: t('Label.Platform') }, { prop: 'cmdName', label: t('Label.Type') }, { prop: 'symbol', label: t('Label.Varieties') }, { prop: 'openPrice', label: t('Label.OpenPrice'), formatter: ({ row }) => { return `${numberFormat(row.openPrice ?? '0')}` }, }, { prop: 'openTime', label: t('Label.OpenTime') }, { prop: 'closePrice', label: t('Label.ClosePrice'), formatter: ({ row }) => { return `${numberFormat(row.closePrice ?? '0')}` }, }, { prop: 'closeTime', label: t('Label.CloseTime') }, { prop: 'tp', label: t('Label.EP') }, { prop: 'sl', label: t('Label.EL') }, { prop: 'commission', label: t('Label.OutsideCommission'), formatter: ({ row }) => { return `${numberFormat(row.commission ?? '0')}` }, }, { prop: 'volume', label: t('Label.Volume'), formatter: ({ row }) => { return `${numberFormat(row.volume ?? '0')}/${t('Label.Lot')}` }, }, { prop: 'storage', label: t('Label.StorageFee'), formatter: ({ row }) => { return `${groupCurrency1(row.currency)}${numberFormat(row.storage ?? '0')}` }, }, { prop: 'profit', label: t('Label.ProfitLoss'), formatter: ({ row }) => { return `${groupCurrency1(row.currency)}${numberFormat(row.profit ?? '0')}` }, }, { prop: 'totalProfit', label: t('Label.TotalProfitLoss'), formatter: ({ row }) => { return `${groupCurrency1(row.currency)}${numberFormat(row.totalProfit ?? '0')}` }, }, ], '3_2': [ { prop: 'ibNo', label: t('Label.AttributionNumber') }, { prop: 'login', label: t('Label.TradingAccount') }, { prop: 'order', label: t('Label.OrderNumber') }, { prop: 'platform', label: t('Label.Platform') }, { prop: 'cmdName', label: t('Label.Type') }, { prop: 'symbol', label: t('Label.Varieties') }, { prop: 'openPrice', label: t('Label.OpenPrice'), formatter: ({ row }) => { return `${numberFormat(row.openPrice ?? '0')}` }, }, { prop: 'openTime', label: t('Label.OpenTime') }, { prop: 'closePrice', label: t('Label.ClosePrice'), formatter: ({ row }) => { return `${numberFormat(row.closePrice ?? '0')}` }, }, { prop: 'closeTime', label: t('Label.CloseTime') }, { prop: 'tp', label: t('Label.EP') }, { prop: 'sl', label: t('Label.EL') }, { prop: 'commission', label: t('Label.OutsideCommission'), formatter: ({ row }) => { return `${numberFormat(row.commission ?? '0')}` }, }, { prop: 'volume', label: t('Label.Volume'), formatter: ({ row }) => { return `${numberFormat(row.volume ?? '0')}/${t('Label.Lot')}` }, }, { prop: 'storage', label: t('Label.StorageFee'), formatter: ({ row }) => { return `${groupCurrency1(row.currency)}${numberFormat(row.storage ?? '0')}` }, }, { prop: 'profit', label: t('Label.ProfitLoss'), formatter: ({ row }) => { return `${groupCurrency1(row.currency)}${numberFormat(row.profit ?? '0')}` }, }, { prop: 'totalProfit', label: t('Label.TotalProfitLoss'), formatter: ({ row }) => { return `${groupCurrency1(row.currency)}${numberFormat(row.totalProfit ?? '0')}` }, }, ], '3_3': [ { prop: 'ibNo', label: t('Label.AttributionNumber') }, { prop: 'login', label: t('Label.TradingAccount') }, { prop: 'order', label: t('Label.OrderNumber') }, { prop: 'platform', label: t('Label.Platform') }, { prop: 'cmdName', label: t('Label.Type') }, { prop: 'symbol', label: t('Label.Varieties') }, { prop: 'openPrice', label: t('Label.OpenPrice'), formatter: ({ row }) => { return `${numberFormat(row.openPrice ?? '0')}` }, }, { prop: 'openTime', label: t('Label.OpenTime') }, { prop: 'closePrice', label: t('Label.ClosePrice'), formatter: ({ row }) => { return `${numberFormat(row.closePrice ?? '0')}` }, }, { prop: 'closeTime', label: t('Label.CloseTime') }, { prop: 'tp', label: t('Label.EP') }, { prop: 'sl', label: t('Label.EL') }, { prop: 'commission', label: t('Label.OutsideCommission'), formatter: ({ row }) => { return `${numberFormat(row.commission ?? '0')}` }, }, { prop: 'volume', label: t('Label.Volume'), formatter: ({ row }) => { return `${numberFormat(row.volume ?? '0')}/${t('Label.Lot')}` }, }, { prop: 'storage', label: t('Label.StorageFee'), formatter: ({ row }) => { return `${groupCurrency1(row.currency)}${numberFormat(row.storage ?? '0')}` }, }, { prop: 'profit', label: t('Label.ProfitLoss'), formatter: ({ row }) => { return `${groupCurrency1(row.currency)}${numberFormat(row.profit ?? '0')}` }, }, { prop: 'totalProfit', label: t('Label.TotalProfitLoss'), formatter: ({ row }) => { return `${groupCurrency1(row.currency)}${numberFormat(row.totalProfit ?? '0')}` }, }, ], '3_4': [ { prop: 'ibNo', label: t('Label.AttributionNumber') }, { prop: 'login', label: t('Label.TradingAccount') }, { prop: 'order', label: t('Label.OrderNumber') }, { prop: 'platform', label: t('Label.Platform') }, { prop: 'cmdName', label: t('Label.Type') }, { prop: 'symbol', label: t('Label.Varieties') }, { prop: 'openPrice', label: t('Label.OpenPrice'), formatter: ({ row }) => { return `${numberFormat(row.openPrice ?? '0')}` }, }, { prop: 'openTime', label: t('Label.OpenTime') }, { prop: 'tp', label: t('Label.EP') }, { prop: 'sl', label: t('Label.EL') }, { prop: 'volume', label: t('Label.Volume'), formatter: ({ row }) => { return `${numberFormat(row.volume ?? '0')}/${t('Label.Lot')}` }, }, { prop: 'storage', label: t('Label.StorageFee'), formatter: ({ row }) => { return `${groupCurrency1(row.currency)}${numberFormat(row.storage ?? '0')}` }, }, { prop: 'profit', label: t('Label.ProfitLoss'), formatter: ({ row }) => { return `${groupCurrency1(row.currency)}${numberFormat(row.profit ?? '0')}` }, }, ], '4': [ { prop: 'cId', label: t('Label.CidAccount') }, { prop: 'ibNo', label: t('Label.AttributionNumber') }, { prop: 'login', label: t('Label.TradingAccount') }, { prop: 'groupType', label: t('Label.AccountType'), formatter: ({ row }) => { return groupTypeName(row.groupType) }, }, { prop: 'name', label: t('Label.Name') }, { prop: 'platform', label: t('Label.Platform') }, { prop: 'leverage', label: t('Label.Leverage') }, { prop: 'margin', label: t('Label.margin') }, { prop: 'commission', label: t('Label.OutsideCommission'), formatter: ({ row }) => { return `$${row.commission ?? '0'}` }, }, { prop: 'credit', label: t('Label.Credit'), formatter: ({ row }) => { return `$${row.credit ?? '0'}` }, }, { prop: 'balance', label: t('Label.Amount'), formatter: ({ row }) => { return `$${row.balance ?? '0'}` }, }, { prop: 'equity', label: t('Label.equity'), formatter: ({ row }) => { return `$${row.equity ?? '0'}` }, }, { prop: 'floating', label: t('Label.FloatingPL') }, { prop: 'registration', label: t('Label.RegistrationTime') }, ], '5': [ { prop: 'ibNo', label: t('Label.IBAccount') }, { prop: 'pIbNo', label: t('Label.AttributionNumber') }, { prop: 'name', label: t('Label.Name') }, { prop: 'addTime', label: t('Label.RegistrationTime') }, ], '6': [ { prop: 'ibNo', label: t('Label.IBAccount') }, { prop: 'typeName', label: t('Label.OperatingMode') }, { prop: 'balanceTypeName', label: t('Label.CommissionType') }, { prop: 'amount', label: t('Label.AmountMoney'), formatter: ({ row }) => { return numberFormat(row.amount ?? '0') }, }, { prop: 'addTime', label: t('Label.ProcessingDate') }, ], '7': [ { prop: 'cId', label: 'CID' }, { prop: 'ibNo', label: t('Label.IBAccount') }, { prop: 'name', label: t('Label.Name') }, { prop: 'login', label: t('Label.TradingAccount') }, { prop: 'platform', label: t('Label.Platform') }, { prop: 'fxVolume', label: t('Label.fxVolume') }, { prop: 'cfdVolume', label: t('Label.cfdVolume') }, { prop: 'indexVolume', label: t('Label.indexVolume') }, { prop: 'metalVolume', label: t('Label.metalVolume') }, ], '24': [ { prop: 'cId', label: t('Label.CidAccount') }, { prop: 'ticket', label: t('Label.OrderNumber') }, { prop: 'login', label: t('Label.TradingAccount') }, { prop: 'symbol', label: t('Label.Varieties') }, { prop: 'openTime', label: t('Label.OpenTime') }, { prop: 'closeTime', label: t('Label.CloseTime') }, { prop: 'customType', label: t('Label.Type'), type: 'tag', tagMap: { 1: t('AccountType.ClassicAccount'), 2: t('AccountType.SeniorAccount'), 5: t('AccountType.SpeedAccount'), 6: t('AccountType.NewSpeedAccount'), 7: t('AccountType.StandardAccount'), 8: t('AccountType.CentAccount'), }, }, { prop: 'point', label: t('Label.Rebates') }, { prop: 'pointValue', label: t('Ib.Report.Title9') }, { prop: 'volume', label: t('Label.Volume'), formatter: ({ row }) => { return `${numberFormat(row.volume ?? '0')}/${t('Label.Lot')}` }, }, { prop: 'rebate', label: t('Label.Commission'), formatter: ({ row }) => { return `$${row.rebate ?? '0'}` }, }, { prop: 'ibNo', label: t('Label.AgentNumber') }, { prop: 'platform', label: t('Label.Platform') }, ], })) const mobileList = computed(() => ({ '1': [ { prop: 'ibNo', label: t('Label.AttributionNumber') }, { prop: 'login', label: t('Label.TradingAccount') }, { prop: 'name', label: t('Label.Name') }, ], '2': [ { prop: 'ibNo', label: t('Label.AttributionNumber') }, { prop: 'login', label: t('Label.TradingAccount') }, { prop: 'groupType', label: t('Label.Type'), type: 'tag', tagMap: { 1: t('AccountType.ClassicAccount'), 2: t('AccountType.SeniorAccount'), 3: !isAfterJuly28() ? t('AccountType.AgencyAccount') : '', 4: t('AccountType.ProfessionalAccount'), 5: t('AccountType.SpeedAccount'), 6: t('AccountType.SpeedAccount'), 7: t('AccountType.StandardAccount'), 8: t('AccountType.CentAccount'), }, }, ], '3_1': [ { prop: 'ibNo', label: t('Label.AttributionNumber') }, { prop: 'login', label: t('Label.TradingAccount') }, { prop: 'order', label: t('Label.OrderNumber') }, ], '3_2': [ { prop: 'ibNo', label: t('Label.AttributionNumber') }, { prop: 'login', label: t('Label.TradingAccount') }, { prop: 'order', label: t('Label.OrderNumber') }, ], '3_3': [ { prop: 'ibNo', label: t('Label.AttributionNumber') }, { prop: 'login', label: t('Label.TradingAccount') }, { prop: 'order', label: t('Label.OrderNumber') }, ], '3_4': [ { prop: 'ibNo', label: t('Label.AttributionNumber') }, { prop: 'login', label: t('Label.TradingAccount') }, { prop: 'order', label: t('Label.OrderNumber') }, ], '4': [ { prop: 'cId', label: t('Label.CidAccount') }, { prop: 'ibNo', label: t('Label.AttributionNumber') }, { prop: 'login', label: t('Label.TradingAccount') }, ], '5': [ { prop: 'ibNo', label: t('Label.IBAccount') }, { prop: 'pIbNo', label: t('Label.AttributionNumber') }, { prop: 'name', label: t('Label.Name') }, ], '6': [ { prop: 'ibNo', label: t('Label.IBAccount') }, { prop: 'typeName', label: t('Label.OperatingMode') }, { prop: 'balanceTypeName', label: t('Label.CommissionType') }, ], '7': [ { prop: 'cId', label: 'CID' }, { prop: 'ibNo', label: t('Label.IBAccount') }, { prop: 'name', label: t('Label.Name') }, ], '24': [ { prop: 'cId', label: t('Label.CidAccount') }, { prop: 'ticket', label: t('Label.OrderNumber') }, { prop: 'login', label: t('Label.TradingAccount') }, ], })) return { columnList, mobileList, platformOptions, customTypeList, groupCurrency1, groupTypeName } }