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); }
public RequestParticipantViewModel(Claim claim) { ClaimId = claim.ClaimId; Claim = claim; UserId = claim.PlayerUserId; User = claim.Player; FeeTotal = Claim.ClaimTotalFee(); FeeToPay = Claim.ClaimFeeDue(); }
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(); }
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); }
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; }
/// <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);
private static bool ClaimPaidInFull(this Claim claim, DateTime operationDate) => claim.ClaimBalance() >= claim.ClaimTotalFee(operationDate.AddDays(-1), null);
public static bool ClaimPaidInFull(this Claim claim) => claim.ClaimBalance() >= claim.ClaimTotalFee();
/// <summary> /// Returns how many money left to pay /// </summary> public static int ClaimFeeDue(this Claim claim) => claim.ClaimTotalFee() - claim.ClaimBalance();
/// <summary> /// Returns claim payment status from claim' data /// </summary> public static ClaimPaymentStatus PaymentStatus(this Claim claim) => GetClaimPaymentStatus(claim.ClaimTotalFee(), claim.ClaimBalance());
public static int ClaimTotalFee(this Claim claim) => claim.ClaimTotalFee(DateTime.UtcNow);