Closed tiagonmas closed 11 months ago
Invoices that have this issue
SELECT dbo.Invoices.Created, dbo.Donations.DonationDate, dbo.Donations.DonationAmount, dbo.Donations.WantsReceipt, dbo.Donations.NIF, dbo.Invoices.Number, dbo.Invoices.Year, YEAR(dbo.Donations.DonationDate) AS YearDonation, YEAR(dbo.Invoices.Created) AS YearCreated, dbo.Donations.PublicId FROM dbo.Donations RIGHT OUTER JOIN dbo.Invoices ON dbo.Donations.Id = dbo.Invoices.DonationId WHERE (YEAR(dbo.Donations.DonationDate) <> YEAR(dbo.Invoices.Created))
The issue is in InvoiceRepository.cs:
DateTime portugalDateTimeNow = DateTime.Now.GetPortugalDateTime();
int sequence = GetNextSequence(portugalDateTimeNow, context, tenant, donation.FoodBank.Id);
we should not use Current time (Now) but the date of the invoice.
Describe the bug When a donor requests an invoice at a later date then the date he donated, we're generating the invoice with current date and not the date when payment was made. This is particularly wrong if the date is on a different year, because of fiscal reasons.
We can only generate invoices from past years until January 15th. After that that we need to show an error message telling the person to contact support. Also, we need to fix the date of the invoice to be the date of payment.