コード例 #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 RequestParticipantViewModel(Claim claim)
 {
     ClaimId  = claim.ClaimId;
     Claim    = claim;
     UserId   = claim.PlayerUserId;
     User     = claim.Player;
     FeeTotal = Claim.ClaimTotalFee();
     FeeToPay = Claim.ClaimFeeDue();
 }
コード例 #3
0
ファイル: ClaimViewModel.cs プロジェクト: kahadev/joinrpg-net
 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();
 }
コード例 #4
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);
        }
コード例 #5
0
        public ClaimListItemViewModel([NotNull]
                                      Claim claim,
                                      int currentUserId)
        {
            if (claim == null)
            {
                throw new ArgumentNullException(nameof(claim));
            }

            var lastComment = claim.CommentDiscussion.Comments.Where(c => c.IsVisibleToPlayer)
                              .OrderByDescending(c => c.CommentId).FirstOrDefault();

            ClaimId = claim.ClaimId;

            ClaimFullStatusView = new ClaimFullStatusView(claim, new AccessArguments(claim, currentUserId));
            Name   = claim.Name;
            Player = claim.Player;

            UpdateDate          = lastComment?.LastEditTime ?? claim.CreateDate;
            CreateDate          = claim.CreateDate;
            Responsible         = claim.ResponsibleMasterUser;
            LastModifiedBy      = lastComment?.Author ?? claim.Player;
            UnreadCommentsCount = claim.CommentDiscussion.GetUnreadCount(currentUserId);

            ProjectId   = claim.ProjectId;
            ProjectName = claim.Project.ProjectName;
            Fields      = claim.GetFields();
            FeePaid     = claim.ClaimBalance();
            FeeDue      = claim.ClaimFeeDue();
            TotalFee    = claim.ClaimTotalFee();

            PreferentialFeeUser = claim.PreferentialFeeUser;


            AccomodationType = claim.AccommodationRequest?.AccommodationType.Name;
            RoomName         = claim.AccommodationRequest?.Accommodation?.Name;
        }
コード例 #6
0
 /// <summary>
 /// Returns total sum of claim fee and all finance operations using current date
 /// </summary>
 public static int ClaimTotalFee(this Claim claim, int?fieldsFee = null)
 => claim.ClaimTotalFee(DateTime.UtcNow, fieldsFee);
コード例 #7
0
 private static bool ClaimPaidInFull(this Claim claim, DateTime operationDate)
 => claim.ClaimBalance() >= claim.ClaimTotalFee(operationDate.AddDays(-1), null);
コード例 #8
0
 public static bool ClaimPaidInFull(this Claim claim)
 => claim.ClaimBalance() >= claim.ClaimTotalFee();
コード例 #9
0
 /// <summary>
 /// Returns how many money left to pay
 /// </summary>
 public static int ClaimFeeDue(this Claim claim)
 => claim.ClaimTotalFee() - claim.ClaimBalance();
コード例 #10
0
 /// <summary>
 /// Returns claim payment status from claim' data
 /// </summary>
 public static ClaimPaymentStatus PaymentStatus(this Claim claim)
 => GetClaimPaymentStatus(claim.ClaimTotalFee(), claim.ClaimBalance());
コード例 #11
0
 public static int ClaimTotalFee(this Claim claim) => claim.ClaimTotalFee(DateTime.UtcNow);