Пример #1
0
        public ClaimFeeViewModel(Claim claim, ClaimViewModel model, int currentUserId)
        {
            Status = model.Status;

            // Reading project fee info applicable for today
            BaseFeeInfo = claim.CurrentFee == null?claim.Project.ProjectFeeInfo() : null;

            // Reading base fee of a claim
            BaseFee = claim.BaseFee();
            // Checks for base fee availability
            HasBaseFee = BaseFeeInfo != null || claim.CurrentFee != null;

            AccommodationFee = claim.ClaimAccommodationFee();
            RoomType         = claim.AccommodationRequest?.AccommodationType?.Name ?? "";
            RoomName         = claim.AccommodationRequest?.Accommodation?.Name;

            FieldsWithFeeCount = model.Fields.FieldWithFeeCount;
            FieldsTotalFee     = model.Fields.FieldsTotalFee;

            HasFieldsWithFee = model.Fields.HasFieldsWithFee;
            CurrentTotalFee  = claim.ClaimTotalFee(FieldsTotalFee);
            CurrentFee       = claim.ClaimCurrentFee(FieldsTotalFee);
            FieldsFee        = model.Fields.FieldsFee;

            foreach (FinanceOperationState s in Enum.GetValues(typeof(FinanceOperationState)))
            {
                Balance[s] = 0;
            }
            foreach (var fo in claim.FinanceOperations)
            {
                Balance[fo.State] += fo.MoneyAmount;
            }

            HasMasterAccess   = claim.HasMasterAccess(currentUserId);
            HasFeeAdminAccess = claim.HasAccess(currentUserId, acl => acl.CanManageMoney);

            PreferentialFeeEnabled    = claim.Project.Details.PreferentialFeeEnabled;
            PreferentialFeeUser       = claim.PreferentialFeeUser;
            PreferentialFeeConditions =
                claim.Project.Details.PreferentialFeeConditions.ToHtmlString();
            PreferentialFeeRequestEnabled = PreferentialFeeEnabled && !PreferentialFeeUser && Status.IsActive();

            ClaimId     = claim.ClaimId;
            ProjectId   = claim.ProjectId;
            FeeVariants = claim.Project.ProjectFeeSettings
                          .Select(f => f.Fee)
                          .Union(CurrentFee)
                          .OrderBy(x => x)
                          .ToList();
            FinanceOperations        = claim.FinanceOperations.Select(fo => new FinanceOperationViewModel(fo, model.HasMasterAccess));
            VisibleFinanceOperations = FinanceOperations.Where(
                fo => fo.OperationType != FinanceOperationTypeViewModel.FeeChange &&
                fo.OperationType != FinanceOperationTypeViewModel.PreferentialFeeRequest);

            ShowOnlinePaymentControls  = model.PaymentTypes.OnlinePaymentsEnabled() && currentUserId == claim.PlayerUserId;
            HasSubmittablePaymentTypes = model.PaymentTypes.Any(pt => pt.TypeKind != PaymentTypeKindViewModel.Online);

            // Determining payment status
            PaymentStatus = FinanceExtensions.GetClaimPaymentStatus(CurrentTotalFee, CurrentBalance);
        }
Пример #2
0
 public ClaimFeeViewModel(Claim claim, int currentUserId)
 {
     CurrentTotalFee = claim.ClaimTotalFee();
     CurrentBalance  = claim.ClaimBalance();
     CurrentFee      = claim.ClaimCurrentFee();
     IsFeeAdmin      = claim.HasMasterAccess(currentUserId, acl => acl.CanManageMoney);
     ClaimId         = claim.ClaimId;
     ProjectId       = claim.ProjectId;
     FeeVariants     = claim.Project.ProjectFeeSettings.Select(f => f.Fee).Union(CurrentFee).OrderBy(x => x).ToList();
 }
Пример #3
0
        public ClaimFeeViewModel(Claim claim, ClaimViewModel model, int currentUserId)
        {
            // Reading project fee info applicable for today
            BaseFeeInfo = claim.CurrentFee == null?claim.Project.ProjectFeeInfo() : null;

            // Reading base fee of a claim
            BaseFee = claim.BaseFee();
            // Checks for base fee availability
            HasBaseFee = BaseFeeInfo != null || claim.CurrentFee != null;

            AccommodationFee = claim.ClaimAccommodationFee();
            RoomType         = claim.AccommodationRequest?.AccommodationType?.Name ?? "";
            RoomName         = claim.AccommodationRequest?.Accommodation?.Name;

            FieldsWithFeeCount = model.Fields.FieldWithFeeCount;
            FieldsTotalFee     = model.Fields.FieldsTotalFee;

            HasFieldsWithFee = model.Fields.HasFieldsWithFee;
            CurrentTotalFee  = claim.ClaimTotalFee(FieldsTotalFee);
            CurrentFee       = claim.ClaimCurrentFee(FieldsTotalFee);
            FieldsFee        = model.Fields.FieldsFee;

            foreach (FinanceOperationState s in Enum.GetValues(typeof(FinanceOperationState)))
            {
                Balance[s] = 0;
            }
            foreach (var fo in claim.FinanceOperations)
            {
                Balance[fo.State] += fo.MoneyAmount;
            }

            IsFeeAdmin = claim.HasAccess(currentUserId,
                                         acl => acl.CanManageMoney);
            PreferentialFeeEnabled    = claim.Project.Details.PreferentialFeeEnabled;
            PreferentialFeeUser       = claim.PreferentialFeeUser;
            PreferentialFeeConditions =
                claim.Project.Details.PreferentialFeeConditions.ToHtmlString();

            ClaimId           = claim.ClaimId;
            ProjectId         = claim.ProjectId;
            FeeVariants       = claim.Project.ProjectFeeSettings.Select(f => f.Fee).Union(CurrentFee).OrderBy(x => x).ToList();
            FinanceOperations = claim.FinanceOperations;

            // Determining payment status
            PaymentStatus = FinanceExtensions.GetClaimPaymentStatus(CurrentTotalFee, CurrentBalance);
        }
Пример #4
0
 /// <summary>
 /// Returns actual fee for a claim (as a sum of claim fee and fields fee) using current date
 /// </summary>
 public static int ClaimCurrentFee(this Claim claim, int?fieldsFee)
 => claim.ClaimCurrentFee(DateTime.UtcNow, fieldsFee);
Пример #5
0
 /// <summary>
 /// Returns total sum of claim fee and all finance operations
 /// </summary>
 private static int ClaimTotalFee(this Claim claim, DateTime operationDate, int?fieldsFee)
 => claim.ClaimCurrentFee(operationDate, fieldsFee)
 + claim.ApprovedFinanceOperations.Sum(fo => fo.FeeChange);
Пример #6
0
 public static int ClaimCurrentFee(this Claim claim) => claim.ClaimCurrentFee(DateTime.UtcNow);
Пример #7
0
 private static int ClaimTotalFee(this Claim claim, DateTime operationDate)
 {
     return(claim.ClaimCurrentFee(operationDate) + claim.ApprovedFinanceOperations.Sum(fo => fo.FeeChange));
 }