Esempio n. 1
0
        public static PayoutUserMonthlyStatementDTO Entity2ReportRowDto(this ADMIN_SaleSummaryToken entity, int year, int month)
        {
            var token = new PayoutUserMonthlyStatementDTO
            {
                Sales        = entity.total.FormatMoney(2)
                , Refund     = entity.refund.FormatMoney(2)
                , Fees       = entity.fee.FormatMoney(2)
                , RefundFees = entity.refundFee.FormatMoney(2)
                , Balance    = entity.total.SalesToBalance(entity.fee, entity.refund, entity.refundFee)
                , Year       = year
                , Month      = month
                , Currency   = entity.Entity2BaseCurrencyDto()
            };

            if (entity.SellerUserId != null)
            {
                token.SellerId = (int)entity.SellerUserId;
                token.Seller   = new BaseUserInfoDTO
                {
                    UserId     = (int)entity.SellerUserId
                    , Email    = entity.Email
                    , FullName = entity.Entity2FullName()
                };
            }

            token.LfeCommission = token.Balance.BalanceToLfeCommission();

            token.Payout = token.Balance.BalanceToPayout(token.LfeCommission);//Sales.ToPayout(token.Fees , token.Commission , token.Refund);

            if (entity.PayoutTypeId == null)
            {
                return(token);
            }

            token.PayoutSettings = new PayoutSettingsDTO
            {
                PayoutType = Utils.ParseEnum <BillingEnums.ePayoutTypes>(entity.PayoutTypeId.ToString())
                , Email    = entity.PaypalEmail
            };

            if (entity.PayoutAddressID == null)
            {
                return(token);
            }

            token.PayoutSettings.Address = String.Format("{0} {1},{2}, {3} {4}, {5}, {6} {7}", entity.AddressFirstName, entity.AddressLastName, entity.PostalCode, entity.CountryName, entity.StateName, entity.CityName, entity.Street1, entity.Street2);

            return(token);
        }
Esempio n. 2
0
        public static PayoutUserMonthlyStatementDTO Entity2ReportRowDto(this PO_MonthlyPayoutToken entity, int year, int month, BillingEnums.ePayoutStatuses status)
        {
            //var totalAuthorSales          = entity.Author_total_sales;
            //var affiliateTotalSales       = entity.Affiliate_total_sales + entity.By_Affiliate_total_sales;
            //var totalAffiliateCommission  = entity.Affiliate_total_non_rgp_commission + entity.By_Affiliate_total_net_non_rgp_sales;
            //var rgp2keep                  = entity.Author_total_rgp_sales + entity.Affiliate_total_rgp_sales + entity.By_Affiliate_total_rgp_sales;
            //var rgp2release               = entity.Author_Released_total_rgp_sales + entity.Affiliate_Released_total_net_rgp_sales + entity.By_Affiliate_Released_total_rgp_commission;
            //var totalRefunded             = entity.Author_total_refunded + entity.Affiliate_total_net_refunded + entity.By_Affiliate_total_net_refunded;
            //var totalRefundedFees         = entity.Author_fee_refunded + entity.Affiliate_fee_net_refunded + entity.By_Affiliate_fee_net_refunded;
            //var totalFees                 = entity.Author_total_non_rgp_fee + entity.Affiliate_total_net_non_rgp_fee + entity.By_Affiliate_total_net_non_rgp_fee +
            //                                entity.Author_Released_total_rgp_fee + entity.Affiliate_Released_total_net_rgp_fee + entity.By_Affiliate_Released_total_net_rgp_fee;


            //var token = new PayoutUserMonthlyStatementDTO
            //{
            //     TotalSales              = (totalAuthorSales + affiliateTotalSales).FormatMoney(2)
            //    ,Sales                   = totalAuthorSales.FormatMoney(2)
            //    ,AffiliateSales          = affiliateTotalSales.FormatMoney(2)
            //    ,RefundProgrammToHold    = rgp2keep.FormatMoney(2)
            //    ,RefundProgrammToRelease = rgp2release.FormatMoney(2)
            //    ,AffiliateCommission     = totalAffiliateCommission.FormatMoney(2)
            //    ,Refund                  = totalRefunded.FormatMoney(2)
            //    ,Fees                    = totalFees.FormatMoney(2)
            //    ,RefundFees              = totalRefundedFees.FormatMoney(2)
            //    ,Year                    = year
            //    ,Month                   = month
            //    ,Currency                = entity.Entity2BaseCurrencyDto()
            //    ,PayoutStatus            = status
            //};

            //token.AffiliateFees = token.AffiliateSales - token.AffiliateCommission;

            //var balance = token.Sales.SalesToBalance(token.Fees,token.Refund,token.RefundFees,token.AffiliateCommission,token.RefundProgrammToHold,token.RefundProgrammToRelease);

            //token.Balance = balance;

            //token.Commission = token.Balance.BalanceToLfeCommission();

            //token.Payout = token.Balance.BalanceToPayout(token.Commission);//Sales.ToPayout(token.Fees , token.Commission , token.Refund);

            var token = new PayoutUserMonthlyStatementDTO
            {
                TotalSales                = entity.TotalSales.FormatMoney(2)
                , Sales                   = entity.Author_total_sales.FormatMoney(2)
                , AffiliateSales          = entity.AffiliateTotalSales.FormatMoney(2)
                , RefundProgrammToHold    = entity.RefundProgramHold.FormatMoney(2)
                , RefundProgrammToRelease = entity.RefundProgramReleased.FormatMoney(2)
                , AffiliateCommission     = entity.AffiliateCommission.FormatMoney(2)
                , Fees          = entity.TotalFees.FormatMoney(2)
                , Refund        = entity.TotalRefunded.FormatMoney(2)
                , RefundFees    = entity.TotalRefundedFees.FormatMoney(2)
                , AffiliateFees = entity.AffiliateFees.FormatMoney(2)
                , Balance       = entity.Balance.FormatMoney(2)
                , LfeCommission = entity.LfeCommissions.FormatMoney(2)
                , Payout        = entity.Payout.FormatMoney(2)
                , Year          = year
                , Month         = month
                , Currency      = entity.Entity2BaseCurrencyDto()
                , PayoutStatus  = status
            };

            if (entity.UserId != null)
            {
                token.SellerId = (int)entity.UserId;
                token.Seller   = new BaseUserInfoDTO
                {
                    UserId     = (int)entity.UserId
                    , Email    = entity.Email
                    , FullName = entity.Entity2FullName()
                };
            }



            if (entity.PayoutTypeId == null)
            {
                return(token);
            }

            token.PayoutSettings = new PayoutSettingsDTO
            {
                PayoutType = Utils.ParseEnum <BillingEnums.ePayoutTypes>(entity.PayoutTypeId.ToString())
                , Email    = entity.PaypalEmail
            };

            if (entity.PayoutAddressID == null)
            {
                return(token);
            }

            token.PayoutSettings.Address = String.Format("{0} {1},{2}, {3} {4}, {5}, {6} {7}", entity.PayoutFirstName, entity.PayoutLastName, entity.PostalCode, entity.CountryName, entity.StateName, entity.CityName, entity.Street1, entity.Street2);

            return(token);
        }