mirror of
https://github.com/stokebob/BealeEngineering.git
synced 2026-03-19 06:37:15 +00:00
Bug fix Sale.UpdateInvoice class
This commit is contained in:
@@ -148,7 +148,8 @@ namespace BealeEngineering.Accounts
|
||||
dialogText = "Import complete." + Environment.NewLine + Environment.NewLine
|
||||
+ importXeroInvoice.InvoicesProcessed + " invoice(s) found" + Environment.NewLine
|
||||
+ importXeroInvoice.InvoicesCreated + " invoice(s) created" + Environment.NewLine
|
||||
+ importXeroInvoice.InvoicesUpdated + " invoice(s) updated" + Environment.NewLine;
|
||||
+ importXeroInvoice.InvoicesUpdated + " invoice(s) updated" + Environment.NewLine
|
||||
+ importXeroInvoice.InvoicesSkipped + " invoice(s) skipped" + Environment.NewLine;
|
||||
|
||||
MessageBox.Show(dialogText);
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ namespace BealeEngineering.Core.Data.Database.Sale
|
||||
private int recordsCreated = 0;
|
||||
private int recordsUpdated = 0;
|
||||
private int invoicesProcessed = 0;
|
||||
private int invoicesSkipped = 0;
|
||||
|
||||
public UpdateInvoice(string sqlConnectionString) : base(sqlConnectionString)
|
||||
{
|
||||
@@ -22,6 +23,7 @@ namespace BealeEngineering.Core.Data.Database.Sale
|
||||
public int RecordsCreated { get { return recordsCreated; } }
|
||||
public int RecordsUpdated { get { return recordsUpdated; } }
|
||||
public int InvoicesProcessed { get { return invoicesProcessed; } }
|
||||
public int InvoicesSkipped { get { return invoicesSkipped; } }
|
||||
public void ByInvoice(Model.Sale.Invoice invoice, bool insertNew = false)
|
||||
{
|
||||
var invoiceList = new List<Model.Sale.Invoice> { invoice };
|
||||
@@ -32,6 +34,7 @@ namespace BealeEngineering.Core.Data.Database.Sale
|
||||
recordsCreated = 0;
|
||||
recordsUpdated = 0;
|
||||
invoicesProcessed = 0;
|
||||
invoicesSkipped = 0;
|
||||
|
||||
// check the list
|
||||
if (invoiceList == null || !invoiceList.Any()) { return; }
|
||||
@@ -103,18 +106,19 @@ namespace BealeEngineering.Core.Data.Database.Sale
|
||||
OUTPUT INSERTED.SaleInvoiceID
|
||||
VALUES(
|
||||
(SELECT ContactID FROM Contact WHERE ContactName = @contactName)
|
||||
@saleInvoiceNumber
|
||||
@invoiceDate
|
||||
@dateDue
|
||||
@reference
|
||||
@currencyCode
|
||||
@invoiceTotal
|
||||
@taxTotal
|
||||
@isCreditNote
|
||||
,@saleInvoiceNumber
|
||||
,@invoiceDate
|
||||
,@dateDue
|
||||
,@reference
|
||||
,@currencyCode
|
||||
,@invoiceTotal
|
||||
,@taxTotal
|
||||
,@isCreditNote
|
||||
)";
|
||||
}
|
||||
else
|
||||
{
|
||||
invoicesSkipped += 1;
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -198,7 +202,7 @@ namespace BealeEngineering.Core.Data.Database.Sale
|
||||
}
|
||||
}
|
||||
}
|
||||
if (InvoicesProcessed == (RecordsCreated + RecordsUpdated))
|
||||
if (InvoicesProcessed == (RecordsCreated + RecordsUpdated + invoicesSkipped))
|
||||
{
|
||||
scope.Complete();
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ namespace BealeEngineering.Core.Logic.Import
|
||||
|
||||
public int InvoicesProcessed { get; private set; } = 0;
|
||||
|
||||
public int InvoicesSkipped { get; private set; } = 0;
|
||||
|
||||
public void ByFilePath(string filePath, bool updateContacts = true)
|
||||
{
|
||||
@@ -44,13 +45,14 @@ namespace BealeEngineering.Core.Logic.Import
|
||||
if (dbInvoiceData.Any())
|
||||
{
|
||||
var updateInvoice = new Data.Database.Sale.UpdateInvoice(sqlConnectionString);
|
||||
updateInvoice.ByInvoiceList(dbInvoiceData);
|
||||
updateInvoice.ByInvoiceList(dbInvoiceData, true);
|
||||
|
||||
InvoicesCreated = updateInvoice.RecordsCreated;
|
||||
InvoicesUpdated = updateInvoice.RecordsUpdated;
|
||||
InvoicesProcessed = updateInvoice.InvoicesProcessed;
|
||||
InvoicesSkipped = updateInvoice.InvoicesSkipped;
|
||||
|
||||
if (InvoicesProcessed != (InvoicesCreated + InvoicesUpdated))
|
||||
if (InvoicesProcessed != (InvoicesCreated + InvoicesUpdated + InvoicesSkipped))
|
||||
{ throw new Exception("Error importing invoices"); }
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user