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