Feature: stock replenishment

This commit is contained in:
Bobbie Hodgetts
2024-05-09 13:23:33 +01:00
committed by GitHub
parent 91ef9acc78
commit 270eebca9a
30 changed files with 721 additions and 249 deletions

View File

@@ -10,19 +10,29 @@ namespace bnhtrade.Core.Data.Database.Account
public class ReadAccountCode : Connection public class ReadAccountCode : Connection
{ {
private Data.Database.SqlWhereBuilder sqlWhere = new SqlWhereBuilder(); private Data.Database.SqlWhereBuilder sqlWhere = new SqlWhereBuilder();
private List<Model.Account.AccountCode> resultList; private List<Model.Account.Account> resultList;
public ReadAccountCode() public ReadAccountCode()
{ {
} }
public List<Model.Account.AccountCode> All() /// <summary>
/// Gets the full chart of accounts
/// </summary>
/// <returns>Dictionary where the database record id is the key</returns>
public Dictionary<uint, Model.Account.Account> All()
{ {
Innit(); Innit();
return Execute(null, null); var list = Execute(null, null);
var dictionary = new Dictionary<uint, Model.Account.Account>();
foreach (var item in list)
{
dictionary.Add(item.Id, item);
}
return dictionary;
} }
public List<Model.Account.AccountCode> ByAccountCode(List<int> accountCodeList) public List<Model.Account.Account> ByAccountCode(List<int> accountCodeList)
{ {
Innit(); Innit();
@@ -35,7 +45,7 @@ namespace bnhtrade.Core.Data.Database.Account
return Execute(sqlWhere.SqlWhereString, sqlWhere.ParameterList); return Execute(sqlWhere.SqlWhereString, sqlWhere.ParameterList);
} }
private List<Model.Account.AccountCode> Execute(string sqlWhere, Dictionary<string, object> parameters) private List<Model.Account.Account> Execute(string sqlWhere, Dictionary<string, object> parameters)
{ {
//build sql query //build sql query
string sqlString = @" string sqlString = @"
@@ -45,6 +55,7 @@ namespace bnhtrade.Core.Data.Database.Account
,tblAccountChartOf.Description ,tblAccountChartOf.Description
,tblAccountChartOfType.AccountChartOfType ,tblAccountChartOfType.AccountChartOfType
,tblAccountChartOfType.BasicType ,tblAccountChartOfType.BasicType
,tblAccountChartOfType.Multiplier
FROM tblAccountChartOf FROM tblAccountChartOf
INNER JOIN tblAccountChartOfType ON tblAccountChartOf.AccountChartOfTypeID = tblAccountChartOfType.AccountChartOfTypeID INNER JOIN tblAccountChartOfType ON tblAccountChartOf.AccountChartOfTypeID = tblAccountChartOfType.AccountChartOfTypeID
" + sqlWhere; " + sqlWhere;
@@ -69,19 +80,20 @@ namespace bnhtrade.Core.Data.Database.Account
{ {
while (reader.Read()) while (reader.Read())
{ {
var result = new Model.Account.AccountCode();
int tablePk = reader.GetInt32(0); uint tablePk = (uint)reader.GetInt32(0);
result.AccountCodeId = reader.GetInt32(1); uint accountCode = (uint)reader.GetInt32(1);
result.Title = reader.GetString(2); string title = reader.GetString(2);
if (!reader.IsDBNull(3)) { result.Description = reader.GetString(3); } string description = null;
result.Type = reader.GetString(4); if (!reader.IsDBNull(3)) { description = reader.GetString(3); }
result.BasicType = reader.GetString(5); string type = reader.GetString(4);
string basicType = reader.GetString(5);
int multiplier = reader.GetInt32(6);
var result = new Model.Account.Account(tablePk, accountCode, title, description, type, basicType, multiplier);
resultList.Add(result); resultList.Add(result);
} }
} }
return resultList; return resultList;
} }
} }
@@ -90,7 +102,7 @@ namespace bnhtrade.Core.Data.Database.Account
private void Innit() private void Innit()
{ {
resultList = new List<Model.Account.AccountCode>(); resultList = new List<Model.Account.Account>();
} }
} }
} }

View File

@@ -94,7 +94,7 @@ namespace bnhtrade.Core.Data.Database.Account
taxcodeList = taxcodeList.Distinct().ToList(); taxcodeList = taxcodeList.Distinct().ToList();
whereBuilder.Innit(); whereBuilder.Init();
whereBuilder.In("TaxCode", taxcodeList, "WHERE"); whereBuilder.In("TaxCode", taxcodeList, "WHERE");
return Execute(whereBuilder.SqlWhereString, whereBuilder.ParameterList); return Execute(whereBuilder.SqlWhereString, whereBuilder.ParameterList);
@@ -111,7 +111,7 @@ namespace bnhtrade.Core.Data.Database.Account
taxcodeIdList = taxcodeIdList.Distinct().ToList(); taxcodeIdList = taxcodeIdList.Distinct().ToList();
whereBuilder.Innit(); whereBuilder.Init();
whereBuilder.In("AccountTaxCodeID", taxcodeIdList, "WHERE"); whereBuilder.In("AccountTaxCodeID", taxcodeIdList, "WHERE");
return Execute(whereBuilder.SqlWhereString, whereBuilder.ParameterList); return Execute(whereBuilder.SqlWhereString, whereBuilder.ParameterList);
@@ -144,7 +144,7 @@ namespace bnhtrade.Core.Data.Database.Account
FROM tblSku FROM tblSku
INNER JOIN tblAccountTaxCode ON tblSku.AccountTaxCodeID = tblAccountTaxCode.AccountTaxCodeID "; INNER JOIN tblAccountTaxCode ON tblSku.AccountTaxCodeID = tblAccountTaxCode.AccountTaxCodeID ";
whereBuilder.Innit(); whereBuilder.Init();
whereBuilder.In("tblSku.skuSkuNumber", skuNumberList, "WHERE"); whereBuilder.In("tblSku.skuSkuNumber", skuNumberList, "WHERE");
sql += whereBuilder.SqlWhereString; sql += whereBuilder.SqlWhereString;
@@ -196,7 +196,7 @@ namespace bnhtrade.Core.Data.Database.Account
LEFT OUTER JOIN tblAccountTaxCode ON tblAccountInvoiceLineItem.AccountTaxCodeID_Default = tblAccountTaxCode.AccountTaxCodeID LEFT OUTER JOIN tblAccountTaxCode ON tblAccountInvoiceLineItem.AccountTaxCodeID_Default = tblAccountTaxCode.AccountTaxCodeID
"; ";
whereBuilder.Innit(); whereBuilder.Init();
whereBuilder.In("tblAccountInvoiceLineItem.ItemCode", lineItemCode, "WHERE"); whereBuilder.In("tblAccountInvoiceLineItem.ItemCode", lineItemCode, "WHERE");
sql += whereBuilder.SqlWhereString; sql += whereBuilder.SqlWhereString;

View File

@@ -59,6 +59,17 @@ namespace bnhtrade.Core.Data.Database
SkuReconciliationFbaReimbursement = 11, SkuReconciliationFbaReimbursement = 11,
} }
/// <summary>
/// Returns the sql table ID for a stock status
/// </summary>
public enum StockStatus
{
FbaFulfillable = 15,
FbaSold = 12,
ReservedGarageStock = 16,
Reserved = 11,
}
/// <summary> /// <summary>
/// Returns the sql table ID for a stock status type /// Returns the sql table ID for a stock status type
/// </summary> /// </summary>

View File

@@ -104,7 +104,7 @@ namespace bnhtrade.Core.Data.Database.Export
cmd.Parameters.AddWithValue("@invoiceID", invoiceId); cmd.Parameters.AddWithValue("@invoiceID", invoiceId);
cmd.Parameters.AddWithValue("@itemCode", invoiceList[i].InvoiceLineList[j].ItemCode); cmd.Parameters.AddWithValue("@itemCode", invoiceList[i].InvoiceLineList[j].ItemCode);
cmd.Parameters.AddWithValue("@netAmount", invoiceList[i].InvoiceLineList[j].UnitAmount); cmd.Parameters.AddWithValue("@netAmount", invoiceList[i].InvoiceLineList[j].UnitAmount);
cmd.Parameters.AddWithValue("@accountCode", invoiceList[i].InvoiceLineList[j].AccountCode.AccountCodeId); cmd.Parameters.AddWithValue("@accountCode", invoiceList[i].InvoiceLineList[j].AccountCode.AccountCode);
cmd.Parameters.AddWithValue("@taxAmount", invoiceList[i].InvoiceLineList[j].TaxAmount); cmd.Parameters.AddWithValue("@taxAmount", invoiceList[i].InvoiceLineList[j].TaxAmount);
cmd.Parameters.AddWithValue("@taxCode", invoiceList[i].InvoiceLineList[j].TaxCode.TaxCode); cmd.Parameters.AddWithValue("@taxCode", invoiceList[i].InvoiceLineList[j].TaxCode.TaxCode);

View File

@@ -43,7 +43,7 @@ namespace bnhtrade.Core.Data.Database.Import
INNER JOIN tblImportAmazonSettlementReportLine ON tblImportAmazonSettlementReport.ImportAmazonSettlementReportID = tblImportAmazonSettlementReportLine.ImportAmazonSettlementReportID INNER JOIN tblImportAmazonSettlementReportLine ON tblImportAmazonSettlementReport.ImportAmazonSettlementReportID = tblImportAmazonSettlementReportLine.ImportAmazonSettlementReportID
WHERE "; WHERE ";
whereBuilder.Innit(); whereBuilder.Init();
whereBuilder.In("tblImportAmazonSettlementReport.[settlement-id]", settlementIdList); whereBuilder.In("tblImportAmazonSettlementReport.[settlement-id]", settlementIdList);
sql += whereBuilder.SqlWhereString; sql += whereBuilder.SqlWhereString;

View File

@@ -120,7 +120,7 @@ namespace bnhtrade.Core.Data.Database.Product
// add nullable items to model // add nullable items to model
if (!reader.IsDBNull(2)) if (!reader.IsDBNull(2))
item.TitleSuffix = reader.GetString(2); item.TitleSuffix = reader.GetString(2);
if (!reader.IsDBNull(3)) if (!reader.IsDBNull(4))
item.ProductCategorySubID = reader.GetInt32(4); item.ProductCategorySubID = reader.GetInt32(4);
if (!reader.IsDBNull(5)) if (!reader.IsDBNull(5))
item.ReleaseDate = DateTime.SpecifyKind(reader.GetDateTime(5), DateTimeKind.Utc); item.ReleaseDate = DateTime.SpecifyKind(reader.GetDateTime(5), DateTimeKind.Utc);
@@ -187,11 +187,11 @@ namespace bnhtrade.Core.Data.Database.Product
"; ";
var sqlWhereBuilder = new Database.SqlWhereBuilder(); var sqlWhereBuilder = new Database.SqlWhereBuilder();
sqlWhereBuilder.Innit(); sqlWhereBuilder.Init();
sqlWhereBuilder.In("tblSku.skuSkuNumber", skuNumberList); sqlWhereBuilder.In("tblSku.skuSkuNumber", skuNumberList);
sql += sqlWhereBuilder.SqlWhereString; sql += sqlWhereBuilder.SqlWhereString;
using (SqlConnection conn = new SqlConnection()) using (SqlConnection conn = new SqlConnection(SqlConnectionString))
{ {
conn.Open(); conn.Open();

View File

@@ -34,7 +34,7 @@ namespace bnhtrade.Core.Data.Database.Sku
FROM tblSku FROM tblSku
WHERE "; WHERE ";
sqlWhere.Innit(); sqlWhere.Init();
sqlWhere.In("skuSkuNumber", skuNumberList); sqlWhere.In("skuSkuNumber", skuNumberList);
sqlString += sqlWhere.SqlWhereString; sqlString += sqlWhere.SqlWhereString;

View File

@@ -7,44 +7,71 @@ using System.Threading.Tasks;
namespace bnhtrade.Core.Data.Database namespace bnhtrade.Core.Data.Database
{ {
/// <summary>
/// Step 1: Call the methods for each where clause you want to create. This can be done multiple times to create an sql where string. Pay attention
/// to the prefixes that you'll require between each where clause, as each time a method is called the sql statement will be appended to the previous sql
/// string.
/// Step 2: Appened the created sql string to your sql statement, NB the WHERE statemet is not included by default.
/// Step 3: Once you've created your sql command object, add the parameters to it using the method contained within this class.
/// STep 4: exceute your sql commend.
/// </summary>
public class SqlWhereBuilder public class SqlWhereBuilder
{ {
private int parameterCount; private int parameterCount = 0;
public SqlWhereBuilder() public SqlWhereBuilder()
{ {
Innit(); Init();
} }
public string SqlWhereString { get; private set; } public string SqlWhereString { get; private set; }
public bool IsSetSqlWhereString
{
get
{
if (SqlWhereString == null || string.IsNullOrEmpty(SqlWhereString))
{
return false;
}
else
{
return true;
}
}
}
public Dictionary<string, object> ParameterList { get; private set; } public Dictionary<string, object> ParameterList { get; private set; }
public void Innit() /// <summary>
/// Initialises the class
/// </summary>
public void Init()
{ {
SqlWhereString = null;
ParameterList = new Dictionary<string, object>();
parameterCount = 0; parameterCount = 0;
SqlWhereString = "";
ParameterList = new Dictionary<string, object>();
} }
public void AddParametersToSqlCommand(SqlCommand cmd) public void AddParametersToSqlCommand(SqlCommand cmd)
{ {
foreach (var item in ParameterList) if (ParameterList != null)
{ {
cmd.Parameters.AddWithValue(item.Key, item.Value); foreach (var item in ParameterList)
{
cmd.Parameters.AddWithValue(item.Key, item.Value);
}
} }
} }
/// <summary> /// <summary>
/// Used to create a string for an SQL where condition 'In' statement /// Append an 'In' statement and parameter list to the class properties
/// </summary> /// </summary>
/// <param name="columnReference">Name of the column to used to for the condition statement</param> /// <param name="columnReference">Name of the column to used to for the condition statement</param>
/// <param name="orValueList">List of values to test in condition statement</param> /// <param name="orValueList">List of values to test in condition statement</param>
/// <param name="wherePrefix">Optional string to prefix to the returned result</param> /// <param name="wherePrefix">Optional prefix that gets added to the sql string result</param>
public void In(string columnReference, List<string> orValueList, string wherePrefix = null) public void In(string columnReference, List<string> orValueList, string wherePrefix = null)
{ {
Innit();
if (orValueList == null || !orValueList.Any()) if (orValueList == null || !orValueList.Any())
{ {
return; return;
@@ -62,7 +89,6 @@ namespace bnhtrade.Core.Data.Database
sqlWhere += " " + columnReference + " IN ( "; sqlWhere += " " + columnReference + " IN ( ";
var paramters = new Dictionary<string, object>();
int listCount = distinctList.Count(); int listCount = distinctList.Count();
for (int i = 0; i < listCount; i++, parameterCount++) for (int i = 0; i < listCount; i++, parameterCount++)
{ {
@@ -73,20 +99,19 @@ namespace bnhtrade.Core.Data.Database
string param = "@parameter" + parameterCount; string param = "@parameter" + parameterCount;
sqlWhere += param; sqlWhere += param;
paramters.Add(param, distinctList[i]); ParameterList.Add(param, distinctList[i]);
} }
sqlWhere += " )"; sqlWhere += " ) ";
SqlWhereString = sqlWhere; SqlWhereString = SqlWhereString + sqlWhere;
ParameterList = paramters;
} }
/// <summary> /// <summary>
/// Used to create a string for an SQL where condition 'In' statement /// Append an 'In' statement and parameter list to the class properties
/// </summary> /// </summary>
/// <param name="columnReference">Name of the column to used to for the condition statement</param> /// <param name="columnReference">Name of the column to used to for the condition statement</param>
/// <param name="orValueList">List of values to test in condition statement</param> /// <param name="orValueList">List of values to test in condition statement</param>
/// <param name="wherePrefix">Optional string to prefix to the returned result</param> /// <param name="wherePrefix">Optional prefix that gets added to the sql string result</param>
public void In(string columnReference, List<int> orValueList, string wherePrefix = null) public void In(string columnReference, List<int> orValueList, string wherePrefix = null)
{ {
var stringList = new List<string>(); var stringList = new List<string>();

View File

@@ -119,5 +119,54 @@ namespace bnhtrade.Core.Data.Database.Stock
} }
return statusBalance; return statusBalance;
} }
/// <summary>
/// Get a list of SKUs avaliable against a specified statusId
/// </summary>
/// <param name="statusId">The stock status id</param>
/// <returns>Dictionary of SKUs and the balance of each</returns>
public Dictionary<string, int> ByStatusId(int statusId)
{
var returnList = new Dictionary<string, int>();
using (SqlConnection conn = new SqlConnection(SqlConnectionString))
{
conn.Open();
using (SqlCommand cmd = new SqlCommand(@"
SELECT sub.*
FROM (
SELECT tblSku.skuSkuID
,tblSku.skuSkuNumber
,SUM(tblStockJournalPost.Quantity) AS Balance
FROM tblStockJournal
INNER JOIN tblStockJournalPost ON tblStockJournal.StockJournalID = tblStockJournalPost.StockJournalID
INNER JOIN tblStock ON tblStockJournal.StockID = tblStock.StockID
INNER JOIN tblSku ON tblStock.SkuID = tblSku.skuSkuID
WHERE (tblStockJournalPost.StockStatusID = @statusId)
GROUP BY tblSku.skuSkuID
,tblSku.skuSkuNumber
) sub
WHERE sub.Balance <> 0
", conn))
{
// add parameters
cmd.Parameters.AddWithValue("@statusId", statusId);
// execute
using (SqlDataReader reader = cmd.ExecuteReader())
{
while (reader.Read())
{
string sku = reader.GetString(1);
int qty = reader.GetInt32(2);
returnList.Add(sku, qty);
}
}
}
}
return returnList;
}
} }
} }

View File

@@ -112,7 +112,7 @@ namespace bnhtrade.Core.Data.Database.Stock
foreach (var item in dbresults) foreach (var item in dbresults)
{ {
result.Sku = item.SkuNumber; result.SkuNumber = item.SkuNumber;
result.AddBalanceTransaction(item.EntryDate, item.StockNumber, item.Quantity); result.AddBalanceTransaction(item.EntryDate, item.StockNumber, item.Quantity);
} }
} }
@@ -125,15 +125,15 @@ namespace bnhtrade.Core.Data.Database.Stock
/// Gets list of stock status debits and credits. Includes stock numbers with balance greater than or less than zero. /// Gets list of stock status debits and credits. Includes stock numbers with balance greater than or less than zero.
/// </summary> /// </summary>
/// <param name="stockStatusId">Required, filters results by stock status Id</param> /// <param name="stockStatusId">Required, filters results by stock status Id</param>
/// <param name="sku">Required, filters results by sku number</param> /// <param name="skuNumber">Required, filters results by sku number</param>
/// <returns>Tuple list is assending order</returns> /// <returns>Tuple list is assending order</returns>
public Model.Stock.StatusTransaction BySku(int stockStatusId, string sku) public Model.Stock.StatusTransaction BySku(int stockStatusId, string skuNumber)
{ {
var result = new Model.Stock.StatusTransaction(); var result = new Model.Stock.StatusTransaction();
result.Sku = sku; result.SkuNumber = skuNumber;
result.StockStatusId = stockStatusId; result.StockStatusId = stockStatusId;
if (string.IsNullOrWhiteSpace(sku)) if (string.IsNullOrWhiteSpace(skuNumber))
{ {
return result; return result;
} }
@@ -176,7 +176,7 @@ namespace bnhtrade.Core.Data.Database.Stock
{ {
var param = new Dapper.DynamicParameters(); var param = new Dapper.DynamicParameters();
param.Add("@stockStatusId", stockStatusId); param.Add("@stockStatusId", stockStatusId);
param.Add("@sku", sku); param.Add("@sku", skuNumber);
var dbList = conn.Query(strSQL, param); var dbList = conn.Query(strSQL, param);

View File

@@ -0,0 +1,115 @@
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static bnhtrade.Core.Data.Database.Constants;
namespace bnhtrade.Core.Data.Database.Stock
{
internal class Status : Connection
{
private bnhtrade.Core.Data.Database.SqlWhereBuilder sqlBuilder;
public List<int> StatusIds { get; set; }
public List<int> StatusTypeIds { get; set; }
public Status ()
{
Init();
}
public void Init()
{
sqlBuilder = new SqlWhereBuilder();
StatusIds = new List<int>();
StatusTypeIds = new List<int>();
}
public List<Model.Stock.Status> Read()
{
var returnList = new List<Model.Stock.Status>();
sqlBuilder.Init();
//build sql query
string sql = @"
SELECT [StockStatusID]
,[StatusCode]
,[StockStatus]
,[StockStatusTypeID]
,[Reference]
,[ForeignKeyID]
,[IsCreditOnly]
,[IsClosed]
,[RecordCreated]
FROM [e2A].[dbo].[tblStockStatus]
WHERE 1=1 ";
// build the where statments
if (StatusIds.Any())
{
sqlBuilder.In("StockStatusID", StatusIds, "AND");
}
if (StatusTypeIds.Any())
{
sqlBuilder.In("StockStatusTypeID", StatusTypeIds, "AND");
}
// append where string to the sql
if (sqlBuilder.IsSetSqlWhereString)
{
sql = sql + sqlBuilder.SqlWhereString;
}
using (SqlConnection conn = new SqlConnection(SqlConnectionString))
{
conn.Open();
using (SqlCommand cmd = new SqlCommand(sql, conn))
{
sqlBuilder.AddParametersToSqlCommand(cmd);
using (SqlDataReader reader = cmd.ExecuteReader())
{
if (reader.HasRows)
{
var typeDict = new Data.Database.Stock.StatusType().Read();
while (reader.Read())
{
int statusId = reader.GetInt32(0);
int? statusCode = null;
if (!reader.IsDBNull(1)) { statusCode = reader.GetInt32(1); }
string stockStatus = reader.GetString(2);
int typeId = reader.GetInt32(3);
string reference = null;
if (!reader.IsDBNull(4)) { reference = reader.GetString(4); }
int? foreignKeyId = null;
if (!reader.IsDBNull(5)) { foreignKeyId = reader.GetInt32(5); }
bool isCreditOnly = reader.GetBoolean(6);
bool isClosed = reader.GetBoolean(7);
DateTime recordCreated = DateTime.SpecifyKind(reader.GetDateTime(8), DateTimeKind.Utc);
var newItem = new Model.Stock.Status(statusId
, statusCode
, stockStatus
, typeDict[typeId]
, reference
, foreignKeyId
, isCreditOnly
, isClosed
, recordCreated
);
returnList.Add(newItem);
}
}
}
}
}
return returnList;
}
}
}

View File

@@ -0,0 +1,63 @@
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace bnhtrade.Core.Data.Database.Stock
{
public class StatusType : Connection
{
public StatusType()
{
}
/// <summary>
/// Reads all Status Types from database
/// </summary>
/// <returns></returns>
public Dictionary<int, Model.Stock.StatusType> Read()
{
var returnDict = new Dictionary<int, Model.Stock.StatusType>();
// get all account info before we start
var accountDict = new Data.Database.Account.ReadAccountCode().All();
using (SqlConnection conn = new SqlConnection(SqlConnectionString))
{
conn.Open();
using (SqlCommand cmd = new SqlCommand(@"
SELECT [StockStatusTypeID]
,[StatusTypeName]
,[ForeignKeyType]
,[ReferenceType]
,[AccountChartOfID]
FROM [e2A].[dbo].[tblStockStatusType]
", conn))
{
using (SqlDataReader reader = cmd.ExecuteReader())
{
var accountIdDict = new Dictionary<int, int>();
while (reader.Read())
{
int statusTypeId = reader.GetInt32(0);
string name = reader.GetString(1);
string foreignKey = null;
if (!reader.IsDBNull(2)) { foreignKey = reader.GetString(2); }
string reference = null;
if (!reader.IsDBNull(3)) { reference = reader.GetString(3); }
uint accountId = (uint)reader.GetInt32(4);
var statusType = new Model.Stock.StatusType(statusTypeId, name, foreignKey, reference, accountDict[accountId]);
returnDict.Add(statusTypeId, statusType);
}
}
}
}
return returnDict;
}
}
}

View File

@@ -15,12 +15,12 @@ namespace bnhtrade.Core.Logic.Account
readAccountCode = new Data.Database.Account.ReadAccountCode(); readAccountCode = new Data.Database.Account.ReadAccountCode();
} }
public List<Model.Account.AccountCode> GetAll() public Dictionary<uint, Model.Account.Account> GetAll()
{ {
return readAccountCode.All(); return readAccountCode.All();
} }
public Model.Account.AccountCode ByAccountCode(int accountCode) public Model.Account.Account ByAccountCode(int accountCode)
{ {
var list = ByAccountCode(new List<int> { accountCode }); var list = ByAccountCode(new List<int> { accountCode });
if (list.Any()) if (list.Any())
@@ -33,14 +33,14 @@ namespace bnhtrade.Core.Logic.Account
} }
} }
public List<Model.Account.AccountCode> ByAccountCode(List<int> accountCodeList) public List<Model.Account.Account> ByAccountCode(List<int> accountCodeList)
{ {
return readAccountCode.ByAccountCode(accountCodeList); return readAccountCode.ByAccountCode(accountCodeList);
} }
public Dictionary<int, Model.Account.AccountCode> ConvertToDictionary(List<Model.Account.AccountCode> accountCodeList) public Dictionary<int, Model.Account.Account> ConvertToDictionary(List<Model.Account.Account> accountCodeList)
{ {
var returnDict = new Dictionary<int, Model.Account.AccountCode>(); var returnDict = new Dictionary<int, Model.Account.Account>();
if (accountCodeList == null) if (accountCodeList == null)
{ {
@@ -49,9 +49,9 @@ namespace bnhtrade.Core.Logic.Account
foreach (var accountCode in accountCodeList) foreach (var accountCode in accountCodeList)
{ {
if (!returnDict.ContainsKey(accountCode.AccountCodeId)) if (!returnDict.ContainsKey((int)accountCode.AccountCode))
{ {
returnDict.Add(accountCode.AccountCodeId, accountCode); returnDict.Add((int)accountCode.AccountCode, accountCode);
} }
} }
return returnDict; return returnDict;

View File

@@ -0,0 +1,43 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace bnhtrade.Core.Logic.Amazon.Fba
{
public class Stock
{
Logic.Stock.StatusBalance read = new Logic.Stock.StatusBalance();
/// <summary>
/// Get a list of FBA SKUs to replenish from reversed stock. This using the local stock ledger and may not tally with Amazon
/// </summary>
/// <returns>SKU and the avaible stock in reserve</returns>
public List<Model.Stock.StatusBalance> GetReplenishmentList()
{
int fbaFulfillableStatusId = (int)Data.Database.Constants.StockStatus.FbaFulfillable;
int reserveStatusId = (int)Data.Database.Constants.StockStatus.ReservedGarageStock;
var fbaList = read.GetSkuQuantity(fbaFulfillableStatusId);
var myList = read.GetSkuQuantity(reserveStatusId);
foreach (var item in fbaList)
{
if (myList.ContainsKey(item.Key))
{
myList.Remove(item.Key);
}
}
var readStatusBalance = new Logic.Stock.StatusBalance();
var returnList = new List<Model.Stock.StatusBalance>();
foreach (var item in myList)
{
var skuStatusBalance = readStatusBalance.GetStatusBalance(item.Key, reserveStatusId, true);
returnList.Add(skuStatusBalance);
}
return returnList;
}
}
}

View File

@@ -66,7 +66,7 @@ namespace bnhtrade.Core.Logic.Sku.Price
statusTypeList.Add((int)Data.Database.Constants.StockStatusType.FbaInventoryActive); statusTypeList.Add((int)Data.Database.Constants.StockStatusType.FbaInventoryActive);
statusTypeList.Add((int)Data.Database.Constants.StockStatusType.FbaShipment); statusTypeList.Add((int)Data.Database.Constants.StockStatusType.FbaShipment);
var fbaSkuStock = new Logic.Stock.GetStatusTypeBalance().BySku(statusTypeList); var fbaSkuStock = new Logic.Stock.StatusTypeBalance().GetByStatusTypeId(statusTypeList);
// retrive SKU info // retrive SKU info
var getSku = new Logic.Sku.GetSkuInfo(); var getSku = new Logic.Sku.GetSkuInfo();

View File

@@ -26,29 +26,29 @@ namespace bnhtrade.Core.Logic.Stock
} }
/// <summary> /// <summary>
/// Return the avaliable balance of a status at a specified date and time. Useful for checking availability before /// Return the avaliable balance of a status, includes datetime that each stockNumber became avaiable.
/// moving stock/sku retrospectivly /// Useful for checking availability before moving stock/sku retrospectivly
/// </summary> /// </summary>
/// <param name="sku">SKU number</param> /// <param name="skuNumber">SKU number</param>
/// <param name="statusId">Status ID</param> /// <param name="statusId">Status ID</param>
/// <param name="atDate">Date and time you would like to know the balance at</param> /// <param name="includeDetails">True, inlcude SKU and StockStatus class. False, supply the SKU Number and StockStatusId instead</param>
/// <returns></returns> /// <returns></returns>
public Model.Stock.StatusBalance GetBySku(string sku, int statusId) public Model.Stock.StatusBalance GetStatusBalance(string skuNumber, int statusId, bool includeDetails = true)
{ {
if (string.IsNullOrWhiteSpace(sku)) if (string.IsNullOrWhiteSpace(skuNumber))
{ {
throw new Exception("SKU number is null, empty, or whitespace"); throw new Exception("SKU number is null, empty, or whitespace");
} }
// get list of transactions for availale stock // get list of transactions for availale stock
var stockTransaction = new Data.Database.Stock.ReadStatusTransaction(); var readStatusTransaction = new Data.Database.Stock.ReadStatusTransaction();
var transList = stockTransaction.BySku(statusId, sku); var statusTransaction = readStatusTransaction.BySku(statusId, skuNumber);
// create quantity list // create quantity list
List<int> qtyList = new List<int>(); List<int> qtyList = new List<int>();
for (int i = 0; i < transList.TransactionList.Count; i++) for (int i = 0; i < statusTransaction.TransactionList.Count; i++)
{ {
qtyList.Add(transList.TransactionList[i].Quantity); qtyList.Add(statusTransaction.TransactionList[i].Quantity);
} }
// tally list // tally list
@@ -57,15 +57,15 @@ namespace bnhtrade.Core.Logic.Stock
{ {
if (qtyList[iCr] < 0) if (qtyList[iCr] < 0)
{ {
int crStockNumber = transList.TransactionList[iCr].StockNumber; int crStockNumber = statusTransaction.TransactionList[iCr].StockNumber;
DateTime crDate = transList.TransactionList[iCr].EntryDate; DateTime crDate = statusTransaction.TransactionList[iCr].EntryDate;
// loop, in reverse, to find debits // loop, in reverse, to find debits
for (int iDr = qtyList.Count - 1; iDr > -1; iDr--) for (int iDr = qtyList.Count - 1; iDr > -1; iDr--)
{ {
// find debits, last in first out (filter by date) // find debits, last in first out (filter by date)
if (transList.TransactionList[iDr].StockNumber == crStockNumber if (statusTransaction.TransactionList[iDr].StockNumber == crStockNumber
&& transList.TransactionList[iDr].EntryDate <= crDate && statusTransaction.TransactionList[iDr].EntryDate <= crDate
&& qtyList[iDr] > 0) && qtyList[iDr] > 0)
{ {
// credit fully assigned // credit fully assigned
@@ -87,22 +87,49 @@ namespace bnhtrade.Core.Logic.Stock
} }
// build result list from tally results // build result list from tally results
var result = new Model.Stock.StatusBalance(); var entryList = new List<(DateTime EntryDate, int StockNumber, int Quantity)>();
result.Sku = transList.Sku;
result.StockStatusId = transList.StockStatusId;
for (int i = 0; i < qtyList.Count; i++) for (int i = 0; i < qtyList.Count; i++)
{ {
if (qtyList[i] != 0) if (qtyList[i] != 0)
{ {
result.AddBalanceTransaction( (DateTime EntryDate, int StockNumber, int Quantity) entryItem = (
transList.TransactionList[i].EntryDate, statusTransaction.TransactionList[i].EntryDate,
transList.TransactionList[i].StockNumber, statusTransaction.TransactionList[i].StockNumber,
qtyList[i]); qtyList[i]);
entryList.Add(entryItem);
} }
} }
return result; if (includeDetails)
{
// get the sku obj
var readSku = new Logic.Sku.GetSkuInfo();
readSku.IncludeConditionInfo = true;
readSku.IncludeProductInfo = true;
readSku.IncludeTaxCodeInfo = true;
var sku = readSku.BySkuNumber(statusTransaction.SkuNumber);
// get the status obj
var readStatus = new Data.Database.Stock.Status();
readStatus.StatusIds = new List<int> { statusTransaction.StockStatusId };
var status = readStatus.Read()[0];
return new Model.Stock.StatusBalance(status, sku, entryList);
}
else
{
return new Model.Stock.StatusBalance(statusTransaction.StockStatusId, statusTransaction.SkuNumber, entryList);
}
}
/// <summary>
/// Get a list of SKUs avaliable against a specified statusId
/// </summary>
/// <param name="statusId">The stock status id</param>
/// <returns>Dictionary of SKUs and the repective balance of each</returns>
public Dictionary<string, int> GetSkuQuantity(int statusId)
{
return new Data.Database.Stock.ReadStatusBalance().ByStatusId(statusId);
} }
} }
} }

View File

@@ -58,10 +58,10 @@ namespace bnhtrade.Core.Logic.Stock
var returnList = new List<(int StockJournalId, int Quantity)>(); var returnList = new List<(int StockJournalId, int Quantity)>();
// get balance of status and check for avaliable quantity // get balance of status and check for avaliable quantity
var statusBalance = new Logic.Stock.StatusBalance().GetBySku(skuNumber, creditStatusId); var statusBalance = new Logic.Stock.StatusBalance().GetStatusBalance(skuNumber, creditStatusId);
if (statusBalance.GetAvaliableQuantity(entryDate) <= 0 if (statusBalance.GetAvaliableQuantity(entryDate) <= 0
|| (statusBalance.CheckAvaliableQuantity(quantity, entryDate) == false && reallocatePartialQuantity == false || (statusBalance.IsQuantityAvaliable(quantity, entryDate) == false && reallocatePartialQuantity == false
)) ))
{ {
return returnList; return returnList;
@@ -70,7 +70,7 @@ namespace bnhtrade.Core.Logic.Stock
// temp code start // temp code start
// until use of stockId is designed out of application // until use of stockId is designed out of application
var stockIdDictionary = new Dictionary<int, int>(); var stockIdDictionary = new Dictionary<int, int>();
foreach (var item in statusBalance.ByDateList) foreach (var item in statusBalance.StockList)
{ {
if (!stockIdDictionary.ContainsKey(item.StockNumber)) if (!stockIdDictionary.ContainsKey(item.StockNumber))
{ {
@@ -84,7 +84,7 @@ namespace bnhtrade.Core.Logic.Stock
//make the changes //make the changes
using (TransactionScope scope = new TransactionScope()) using (TransactionScope scope = new TransactionScope())
{ {
foreach (var item in statusBalance.ByDateList) foreach (var item in statusBalance.StockList)
{ {
if (quantity > item.Quantity) if (quantity > item.Quantity)
{ {

View File

@@ -6,11 +6,11 @@ using System.Threading.Tasks;
namespace bnhtrade.Core.Logic.Stock namespace bnhtrade.Core.Logic.Stock
{ {
public class GetStatusTypeBalance public class StatusTypeBalance
{ {
private Core.Data.Database.Stock.ReadStatusTypeBalance dbRead; private Core.Data.Database.Stock.ReadStatusTypeBalance dbRead;
public GetStatusTypeBalance() public StatusTypeBalance()
{ {
dbRead = new Data.Database.Stock.ReadStatusTypeBalance(); dbRead = new Data.Database.Stock.ReadStatusTypeBalance();
} }
@@ -20,7 +20,7 @@ namespace bnhtrade.Core.Logic.Stock
/// </summary> /// </summary>
/// <param name="StatusTypeIdList">List of Status Type Ids</param> /// <param name="StatusTypeIdList">List of Status Type Ids</param>
/// <returns>Dictionary where SKU number is key and quantity is value</returns> /// <returns>Dictionary where SKU number is key and quantity is value</returns>
public Dictionary<string, int> BySku(List<int> StatusTypeIdList) public Dictionary<string, int> GetByStatusTypeId(List<int> StatusTypeIdList)
{ {
return dbRead.ReadSku(StatusTypeIdList); return dbRead.ReadSku(StatusTypeIdList);
} }

View File

@@ -0,0 +1,41 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.UI.WebControls;
namespace bnhtrade.Core.Model.Account
{
public class Account
{
public Account(uint id, uint accountCode, string accountName, string description, string type, string basicType, int multiplier)
{
Id = id;
AccountCode = accountCode;
AccountName = accountName;
Description = description;
Type = type;
BasicType = basicType;
Multiplier = multiplier;
}
/// <summary>
/// Database record id
/// </summary>
public uint Id { get; private set; }
public uint AccountCode { get; private set; }
public string AccountName { get; private set; }
public string Description { get; private set; }
public string Type { get; private set; }
public string BasicType { get; private set; }
public int Multiplier { get; private set; }
}
}

View File

@@ -1,86 +0,0 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace bnhtrade.Core.Model.Account
{
public class AccountCode : IValidatableObject
{
private int? accountCodeId;
[Required(), Range(1, int.MaxValue)]
public int AccountCodeId
{
get { return (int)accountCodeId; }
set { accountCodeId = value; }
}
[Required(), MaxLength(150)]
public string Title
{
get;
set;
}
[MaxLength(500)]
public string Description
{
get;
set;
}
[Required(), MaxLength(50)]
public string Type
{
get;
set;
}
[Required(), MaxLength(50)]
public string BasicType
{
get;
set;
}
public bool IsSetAccountCodeId
{
get { return accountCodeId != null; }
}
public bool IsSetTitle
{
get { return Title != null; }
}
public bool IsSetDescription
{
get { return Description != null; }
}
public bool IsSetType
{
get { return Type != null; }
}
public bool IsSetBasicType
{
get { return BasicType != null; }
}
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
{
var resultList = new List<ValidationResult>();
if (!IsSetAccountCodeId)
{
resultList.Add(new ValidationResult("Account Code is not set"));
}
return resultList;
}
}
}

View File

@@ -28,7 +28,7 @@ namespace bnhtrade.Core.Model.Account
decimal? UnitAmount { get; set; } decimal? UnitAmount { get; set; }
Model.Account.AccountCode AccountCode { get; set; } Model.Account.Account AccountCode { get; set; }
Model.Account.TaxCodeInfo TaxCode { get; set; } Model.Account.TaxCodeInfo TaxCode { get; set; }
@@ -116,7 +116,7 @@ namespace bnhtrade.Core.Model.Account
public bool UnitAmountIsTaxExclusive { get; set; } public bool UnitAmountIsTaxExclusive { get; set; }
[Required()] [Required()]
public Model.Account.AccountCode AccountCode public Model.Account.Account AccountCode
{ {
get; get;
set; set;

View File

@@ -44,7 +44,7 @@ namespace bnhtrade.Core.Model.Account
} }
[Required()] [Required()]
public Model.Account.AccountCode DefaultAccountCode public Model.Account.Account DefaultAccountCode
{ {
get; get;
set; set;
@@ -61,7 +61,6 @@ namespace bnhtrade.Core.Model.Account
{ {
var resultList = new List<ValidationResult>(); var resultList = new List<ValidationResult>();
resultList.AddRange(DefaultAccountCode.Validate(validationContext));
resultList.AddRange(DefaultTaxCode.Validate(validationContext)); resultList.AddRange(DefaultTaxCode.Validate(validationContext));
return resultList; return resultList;

View File

@@ -0,0 +1,42 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace bnhtrade.Core.Model.Stock
{
public class Status
{
public Status(int statusId, int? statusCode, string title, Model.Stock.StatusType type, string reference, int? foreignKeyId, bool isCreditOnly, bool isClosed, DateTime recordCreated)
{
StatusId = statusId;
StatusCode = statusCode;
StatusTitle = title;
StatusType = type;
Reference = reference;
ForeignKeyID = foreignKeyId;
IsCreditOnly = isCreditOnly;
IsClosed = isClosed;
RecordCreated = recordCreated;
}
public int StatusId { get; private set; }
public int? StatusCode { get; private set; }
public string StatusTitle { get; private set; }
public Model.Stock.StatusType StatusType { get; private set; }
public string Reference { get; private set; }
public int? ForeignKeyID { get; private set; }
public bool IsCreditOnly { get; private set; }
public bool IsClosed { get; private set; }
public DateTime RecordCreated { get; private set; }
}
}

View File

@@ -1,60 +1,150 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using static bnhtrade.Core.Data.Database.Constants;
using System.Threading.Tasks;
namespace bnhtrade.Core.Model.Stock namespace bnhtrade.Core.Model.Stock
{ {
public class StatusBalance public class StatusBalance
{ {
public int StockStatusId { get; set; } internal StatusBalance(int stockStatusId, string skuNumber, List<(DateTime EntryDate, int StockNumber, int Quantity)> stockList)
public string Sku { get; set; }
public List<ByDate> ByDateList { get; private set; } = new List<ByDate>();
public class ByDate
{ {
public DateTime EntryDate { get; set; } StockStatusId = stockStatusId;
SkuNumber = skuNumber;
public int StockNumber { get; set; } AddStockList(stockList);
public int Quantity { get; set; }
} }
public void AddBalanceTransaction(DateTime entryDate, int stockNumber, int quantity) internal StatusBalance(Model.Stock.Status status, Model.Sku.Sku sku, List<(DateTime EntryDate, int StockNumber, int Quantity)> stockList)
{ {
if (entryDate == new DateTime()) StockStatusId = status.StatusId;
Status = status;
SkuNumber = sku.SkuNumber;
Sku = sku;
AddStockList(stockList);
}
public int StockStatusId { get; private set; }
public Model.Stock.Status Status { get; private set; }
public bool IsSetStatus
{
get
{ {
throw new Exception("Entry date set to default value"); return Status != null;
}
}
public string SkuNumber { get; private set; }
public Model.Sku.Sku Sku { get; private set; }
public bool IsSetSku
{
get
{
return Sku != null;
}
}
/// <summary>
/// A list of when each stock item(s) became available and the quanitity (which is not a running total).
/// </summary>
public List<Stock> StockList { get; private set; } = new List<Stock>();
public class Stock
{
public Stock(DateTime entryDate, int stockNumber, int quantity)
{
EntryDate = entryDate;
StockNumber = stockNumber;
Quantity = quantity;
} }
var item = new ByDate(); public DateTime EntryDate { get; private set; }
item.EntryDate = entryDate;
item.StockNumber = stockNumber;
item.Quantity = quantity;
if (ByDateList == null) { ByDateList = new List<ByDate>(); } public int StockNumber { get; private set; }
if (ByDateList.Count == 0 || ByDateList.Last().EntryDate <= item.EntryDate) public int Quantity { get; private set; }
}
internal void AddDetail(Model.Stock.Status status, Model.Sku.Sku sku)
{
if (sku.SkuNumber != SkuNumber || status.StatusId != StockStatusId)
{ {
ByDateList.Add(item); throw new ArgumentException("Invalid SKU or Status applied to class");
} }
else SkuNumber = sku.SkuNumber;
Sku = sku;
}
private void AddStockList(List<(DateTime EntryDate, int StockNumber, int Quantity)> stockList)
{
foreach (var stockItem in stockList)
{ {
for (int i = 0; i < ByDateList.Count; i++) if (stockItem.EntryDate == new DateTime())
{ {
if (entryDate <= ByDateList[i].EntryDate) throw new Exception("Entry date set to default value");
}
var item = new Stock(stockItem.EntryDate, stockItem.StockNumber, stockItem.Quantity);
if (StockList.Count == 0 || StockList.Last().EntryDate <= item.EntryDate)
{
StockList.Add(item);
}
else
{
for (int i = 0; i < StockList.Count; i++)
{ {
i++; if (stockItem.EntryDate <= StockList[i].EntryDate)
ByDateList.Insert(i, item); {
i++;
StockList.Insert(i, item);
}
} }
} }
} }
} }
public bool CheckAvaliableQuantity(int quantity, DateTime onDateTime) public int GetAvaliableQuantity()
{
if (!StockList.Any())
{
return 0;
}
int qty = 0;
for (int i = 0; i < StockList.Count; i++)
{
qty += StockList[i].Quantity;
}
return qty;
}
public int GetAvaliableQuantity(DateTime onDateTime)
{
if (!StockList.Any())
{
return 0;
}
int qty = 0;
for (int i = 0; i < StockList.Count; i++)
{
if (StockList[i].EntryDate <= onDateTime)
{
qty += StockList[i].Quantity;
}
}
return qty;
}
public bool IsQuantityAvaliable(int quantity, DateTime onDateTime)
{ {
if (GetAvaliableQuantity(onDateTime) < quantity) if (GetAvaliableQuantity(onDateTime) < quantity)
{ {
@@ -65,42 +155,5 @@ namespace bnhtrade.Core.Model.Stock
return true; return true;
} }
} }
public int GetAvaliableQuantity()
{
if (!ByDateList.Any())
{
return 0;
}
int qty = 0;
for (int i = 0; i < ByDateList.Count; i++)
{
qty += ByDateList[i].Quantity;
}
return qty;
}
public int GetAvaliableQuantity(DateTime onDateTime)
{
if (!ByDateList.Any())
{
return 0;
}
int qty = 0;
for (int i = 0; i < ByDateList.Count; i++)
{
if (ByDateList[i].EntryDate <= onDateTime)
{
qty += ByDateList[i].Quantity;
}
}
return qty;
}
} }
} }

View File

@@ -10,7 +10,7 @@ namespace bnhtrade.Core.Model.Stock
{ {
public int StockStatusId { get; set; } public int StockStatusId { get; set; }
public string Sku { get; set; } public string SkuNumber { get; set; }
public int Balance public int Balance
{ {

View File

@@ -0,0 +1,26 @@
using bnhtrade.Core.Data.Database.Stock;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace bnhtrade.Core.Model.Stock
{
public class StatusType
{
public StatusType(int stockStatusTypeId, string name, string foreignKeyType, string referenceType, Model.Account.Account account)
{
StockStatusTypeID = stockStatusTypeId;
StatusTypeName = name;
ForeignKeyType = foreignKeyType;
ReferenceType = referenceType;
Account = account;
}
public int StockStatusTypeID { get; private set; }
public string StatusTypeName { get; private set; }
public string ForeignKeyType { get; private set; }
public string ReferenceType { get; private set; }
public Model.Account.Account Account { get; private set; }
}
}

View File

@@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace bnhtrade.Core.Test.Amazon
{
public class Amazon
{
public Amazon()
{
var stock = new Stock();
stock.GetReplenishmentList();
}
public class Stock
{
public void GetReplenishmentList()
{
var read = new bnhtrade.Core.Logic.Amazon.Fba.Stock();
var resut = read.GetReplenishmentList();
}
}
}
}

View File

@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using bnhtrade.Core.Data.Database.Stock;
namespace bnhtrade.Core.Test.Stock namespace bnhtrade.Core.Test.Stock
{ {
@@ -11,8 +12,9 @@ namespace bnhtrade.Core.Test.Stock
public Stock() public Stock()
{ {
// method you want to start here // method you want to start here
ReadStockStatus();
} }
public void ReadStatusBalance() public void ReadStatusBalance()
{ {
var result = new bnhtrade.Core.Data.Database.Stock.ReadStatusTransaction() var result = new bnhtrade.Core.Data.Database.Stock.ReadStatusTransaction()
@@ -26,7 +28,15 @@ namespace bnhtrade.Core.Test.Stock
var atDate = new DateTime(2017, 02, 01, 21, 54, 30); var atDate = new DateTime(2017, 02, 01, 21, 54, 30);
DateTime.TryParse("22/12/2017 16:35:58", out atDate); DateTime.TryParse("22/12/2017 16:35:58", out atDate);
var result = new Core.Logic.Stock.StatusBalance().GetBySku(sku, statusId); var result = new Core.Logic.Stock.StatusBalance().GetStatusBalance(sku, statusId);
int i = 0;
}
public void StatusBalance2()
{
int statusId = 16; // Inventory, Reserved (Garage Stock)
var result = new Core.Logic.Stock.StatusBalance().GetSkuQuantity(statusId);
int i = result.Values.ToList().Sum();
int y = 0;
} }
public void ReadStockId() public void ReadStockId()
@@ -47,5 +57,14 @@ namespace bnhtrade.Core.Test.Stock
{ {
new bnhtrade.Core.Logic.Stock.SkuTransactionReconcile().UnReconcileTransaction(transactoinId); new bnhtrade.Core.Logic.Stock.SkuTransactionReconcile().UnReconcileTransaction(transactoinId);
} }
public void ReadStockStatus()
{
var db = new Status();
db.StatusIds = new List<int> { 3, 4, 5, 6, 7, 11, 12, 13, 15 };
db.StatusTypeIds = new List<int> { 12, 5 };
var result = db.Read();
int i = 0;
}
} }
} }

View File

@@ -183,7 +183,10 @@
<Compile Include="Data\Database\Stock\InsertSkuTransactionType.cs" /> <Compile Include="Data\Database\Stock\InsertSkuTransactionType.cs" />
<Compile Include="Data\Database\Stock\JournalCrud.cs" /> <Compile Include="Data\Database\Stock\JournalCrud.cs" />
<Compile Include="Data\Database\Stock\ReadStatusTypeBalance.cs" /> <Compile Include="Data\Database\Stock\ReadStatusTypeBalance.cs" />
<Compile Include="Data\Database\Stock\Status.cs" />
<Compile Include="Data\Database\Stock\StatusType.cs" />
<Compile Include="Logic\Amazon\Fba\Fnsku.cs" /> <Compile Include="Logic\Amazon\Fba\Fnsku.cs" />
<Compile Include="Logic\Amazon\Fba\Stock.cs" />
<Compile Include="Logic\Import\Amazon.cs" /> <Compile Include="Logic\Import\Amazon.cs" />
<Compile Include="Logic\Import\AmazonFbaInventoryAdjustment.cs" /> <Compile Include="Logic\Import\AmazonFbaInventoryAdjustment.cs" />
<Compile Include="Data\Database\Import\AmazonFbaInventoryAgeData.cs" /> <Compile Include="Data\Database\Import\AmazonFbaInventoryAgeData.cs" />
@@ -234,7 +237,7 @@
<Compile Include="Logic\Product\AmazonEstimateFee.cs" /> <Compile Include="Logic\Product\AmazonEstimateFee.cs" />
<Compile Include="Logic\Product\GetProductInfo.cs" /> <Compile Include="Logic\Product\GetProductInfo.cs" />
<Compile Include="Logic\Sku\GetSkuInfo.cs" /> <Compile Include="Logic\Sku\GetSkuInfo.cs" />
<Compile Include="Logic\Stock\GetStatusTypeBalance.cs" /> <Compile Include="Logic\Stock\StatusTypeBalance.cs" />
<Compile Include="Logic\Stock\SkuTransactionImport.cs" /> <Compile Include="Logic\Stock\SkuTransactionImport.cs" />
<Compile Include="Logic\Stock\StatusBalance.cs" /> <Compile Include="Logic\Stock\StatusBalance.cs" />
<Compile Include="Logic\Utilities\EasyMD5.cs" /> <Compile Include="Logic\Utilities\EasyMD5.cs" />
@@ -271,7 +274,7 @@
<Compile Include="Logic\Utilities\StringCheck.cs" /> <Compile Include="Logic\Utilities\StringCheck.cs" />
<Compile Include="Logic\Utilities\AccountVat.cs" /> <Compile Include="Logic\Utilities\AccountVat.cs" />
<Compile Include="Logic\Validate\SkuPriceInfo.cs" /> <Compile Include="Logic\Validate\SkuPriceInfo.cs" />
<Compile Include="Model\Account\AccountCode.cs" /> <Compile Include="Model\Account\Account.cs" />
<Compile Include="Model\Account\InvoiceHeader.cs" /> <Compile Include="Model\Account\InvoiceHeader.cs" />
<Compile Include="Model\Account\Invoice.cs" /> <Compile Include="Model\Account\Invoice.cs" />
<Compile Include="Model\Account\InvoiceLineItem.cs" /> <Compile Include="Model\Account\InvoiceLineItem.cs" />
@@ -303,8 +306,10 @@
<Compile Include="Model\Stock\SkuTransactionCreate.cs" /> <Compile Include="Model\Stock\SkuTransactionCreate.cs" />
<Compile Include="Model\Stock\SkuTransactionType.cs" /> <Compile Include="Model\Stock\SkuTransactionType.cs" />
<Compile Include="Model\Stock\SkuTransaction.cs" /> <Compile Include="Model\Stock\SkuTransaction.cs" />
<Compile Include="Model\Stock\Status.cs" />
<Compile Include="Model\Stock\StatusBalance.cs" /> <Compile Include="Model\Stock\StatusBalance.cs" />
<Compile Include="Model\Stock\StatusTransaction.cs" /> <Compile Include="Model\Stock\StatusTransaction.cs" />
<Compile Include="Model\Stock\StatusType.cs" />
<Compile Include="Test\Account\Account.cs" /> <Compile Include="Test\Account\Account.cs" />
<Compile Include="Test\Amazon\SP-API\FulfillmentInboundV0.cs" /> <Compile Include="Test\Amazon\SP-API\FulfillmentInboundV0.cs" />
<Compile Include="Test\Amazon\SP-API\Reports.cs" /> <Compile Include="Test\Amazon\SP-API\Reports.cs" />
@@ -315,6 +320,7 @@
<Compile Include="Test\InboundShipmentInfo.cs" /> <Compile Include="Test\InboundShipmentInfo.cs" />
<Compile Include="Logic\AmazonFBAInbound\ShipmentAddByFNSKU.cs" /> <Compile Include="Logic\AmazonFBAInbound\ShipmentAddByFNSKU.cs" />
<Compile Include="Test\InboundShipmentInfoSync.cs" /> <Compile Include="Test\InboundShipmentInfoSync.cs" />
<Compile Include="Test\Amazon\Amazon.cs" />
<Compile Include="Test\Logic\Export.cs" /> <Compile Include="Test\Logic\Export.cs" />
<Compile Include="Test\Sku\Sku.cs" /> <Compile Include="Test\Sku\Sku.cs" />
<Compile Include="Test\SQLLoop.cs" /> <Compile Include="Test\SQLLoop.cs" />

View File

@@ -264,8 +264,8 @@ namespace bnhtradeScheduledTasks
Console.WriteLine("<5> Test Logic"); Console.WriteLine("<5> Test Logic");
Console.WriteLine("<6> Test SKU"); Console.WriteLine("<6> Test SKU");
Console.WriteLine("<7> Test Stock"); Console.WriteLine("<7> Test Stock");
Console.WriteLine("<8> Test Amazon SP-API Report"); Console.WriteLine("<8> Test Amazon SP-API");
Console.WriteLine("<9> "); Console.WriteLine("<9> Test Amazon");
Console.WriteLine("<a> Test SP-API Fulfilment Inbound"); Console.WriteLine("<a> Test SP-API Fulfilment Inbound");
Console.WriteLine(); Console.WriteLine();
Console.WriteLine("<0> Back"); Console.WriteLine("<0> Back");
@@ -360,6 +360,7 @@ namespace bnhtradeScheduledTasks
{ {
Console.Clear(); Console.Clear();
new bnhtrade.Core.Test.Amazon.Amazon();
Console.WriteLine("Nothing to do here"); Console.WriteLine("Nothing to do here");