Skip to content
Merged

Dev #1562

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@
using System;
using Volo.Abp.Domain.Entities.Auditing;
using System.Linq;
using Volo.Abp.MultiTenancy;

namespace Unity.Payments.Domain.AccountCodings
{
public class AccountCoding : AuditedAggregateRoot<Guid>
public class AccountCoding : AuditedAggregateRoot<Guid>, IMultiTenant
{
public Guid? TenantId { get; set; }
public string MinistryClient { get; private set; }
public string Responsibility { get; private set; }
public string ServiceLine { get; private set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -419,8 +419,12 @@ protected internal async Task<List<PaymentRequestDto>> MapToDtoAndLoadDetailsAsy
{
paymentRequestDto.CreatorUser = paymentRequestUserDto;
}
paymentRequestDto.AccountCodingDisplay = await GetAccountDistributionCode(paymentRequestDto.AccountCoding);

if(paymentRequestDto != null && paymentRequestDto.AccountCoding != null)
{
paymentRequestDto.AccountCodingDisplay = await GetAccountDistributionCode(paymentRequestDto.AccountCoding);
}

foreach (var expenseApproval in paymentRequestDto.ExpenseApprovals)
{
if (expenseApproval.DecisionUserId.HasValue
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public PaymentsApplicationAutoMapperProfile()
CreateMap<Supplier, SupplierDto>();

CreateMap<CreateUpdateAccountCodingDto, AccountCoding>()
.ForMember(dest => dest.TenantId, opt => opt.Ignore())
.ForMember(dest => dest.LastModificationTime, opt => opt.Ignore())
.ForMember(dest => dest.LastModifierId, opt => opt.Ignore())
.ForMember(dest => dest.CreationTime, opt => opt.Ignore())
Expand All @@ -50,6 +51,7 @@ public PaymentsApplicationAutoMapperProfile()
CreateMap<AccountCoding, AccountCodingDto>();
CreateMap<AccountCodingDto, CreateUpdateAccountCodingDto>();
CreateMap<CreateUpdateAccountCodingDto, AccountCoding>()
.ForMember(dest => dest.TenantId, opt => opt.Ignore())
.ForMember(dest => dest.LastModificationTime, opt => opt.Ignore())
.ForMember(dest => dest.LastModifierId, opt => opt.Ignore())
.ForMember(dest => dest.CreationTime, opt => opt.Ignore())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public class PaymentsApprovalModel : IValidatableObject
public string ToStatusText { get; set; } = string.Empty;

public Guid? PreviousL1Approver { get; set; }
public bool HasUserPaymentThreshold { get; set; }

public bool IsApproval { get; set; }
public bool IsValid { get; set; } = false;
Expand All @@ -64,7 +65,14 @@ public IEnumerable<ValidationResult> Validate(ValidationContext validationContex
errorMessage: localizer["ApplicationPaymentRequest:Validations:L2ApproverRestriction"],
memberNames: [nameof(PreviousL1Approver)]
);
}
} else if (IsApproval
&& Status == PaymentRequestStatus.L2Pending && !HasUserPaymentThreshold)
{
yield return new ValidationResult(
errorMessage: "Your User has not been configured with an Approved Payment Threshold. Please contact your system administrator.",
memberNames: [nameof(PreviousL1Approver)]
);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@
<input type="hidden" asp-for="@Model.PaymentGroupings[k].Items[i].ToStatus" />
<input type="hidden" asp-for="@Model.PaymentGroupings[k].Items[i].PreviousL1Approver" />
<input type="hidden" asp-for="@Model.PaymentGroupings[k].Items[i].IsValid" />
<input type="hidden" asp-for="@Model.PaymentGroupings[k].Items[i].HasUserPaymentThreshold" />
<abp-row id=@($"{@Model.PaymentGroupings[k].Items[i].Id}_header") class=" m-0 p-2">
<abp-column size="_12" class="px-1 d-flex align-items-center">
<div class="w-100">
Expand Down Expand Up @@ -161,10 +162,17 @@
</abp-row>
}
<abp-column size="_12" class=" m-0 p-3 payment-error-column text-danger" abp-if="@(!ModelState.IsValid)">
@if(ModelState.ContainsKey(nameof(PaymentsApprovalModel.PreviousL1Approver))
@if (ModelState.ContainsKey(nameof(PaymentsApprovalModel.PreviousL1Approver))
&& ModelState[nameof(PaymentsApprovalModel.PreviousL1Approver)]?.ValidationState == Microsoft.AspNetCore.Mvc.ModelBinding.ModelValidationState.Invalid)
{
<span>@L["ApplicationPaymentRequest:Validations:L2ApproverRestrictionBatch"]</span>
var previousL1ApproverState = ModelState[nameof(PaymentsApprovalModel.PreviousL1Approver)];
if (previousL1ApproverState != null)
{
foreach (var error in previousL1ApproverState.Errors)
{
<span>@error.ErrorMessage</span>
}
}
}
</abp-column>
<abp-row class="m-0 p-2 no-payment-msg text-center" id="no-payment-msg" style="display: none;">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ private async Task<PaymentsApprovalModel> CreateApprovalModel(PaymentDetailsDto
IsL3ApprovalRequired = isL3ApprovalRequired,
ToStatus = payment.Status,
IsApproval = IsApproval,
HasUserPaymentThreshold = UserPaymentThreshold.HasValue,
PreviousL1Approver = payment.ExpenseApprovals.FirstOrDefault(x => x.Type == ExpenseApprovalType.Level1)?.DecisionUserId
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,6 @@ $(function () {
text: 'Approve',
className: 'custom-table-btn flex-none btn btn-secondary payment-status',
action: function (e, dt, node, config) {
// Check if user payment threshold is defined and greater than 0
if (parseFloat($("#UserPaymentThreshold").val() || 0) <= 0) {
abp.notify.error(
'Your User has not been configured with an Approved Payment Threshold. Please contact your system administrator.',
'Payment Requests'
);
return;
}
paymentRequestStatusModal.open({
paymentIds: JSON.stringify(selectedPaymentIds),
isApprove: true
Expand Down Expand Up @@ -645,8 +637,14 @@ $(function () {
name: 'accountCodingDisplay',
data: 'accountCodingDisplay',
className: 'data-table-header',
index: columnIndex

index: columnIndex,
render: function (data) {
if (data + "" !== "undefined" && data?.length > 0) {
return data;
} else {
return "";
}
}
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,14 @@

namespace Unity.GrantManager.Payments
{
public class AccountCodingAppService :
CrudAppService<
public class AccountCodingAppService(
IRepository<AccountCoding, Guid> repository
) : CrudAppService<
AccountCoding,
AccountCodingDto,
Guid,
PagedAndSortedResultRequestDto,
CreateUpdateAccountCodingDto>, IAccountCodingAppService
CreateUpdateAccountCodingDto>(repository), IAccountCodingAppService
{
public AccountCodingAppService(IRepository<AccountCoding, Guid> repository)
: base(repository)
{
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@
try {
assessmentResultObj['correlationId'] = formVersionId;
assessmentResultObj['worksheetId'] = worksheetId;
if(assessmentResultObj['ApprovedAmount'] == '') {
assessmentResultObj['ApprovedAmount'] = null;
}
unity.grantManager.grantApplications.grantApplication
.updateAssessmentResults(applicationId, assessmentResultObj)
.done(function () {
Expand Down