Skip to content
Merged

Dev #1569

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 @@ -16,21 +16,27 @@
using Microsoft.Extensions.Logging;
using Volo.Abp.Uow;
using Unity.Modules.Shared.Http;
using Unity.Payments.PaymentConfigurations;
using Unity.Payments.Domain.AccountCodings;

namespace Unity.Payments.Integrations.Cas
{

[IntegrationService]
[ExposeServices(typeof(InvoiceService), typeof(IInvoiceService))]
public class InvoiceService(ICasTokenService iTokenService,
IPaymentRequestRepository paymentRequestRepository,
IResilientHttpRequest resilientHttpRequest,
IOptions<CasClientOptions> casClientOptions,
ISupplierRepository iSupplierRepository,
ISiteRepository iSiteRepository,
IUnitOfWorkManager unitOfWorkManager) : ApplicationService, IInvoiceService
#pragma warning disable S107 // Methods should not have too many parameters
public class InvoiceService(
ICasTokenService iTokenService,
IAccountCodingRepository accountCodingRepository,
PaymentConfigurationAppService paymentConfigurationAppService,
IPaymentRequestRepository paymentRequestRepository,
IResilientHttpRequest resilientHttpRequest,
IOptions<CasClientOptions> casClientOptions,
ISupplierRepository iSupplierRepository,
ISiteRepository iSiteRepository,
IUnitOfWorkManager unitOfWorkManager) : ApplicationService, IInvoiceService
#pragma warning restore S107 // Methods should not have too many parameters
{


private const string CFS_APINVOICE = "cfs/apinvoice";

private readonly Dictionary<int, string> CASPaymentGroup = new()
Expand All @@ -39,7 +45,6 @@ public class InvoiceService(ICasTokenService iTokenService,
[(int)PaymentGroup.Cheque] = "GEN CHQ"
};


protected virtual async Task<Invoice?> InitializeCASInvoice(PaymentRequest paymentRequest,
string? accountDistributionCode)
{
Expand Down Expand Up @@ -101,12 +106,13 @@ public class InvoiceService(ICasTokenService iTokenService,
throw new UserFriendlyException("CreateInvoiceByPaymentRequestAsync: Payment Request not found");
}

// Based on the payment request application id in the correlation id
// lookup the form id
// on the form is there an acount distribution code?
// If no account distribution code then we can use the default account distribution code from payment configuration default account distribution code id

string? accountDistributionCode = "";// this will be on the payment request
if (!paymentRequest.AccountCodingId.HasValue)
{
throw new UserFriendlyException("CreateInvoiceByPaymentRequestAsync: Account Coding - Payment Request - not found");
}

AccountCoding accountCoding = await accountCodingRepository.GetAsync(paymentRequest.AccountCodingId.Value);
string accountDistributionCode = await paymentConfigurationAppService.GetAccountDistributionCode(accountCoding);// this will be on the payment request

if (!string.IsNullOrEmpty(accountDistributionCode))
{
Expand Down