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); }
/// <summary> /// Returns actual fee for a claim (as a sum of claim fee and fields fee) /// </summary> private static int ClaimCurrentFee(this Claim claim, DateTime operationDate, int?fieldsFee) { return(claim.BaseFee(operationDate) + claim.ClaimFieldsFee(fieldsFee) + claim.ClaimAccommodationFee()); /****************************************************************** * If you want to add additional fee to a claim's fee, * append your value to the expression above. * Example: * return claim.BaseFee(operationDate) * + claim.ClaimFieldsFee(fieldsFee) * + claim.ClaimAccommodationFee() * + claim.SomeOtherBigFee(); *****************************************************************/ }
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); }