public ClaimListItemViewModel([NotNull] Claim claim, int currentUserId) { if (claim == null) { throw new ArgumentNullException(nameof(claim)); } var lastComment = claim.Comments.Where(c => c.IsVisibleToPlayer).OrderByDescending(c => c.CommentId).FirstOrDefault(); ClaimId = claim.ClaimId; ClaimStatus = (ClaimStatusView)claim.ClaimStatus; Name = claim.Name; Player = claim.Player; UpdateDate = lastComment?.LastEditTime ?? claim.CreateDate; CreateDate = claim.CreateDate; Responsible = claim.ResponsibleMasterUser; LastModifiedBy = lastComment?.Author ?? claim.Player; UnreadCommentsCount = claim.Comments.Count(comment => (comment.IsVisibleToPlayer || claim.HasMasterAccess(currentUserId)) && !comment.IsReadByUser(currentUserId)); ProjectId = claim.ProjectId; ProjectName = claim.Project.ProjectName; Fields = new CustomFieldsViewModel(currentUserId, claim); FeePaid = claim.ClaimBalance(); FeeDue = claim.ClaimFeeDue(); }
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(); PreferentialFeeUser = claim.PreferentialFeeUser; AccomodationType = claim.AccommodationRequest?.AccommodationType.Name; RoomName = claim.AccommodationRequest?.Accommodation?.Name; }
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(); }
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());