Skip to content

Commit

Permalink
Changes for invoice received
Browse files Browse the repository at this point in the history
  • Loading branch information
Prashanthi-Sivanarayana committed Nov 8, 2024
1 parent 5ce7138 commit d5571f2
Showing 1 changed file with 18 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -485,11 +485,16 @@ private async Task<JsonObject> CreateSinglePayment(SupplementaryApplication appr
DateTime secondAnniversaryDate,
DateTime? fundingEndDate)
{
DateTime invoiceDate = ((CheckSubmissionIsWithinLast45days(approvedSA.ofm_submittedon.Value, firstAnniversaryDate) || CheckSubmissionIsWithinLast45days(approvedSA.ofm_submittedon.Value, secondAnniversaryDate) || CheckSubmissionIsWithinLast45days(approvedSA.ofm_submittedon.Value, fundingEndDate.Value)) ? paymentDate.GetFirstDayOfFollowingNextMonth(holidaysList) : (paymentDate == approvedSA.ofm_start_date!.Value) ? paymentDate.GetLastBusinessDayOfThePreviousMonth(holidaysList) : paymentDate.GetCFSInvoiceDate(holidaysList, _BCCASApi.PayableInDays));
DateTime invoiceDate = (paymentDate == approvedSA.ofm_start_date!.Value) ? paymentDate.GetLastBusinessDayOfThePreviousMonth(holidaysList) : paymentDate.GetCFSInvoiceDate(holidaysList, _BCCASApi.PayableInDays);
DateTime invoiceReceivedDate = invoiceDate.AddBusinessDays(_BCCASApi.PayableInDays, holidaysList);
DateTime effectiveDate = invoiceDate;


//this applies if supplementary application is submitted within 45 days.
if ((CheckSubmissionIsWithinLast45days(approvedSA.ofm_submittedon.Value, firstAnniversaryDate) || CheckSubmissionIsWithinLast45days(approvedSA.ofm_submittedon.Value, secondAnniversaryDate) || CheckSubmissionIsWithinLast45days(approvedSA.ofm_submittedon.Value, fundingEndDate.Value)))
{
invoiceReceivedDate = paymentDate.GetFirstDayOfFollowingNextMonth(holidaysList);
invoiceDate = invoiceReceivedDate.GetCFSInvoiceDate(holidaysList, _BCCASApi.PayableInDays);
effectiveDate = invoiceDate;
}

if (approvedSA.ofm_retroactive_date is not null && !(CheckSubmissionIsWithinLast45days(approvedSA.ofm_submittedon.Value, firstAnniversaryDate) || CheckSubmissionIsWithinLast45days(approvedSA.ofm_submittedon.Value, secondAnniversaryDate) || CheckSubmissionIsWithinLast45days(approvedSA.ofm_submittedon.Value, fundingEndDate.Value)))
{
Expand All @@ -500,7 +505,7 @@ private async Task<JsonObject> CreateSinglePayment(SupplementaryApplication appr
effectiveDate = invoiceDate;
}

Guid fiscalYear = invoiceDate.AddMonths(-1).MatchFiscalYear(fiscalYears);
Guid fiscalYear = paymentDate.MatchFiscalYear(fiscalYears);

var payload = new JsonObject()
{
Expand Down Expand Up @@ -552,11 +557,16 @@ private async Task<JsonObject> CreatePaymentsInBatch(Application baseApplication
for (DateTime paymentDate = startDate; paymentDate <= endDate; paymentDate = paymentDate.AddMonths(1))
{

DateTime invoiceDate = ((CheckSubmissionIsWithinLast45days(approvedSA.ofm_submittedon.Value, firstAnniversaryDate) || CheckSubmissionIsWithinLast45days(approvedSA.ofm_submittedon.Value, secondAnniversaryDate) || CheckSubmissionIsWithinLast45days(approvedSA.ofm_submittedon.Value, fundingEndDate.Value)) ? paymentDate.GetFirstDayOfFollowingNextMonth(holidaysList) : (paymentDate == startDate) ? startDate.GetLastBusinessDayOfThePreviousMonth(holidaysList) : paymentDate.GetCFSInvoiceDate(holidaysList, _BCCASApi.PayableInDays));
DateTime invoiceDate = (paymentDate == startDate) ? startDate.GetLastBusinessDayOfThePreviousMonth(holidaysList) : paymentDate.GetCFSInvoiceDate(holidaysList, _BCCASApi.PayableInDays);
DateTime invoiceReceivedDate = invoiceDate.AddBusinessDays(_BCCASApi.PayableInDays, holidaysList);
DateTime effectiveDate = invoiceDate;


//this applies if supplementary application is submitted within 45 days.
if ((CheckSubmissionIsWithinLast45days(approvedSA.ofm_submittedon.Value, firstAnniversaryDate) || CheckSubmissionIsWithinLast45days(approvedSA.ofm_submittedon.Value, secondAnniversaryDate) || CheckSubmissionIsWithinLast45days(approvedSA.ofm_submittedon.Value, fundingEndDate.Value)))
{
invoiceReceivedDate = paymentDate.GetFirstDayOfFollowingNextMonth(holidaysList);
invoiceDate = invoiceReceivedDate.GetCFSInvoiceDate(holidaysList, _BCCASApi.PayableInDays);
effectiveDate = invoiceDate;
}

if (approvedSA.ofm_retroactive_date is not null && !(CheckSubmissionIsWithinLast45days(approvedSA.ofm_submittedon.Value, firstAnniversaryDate) || CheckSubmissionIsWithinLast45days(approvedSA.ofm_submittedon.Value, secondAnniversaryDate) || CheckSubmissionIsWithinLast45days(approvedSA.ofm_submittedon.Value, fundingEndDate.Value)))
{
Expand All @@ -567,7 +577,7 @@ private async Task<JsonObject> CreatePaymentsInBatch(Application baseApplication
effectiveDate = invoiceDate;
}

Guid? fiscalYear = invoiceDate.AddMonths(-1).MatchFiscalYear(fiscalYears);
Guid? fiscalYear = startDate.MatchFiscalYear(fiscalYears);
var paymentToCreate = new JsonObject()
{
{ "ofm_invoice_line_number", nextLineNumber++ },
Expand Down

0 comments on commit d5571f2

Please sign in to comment.