Archive Invoice

This commit is contained in:
Kukks
2020-05-07 12:50:07 +02:00
parent 137c3ef2ce
commit e5a3ef3e22
9 changed files with 107 additions and 7 deletions

View File

@@ -158,7 +158,8 @@ retry:
Status = invoice.StatusString,
#pragma warning restore CS0618 // Type or member is obsolete
ItemCode = invoice.ProductInformation.ItemCode,
CustomerEmail = invoice.RefundMail
CustomerEmail = invoice.RefundMail,
Archived = false
});
foreach (var paymentMethod in invoice.GetPaymentMethods())
@@ -396,6 +397,17 @@ retry:
}
}
public async Task ToggleInvoiceArchival(string invoiceId, bool archived)
{
using (var context = _ContextFactory.CreateContext())
{
var invoiceData = await context.FindAsync<InvoiceData>(invoiceId).ConfigureAwait(false);
if (invoiceData == null || invoiceData.Archived == archived )
return;
invoiceData.Archived = archived;
await context.SaveChangesAsync().ConfigureAwait(false);
}
}
public async Task UpdatePaidInvoiceToInvalid(string invoiceId)
{
using (var context = _ContextFactory.CreateContext())
@@ -499,6 +511,7 @@ retry:
{
entity.BuyerInformation.BuyerEmail = entity.RefundMail;
}
entity.Archived = invoice.Archived;
return entity;
}
@@ -513,6 +526,11 @@ retry:
{
IQueryable<Data.InvoiceData> query = context.Invoices;
if (!queryObject.IncludeArchived)
{
query = query.Where(i => !i.Archived);
}
if (queryObject.InvoiceId != null && queryObject.InvoiceId.Length > 0)
{
var statusSet = queryObject.InvoiceId.ToHashSet().ToArray();
@@ -838,5 +856,6 @@ retry:
public bool IncludeAddresses { get; set; }
public bool IncludeEvents { get; set; }
public bool IncludeArchived { get; set; } = true;
}
}