Skip to content

Commit 47b359f

Browse files
author
CIS Guru
committed
See REVISIONS.md for details
1 parent af98892 commit 47b359f

3 files changed

Lines changed: 20 additions & 16 deletions

File tree

Aquiis.SimpleStart.Tests/PaymentServiceTests.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -576,7 +576,7 @@ public async Task DeleteAsync_UpdatesInvoiceStatus()
576576
InvoiceId = _testInvoiceId,
577577
Amount = 1500,
578578
PaidOn = DateTime.Today,
579-
PaymentMethod = "Check",
579+
PaymentMethod = ApplicationConstants.PaymentMethods.Check,
580580
CreatedBy = _testUserId,
581581
CreatedOn = DateTime.UtcNow
582582
};
@@ -606,7 +606,7 @@ public async Task CalculateTotalPaymentsAsync_ReturnsCorrectTotal()
606606
InvoiceId = _testInvoiceId,
607607
Amount = 500,
608608
PaidOn = DateTime.Today,
609-
PaymentMethod = "Check",
609+
PaymentMethod = ApplicationConstants.PaymentMethods.Check,
610610
CreatedBy = _testUserId,
611611
CreatedOn = DateTime.UtcNow
612612
};
@@ -618,7 +618,7 @@ public async Task CalculateTotalPaymentsAsync_ReturnsCorrectTotal()
618618
InvoiceId = _testInvoiceId,
619619
Amount = 750,
620620
PaidOn = DateTime.Today,
621-
PaymentMethod = "Cash",
621+
PaymentMethod = ApplicationConstants.PaymentMethods.Cash,
622622
CreatedBy = _testUserId,
623623
CreatedOn = DateTime.UtcNow
624624
};
@@ -641,7 +641,7 @@ public async Task CalculateTotalPaymentsAsync_WithDateRange_ReturnsFilteredTotal
641641
InvoiceId = _testInvoiceId,
642642
Amount = 500,
643643
PaidOn = DateTime.Today.AddMonths(-2),
644-
PaymentMethod = "Check",
644+
PaymentMethod = ApplicationConstants.PaymentMethods.Check,
645645
CreatedBy = _testUserId,
646646
CreatedOn = DateTime.UtcNow
647647
};
@@ -653,7 +653,7 @@ public async Task CalculateTotalPaymentsAsync_WithDateRange_ReturnsFilteredTotal
653653
InvoiceId = _testInvoiceId,
654654
Amount = 750,
655655
PaidOn = DateTime.Today,
656-
PaymentMethod = "Cash",
656+
PaymentMethod = ApplicationConstants.PaymentMethods.Cash,
657657
CreatedBy = _testUserId,
658658
CreatedOn = DateTime.UtcNow
659659
};
@@ -690,7 +690,7 @@ public async Task GetPaymentSummaryByMethodAsync_ReturnsCorrectSummary()
690690
InvoiceId = _testInvoiceId,
691691
Amount = 300,
692692
PaidOn = DateTime.Today,
693-
PaymentMethod = "Check",
693+
PaymentMethod = ApplicationConstants.PaymentMethods.Check,
694694
CreatedBy = _testUserId,
695695
CreatedOn = DateTime.UtcNow
696696
};
@@ -702,7 +702,7 @@ public async Task GetPaymentSummaryByMethodAsync_ReturnsCorrectSummary()
702702
InvoiceId = _testInvoiceId,
703703
Amount = 700,
704704
PaidOn = DateTime.Today,
705-
PaymentMethod = "Cash",
705+
PaymentMethod = ApplicationConstants.PaymentMethods.Cash,
706706
CreatedBy = _testUserId,
707707
CreatedOn = DateTime.UtcNow
708708
};
@@ -727,7 +727,7 @@ public async Task GetTotalPaidForInvoiceAsync_ReturnsCorrectTotal()
727727
InvoiceId = _testInvoiceId,
728728
Amount = 500,
729729
PaidOn = DateTime.Today,
730-
PaymentMethod = "Check",
730+
PaymentMethod = ApplicationConstants.PaymentMethods.OnlinePayment,
731731
CreatedBy = _testUserId,
732732
CreatedOn = DateTime.UtcNow
733733
};
@@ -739,7 +739,7 @@ public async Task GetTotalPaidForInvoiceAsync_ReturnsCorrectTotal()
739739
InvoiceId = _testInvoiceId,
740740
Amount = 750,
741741
PaidOn = DateTime.Today,
742-
PaymentMethod = "Cash",
742+
PaymentMethod = ApplicationConstants.PaymentMethods.Cash,
743743
CreatedBy = _testUserId,
744744
CreatedOn = DateTime.UtcNow
745745
};

Aquiis.SimpleStart/Application/Services/PaymentService.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -362,34 +362,34 @@ private async Task UpdateInvoiceAfterPaymentChangeAsync(Guid invoiceId)
362362
// Update invoice status based on payment
363363
if (totalPaid >= totalDue)
364364
{
365-
invoice.Status = "Paid";
365+
invoice.Status = ApplicationConstants.InvoiceStatuses.Paid;
366366
invoice.PaidOn = invoice.Payments
367367
.Where(p => !p.IsDeleted)
368368
.OrderByDescending(p => p.PaidOn)
369369
.FirstOrDefault()?.PaidOn ?? DateTime.UtcNow;
370370
}
371-
else if (totalPaid > 0 && invoice.Status != "Cancelled")
371+
else if (totalPaid > 0 && invoice.Status != ApplicationConstants.InvoiceStatuses.Cancelled)
372372
{
373373
// Invoice is partially paid
374374
if (invoice.DueOn < DateTime.Today)
375375
{
376-
invoice.Status = "Overdue";
376+
invoice.Status = ApplicationConstants.InvoiceStatuses.Overdue;
377377
}
378378
else
379379
{
380-
invoice.Status = "Pending";
380+
invoice.Status = ApplicationConstants.InvoiceStatuses.Pending;
381381
}
382382
}
383-
else if (invoice.Status != "Cancelled")
383+
else if (invoice.Status != ApplicationConstants.InvoiceStatuses.Cancelled)
384384
{
385385
// No payments
386386
if (invoice.DueOn < DateTime.Today)
387387
{
388-
invoice.Status = "Overdue";
388+
invoice.Status = ApplicationConstants.InvoiceStatuses.Overdue;
389389
}
390390
else
391391
{
392-
invoice.Status = "Pending";
392+
invoice.Status = ApplicationConstants.InvoiceStatuses.Pending;
393393
}
394394
}
395395

Aquiis.SimpleStart/Core/Constants/ApplicationConstants.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,8 @@ public static class PaymentMethods
152152
public const string CreditCard = "Credit Card";
153153
public const string BankTransfer = "Bank Transfer";
154154
public const string CryptoCurrency = "Crypto Currency";
155+
public const string Cash = "Cash";
156+
public const string Check = "Check";
155157
public const string Other = "Other";
156158

157159
public static IReadOnlyList<string> AllPaymentMethods { get; } = new List<string>
@@ -161,6 +163,8 @@ public static class PaymentMethods
161163
CreditCard,
162164
BankTransfer,
163165
CryptoCurrency,
166+
Cash,
167+
Check,
164168
Other
165169
};
166170
}

0 commit comments

Comments
 (0)