예제 #1
0
 public PaymentViewModel(ClaimViewModel claim) : base(claim)
 {
     ActionName = "Оплатить";
 }
예제 #2
0
 public SubmitPaymentViewModel(ClaimViewModel claim) : base(claim)
 {
     ActionName   = "Отметить взнос";
     PaymentTypes = claim.PaymentTypes.GetUserSelectablePaymentTypes();
     CommentText  = "Сдан взнос";
 }
예제 #3
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);
        }