mirror of
https://github.com/stokebob/bnhtrade.git
synced 2026-03-23 08:17:15 +00:00
wip
This commit is contained in:
@@ -8,7 +8,7 @@ using static System.ComponentModel.Design.ObjectSelectorEditor;
|
||||
|
||||
namespace bnhtrade.Core.Data.Database.Account
|
||||
{
|
||||
internal class PurchaseInvoice : Connection
|
||||
public class PurchaseInvoice : Connection
|
||||
{
|
||||
private bnhtrade.Core.Data.Database.SqlWhereBuilder sqlBuilder;
|
||||
|
||||
|
||||
@@ -44,6 +44,7 @@ namespace bnhtrade.Core.Data.Database.Account
|
||||
InvoiceIdList = new List<int>();
|
||||
InvoiceLineIdList = new List<int>();
|
||||
StatusList = new List<string>();
|
||||
ItemDescription = new List<string>();
|
||||
}
|
||||
|
||||
public Dictionary<int, Model.Account.PurchaseInvoice.Line> Read()
|
||||
@@ -104,6 +105,9 @@ namespace bnhtrade.Core.Data.Database.Account
|
||||
sql = sql + sqlBuilder.SqlWhereString;
|
||||
}
|
||||
|
||||
// catch taxcode to add in after db read
|
||||
var lineTaxCodeDict = new Dictionary<int, string>();
|
||||
|
||||
using (SqlConnection conn = new SqlConnection(SqlConnectionString))
|
||||
{
|
||||
conn.Open();
|
||||
@@ -173,14 +177,35 @@ namespace bnhtrade.Core.Data.Database.Account
|
||||
line.RecordModified = recordModified;
|
||||
line.RecordCreated = recordCreated;
|
||||
line.IsActive = isActive;
|
||||
line.AccountTaxCode = accountTaxCode;
|
||||
|
||||
returnList.Add(purchaseLineID, line);
|
||||
|
||||
lineTaxCodeDict.Add(purchaseLineID, accountTaxCode);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// read tax codes form db and add to return object
|
||||
var taxcodeList = new Data.Database.Account.ReadTaxCode().GetByTaxCode(lineTaxCodeDict.Values.ToList());
|
||||
|
||||
foreach (var line in returnList.Values)
|
||||
{
|
||||
foreach(var taxcode in taxcodeList)
|
||||
{
|
||||
if (taxcode.TaxCode == lineTaxCodeDict[line.PurchaseLineId])
|
||||
{
|
||||
line.AccountTaxCode = taxcode;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (line.AccountTaxCode == null)
|
||||
{
|
||||
throw new Exception("Fail safe, this really shouodn't happen");
|
||||
}
|
||||
}
|
||||
|
||||
// all done
|
||||
return returnList;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user