mirror of
https://github.com/stokebob/BealeEngineering.git
synced 2026-03-21 07:37:16 +00:00
Bugfix, minor updates
This commit is contained in:
@@ -17,7 +17,6 @@ namespace BealeEngineering.Core.Data.Database.Client
|
||||
public int ByDictionary(Dictionary<int, int> saleInvoiceIdToPoLineId)
|
||||
{
|
||||
int rowsCreated = 0;
|
||||
|
||||
if (saleInvoiceIdToPoLineId == null || !saleInvoiceIdToPoLineId.Any())
|
||||
{
|
||||
throw new Exception("No data passed to function.");
|
||||
|
||||
@@ -33,14 +33,14 @@ namespace BealeEngineering.Core.Data.Database.Client
|
||||
}
|
||||
}
|
||||
}
|
||||
public List<int> GetUnallocatedInvoiceId()
|
||||
public List<string> GetUnallocatedInvoice()
|
||||
{
|
||||
using (SqlConnection conn = new SqlConnection(sqlConnectionString))
|
||||
{
|
||||
conn.Open();
|
||||
|
||||
using (SqlCommand cmd = new SqlCommand(@"
|
||||
SELECT SaleInvoice.SaleInvoiceID
|
||||
SELECT SaleInvoice.SaleInvoiceNumber
|
||||
FROM SaleInvoice
|
||||
LEFT OUTER JOIN ClientPurchaseOrderLineSalesInvoice ON SaleInvoice.SaleInvoiceID = ClientPurchaseOrderLineSalesInvoice.SaleInvoiceID
|
||||
WHERE (ClientPurchaseOrderLineSalesInvoice.SaleInvoiceID IS NULL)
|
||||
@@ -56,10 +56,10 @@ namespace BealeEngineering.Core.Data.Database.Client
|
||||
}
|
||||
else
|
||||
{
|
||||
var returnList = new List<int>();
|
||||
var returnList = new List<string>();
|
||||
while (reader.Read())
|
||||
{
|
||||
returnList.Add(reader.GetInt32(0));
|
||||
returnList.Add(reader.GetString(0));
|
||||
}
|
||||
return returnList;
|
||||
}
|
||||
|
||||
@@ -28,22 +28,23 @@ namespace BealeEngineering.Core.Logic.Client
|
||||
|
||||
// get list of unallocated invoices
|
||||
var poAlloInstance = new Data.Database.Client.ReadPurchaseOrderAllocation(SqlConnectionString);
|
||||
var invoiceIdList = poAlloInstance.GetUnallocatedInvoiceId();
|
||||
var invoiceNumberList = poAlloInstance.GetUnallocatedInvoice();
|
||||
|
||||
// nothing to allocate
|
||||
if (invoiceIdList == null || !invoiceIdList.Any())
|
||||
if (invoiceNumberList == null || !invoiceNumberList.Any())
|
||||
{
|
||||
IsComplete = true;
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
InvoiceProcessed = invoiceIdList.Count();
|
||||
InvoiceProcessed = invoiceNumberList.Count();
|
||||
}
|
||||
|
||||
// get invoice header info
|
||||
var invoiceInst = new Data.Database.Sale.ReadInvoiceHeader(SqlConnectionString);
|
||||
var invoiceList = invoiceInst.GetBySaleInvoiceId(invoiceIdList);
|
||||
var readInvoice = new Data.Database.Sale.ReadInvoiceHeader(SqlConnectionString);
|
||||
readInvoice.InvoiceNumber = invoiceNumberList;
|
||||
var invoiceList = readInvoice.GetByFilters();
|
||||
|
||||
// create lookup list for matching
|
||||
var lookupList = new List<Tuple<Model.Sale.InvoiceHeader, string, int?>>();
|
||||
@@ -72,10 +73,10 @@ namespace BealeEngineering.Core.Logic.Client
|
||||
//get client POs from db that match reference list
|
||||
var referenceList = new List<string>();
|
||||
foreach(var item in lookupList) { referenceList.Add(item.Item2); }
|
||||
var poInstance = new Data.Database.Client.ReadPurchaseOrder(SqlConnectionString);
|
||||
poInstance.Reference = referenceList.Distinct().ToList();
|
||||
poInstance.ReturnIsClosed = true; // <--------------------------------------------------change to false after
|
||||
var clientPoList = poInstance.GetByFilters();
|
||||
var readPurchaseOrder = new Data.Database.Client.ReadPurchaseOrder(SqlConnectionString);
|
||||
readPurchaseOrder.Reference = referenceList.Distinct().ToList();
|
||||
readPurchaseOrder.ReturnIsClosed = false;
|
||||
var clientPoList = readPurchaseOrder.GetByFilters();
|
||||
|
||||
// create dictionary for matched items
|
||||
var invoiceIdToPoLineId = new Dictionary<int, int>();
|
||||
@@ -143,8 +144,8 @@ namespace BealeEngineering.Core.Logic.Client
|
||||
// update db table
|
||||
if (invoiceIdToPoLineId.Count > 0)
|
||||
{
|
||||
var instance2 = new Data.Database.Client.CreatePurchaseOrderAllocation(SqlConnectionString);
|
||||
InvoiceMatched = instance2.ByDictionary(invoiceIdToPoLineId);
|
||||
var createAllocation = new Data.Database.Client.CreatePurchaseOrderAllocation(SqlConnectionString);
|
||||
InvoiceMatched = createAllocation.ByDictionary(invoiceIdToPoLineId);
|
||||
}
|
||||
IsComplete = true;
|
||||
}
|
||||
|
||||
@@ -13,14 +13,12 @@ namespace BealeEngineering.Core.Test
|
||||
SqlConnectionString = sqlConnectionString;
|
||||
|
||||
// enter method to start here
|
||||
Import();
|
||||
ClientPurchaseOrder();
|
||||
}
|
||||
private string SqlConnectionString { get; set; }
|
||||
public void Invoice()
|
||||
public void ClientPurchaseOrder()
|
||||
{
|
||||
// thing you want to run from the form button
|
||||
|
||||
var inst = new Core.Test.Sales.Invoice(SqlConnectionString);
|
||||
var inst = new Test.Client.PurchaseOrder(SqlConnectionString);
|
||||
}
|
||||
public void Contact()
|
||||
{
|
||||
@@ -30,6 +28,12 @@ namespace BealeEngineering.Core.Test
|
||||
{
|
||||
var inst = new Test.Import.ImportFlatfile(SqlConnectionString);
|
||||
}
|
||||
public void Invoice()
|
||||
{
|
||||
// thing you want to run from the form button
|
||||
|
||||
var inst = new Core.Test.Sales.Invoice(SqlConnectionString);
|
||||
}
|
||||
public void ValidateModel()
|
||||
{
|
||||
var inst = new Test.Sales.Invoice(SqlConnectionString);
|
||||
|
||||
@@ -8,17 +8,17 @@ namespace BealeEngineering.Core.Test.Client
|
||||
{
|
||||
public class PurchaseOrder
|
||||
{
|
||||
public List<int> PurchaseOrderIdList { get; set; }
|
||||
public string SqlConnectionString { get; set; }
|
||||
public PurchaseOrder(string sqlConnectionString)
|
||||
{
|
||||
SqlConnectionString = sqlConnectionString;
|
||||
PurchaseOrderIdList = new List<int> { 92, 17, 140 };
|
||||
|
||||
// method to start here
|
||||
GetUnallocatedPo();
|
||||
|
||||
}
|
||||
public void Start()
|
||||
{
|
||||
GetPurchaseOrderById();
|
||||
}
|
||||
public List<int> PurchaseOrderIdList { get; set; }
|
||||
public string SqlConnectionString { get; set; }
|
||||
public void GetPurchaseOrderById()
|
||||
{
|
||||
var inst = new Core.Data.Database.Client.ReadPurchaseOrder(SqlConnectionString);
|
||||
@@ -29,5 +29,10 @@ namespace BealeEngineering.Core.Test.Client
|
||||
var inst = new Logic.Client.PurchaseOrderAutoAllocate(SqlConnectionString);
|
||||
inst.Execute();
|
||||
}
|
||||
public void GetUnallocatedPo()
|
||||
{
|
||||
var readPoAllo = new Data.Database.Client.ReadPurchaseOrderAllocation(SqlConnectionString);
|
||||
var test = readPoAllo.GetUnallocatedInvoice();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user