public static VendorPayoutListModel ToListModel(this VendorPayout Payout, IOrderService _orderService)
 {
     var model = new VendorPayoutListModel()
     {
         CommissionPercentage = Payout.CommissionPercentage,
         Id = Payout.Id,
         OrderId = Payout.OrderId,
         PayoutDate = Payout.PayoutDate,
         PayoutStatus = Payout.PayoutStatus,
         Remarks = Payout.Remarks,
         VendorId = Payout.VendorId,
         VendorOrderTotal = Payout.VendorOrderTotal,
         PayoutStatusName = Payout.PayoutStatus.ToString()
     };
     if (_orderService != null)
     {
         var order = _orderService.GetOrderById(Payout.OrderId);
         model.OrderId = order.Id;
     }
     return model;
 }
        public static VendorPayoutModel ToModel(this VendorPayout Payout, IOrderService _orderService)
        {
            var model = new VendorPayoutModel()
            {
                CommissionPercentage = Payout.CommissionPercentage,
                Id = Payout.Id,
                OrderId = Payout.OrderId,
                PayoutDate = Payout.PayoutDate,
                PayoutStatus = Payout.PayoutStatus,
                Remarks = Payout.Remarks,
                VendorId = Payout.VendorId,
                VendorOrderTotal = Payout.VendorOrderTotal,
                ShippingCharge = Payout.ShippingCharge,
                PayoutStatusName = Payout.PayoutStatus.ToString(),
            };
           
            if (Payout.PayoutStatus == PayoutStatus.Cancelled)
            {
                model.CommissionAmount = 0;
                model.PayoutAmount = 0;
                model.VendorOrderTotal = 0;
            }
            else if (_orderService != null)
            {
               var order =  _orderService.GetOrderById(Payout.OrderId);
               model.OrderDate = order.CreatedOnUtc;
/*
               var vendorItemTotalExShipping = Payout.VendorOrderTotal - model.ShippingCharge;
               var vendorItemTotalOriginal = (vendorItemTotalExShipping * 100) / (100 + Payout.CommissionPercentage);
               decimal commission = vendorItemTotalExShipping - vendorItemTotalOriginal;
               model.CommissionAmount = commission;
               model.PayoutAmount = vendorItemTotalOriginal;*/
                
               model.PayoutAmount = GetPayoutAmount(Payout.VendorOrderTotal,Payout.CommissionPercentage);
               model.CommissionAmount = model.VendorOrderTotal - model.PayoutAmount;
            }

            return model;
        }