SP-API stock reconciliation

Amazon had depreciated a number of reports that were used for stock reconciliation. Application now uses the new fba ledger report to reconcile. It is currently untested, as this requires data from Amazon. Methods that require testing will return a 'NotImplementedException'.

Also, removed the depreciated ILMerge and replaced with ILRepack.

Plus much more tidying up, and improvements.
This commit is contained in:
Bobbie Hodgetts
2024-05-07 08:24:00 +01:00
committed by GitHub
parent 2f919d7b5a
commit 91ef9acc78
1272 changed files with 4944 additions and 2773311 deletions
+23 -65
View File
@@ -1,54 +1,20 @@
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Configuration;
using System.Transactions;
using bnhtrade.Core;
using bnhtrade.Core.Stock;
using bnhtrade.Core.Model;
namespace bnhtradeScheduledTasks
{
class Program
{
static private bnhtrade.Core.Model.Credentials.bnhtradeDB dbCredentials;
static private bnhtrade.Core.Model.Credentials.AmazonSPAPI spapiCredentials;
static Program()
{
dbCredentials = new bnhtrade.Core.Model.Credentials.bnhtradeDB(
ConfigurationManager.AppSettings["DbDataSource"]
, ConfigurationManager.AppSettings["DbUserId"]
, ConfigurationManager.AppSettings["DbUserPassword"]
);
spapiCredentials = new bnhtrade.Core.Model.Credentials.AmazonSPAPI(
ConfigurationManager.AppSettings["SpapiAccessKey"]
, ConfigurationManager.AppSettings["SpapiSecretKey"]
, ConfigurationManager.AppSettings["SpapiRoleArn"]
, ConfigurationManager.AppSettings["SpapiClientId"]
, ConfigurationManager.AppSettings["SpapiClientSecret"]
, ConfigurationManager.AppSettings["SpapiRefreshToken"]
);
}
//public static string BNHtradeDbConnectionString()
//{
// return ConfigurationManager.ConnectionStrings["bnhtradeDbConnString"].ConnectionString;
//}
static void Main(string[] args)
{
//string sqlConnectionString = BNHtradeDbConnectionString();
if (args.Length == 0)
{
// get db connection string
//string sqlConnectionString = BNHtradeDbConnectionString();
string consoleHeader = "Welcome to THE application!\n";
do
@@ -104,7 +70,7 @@ namespace bnhtradeScheduledTasks
else if (input == "1")
{
Console.Clear();
new bnhtrade.Core.Logic.Utilities.NightlyRoutine(spapiCredentials, dbCredentials).DownloadAll();
new bnhtrade.Core.Logic.Utilities.NightlyRoutine().DownloadAll();
Console.WriteLine("Complete, press any key to continue...");
Console.ReadKey();
}
@@ -125,8 +91,8 @@ namespace bnhtradeScheduledTasks
else if (input == "4")
{
Console.Clear();
new bnhtrade.Core.Logic.Import.AmazonSettlement(spapiCredentials).SyncDatabase(dbCredentials.ConnectionString);
new bnhtrade.Core.Logic.Export.AmazonSettlement(dbCredentials.ConnectionString).ToInvoice();
new bnhtrade.Core.Logic.Import.AmazonSettlement().SyncDatabase();
new bnhtrade.Core.Logic.Export.AmazonSettlement().ToInvoice();
Console.WriteLine("Complete, press any key to continue...");
Console.ReadKey();
}
@@ -196,10 +162,9 @@ namespace bnhtradeScheduledTasks
else if (input == "1")
{
Console.Clear();
var task = new StockReconciliation();
try
{
task.UpdateFbaStockImportData(dbCredentials.ConnectionString);
new bnhtrade.Core.Logic.Import.Amazon().SyncAllWithDatabase();
}
catch (Exception ex)
{
@@ -211,10 +176,9 @@ namespace bnhtradeScheduledTasks
else if (input == "2")
{
Console.Clear();
var task = new StockReconciliation();
try
{
task.ProcessFbaStockImportData(dbCredentials.ConnectionString);
new bnhtrade.Core.Logic.Stock.SkuTransactionImport().ImportAll();
}
catch (Exception ex)
{
@@ -228,7 +192,7 @@ namespace bnhtradeScheduledTasks
Console.Clear();
//try
//{
var recon = new bnhtrade.Core.Logic.Stock.SkuTransactionReconcile(dbCredentials.ConnectionString);
var recon = new bnhtrade.Core.Logic.Stock.SkuTransactionReconcile();
recon.ReconcileStockTransactions(false);
Console.WriteLine(recon.ItemsCompleted + " of " + (recon.ItemsCompleted + recon.ItemsRemaining) + " items completed.");
Console.WriteLine("Current transaction ID=" + recon.CurrentSkuTransaction.SkuTransactionId);
@@ -245,12 +209,11 @@ namespace bnhtradeScheduledTasks
else if (input == "4")
{
Console.Clear();
var task = new StockReconciliation();
try
{
task.UpdateFbaStockImportData(dbCredentials.ConnectionString);
task.ProcessFbaStockImportData(dbCredentials.ConnectionString);
new bnhtrade.Core.Logic.Stock.SkuTransactionReconcile(dbCredentials.ConnectionString).ReconcileStockTransactions(false);
new bnhtrade.Core.Logic.Import.Amazon().SyncAllWithDatabase();
new bnhtrade.Core.Logic.Stock.SkuTransactionImport().ImportAll();
new bnhtrade.Core.Logic.Stock.SkuTransactionReconcile().ReconcileStockTransactions(false);
}
catch (Exception ex)
{
@@ -282,7 +245,7 @@ namespace bnhtradeScheduledTasks
else if (input == "8")
{
Console.Clear();
new bnhtrade.Core.Logic.Utilities.NightlyRoutine(spapiCredentials, dbCredentials).DownloadAll();
new bnhtrade.Core.Logic.Utilities.NightlyRoutine().DownloadAll();
Console.WriteLine("Complete, press any key to continue...");
Console.ReadKey();
}
@@ -301,8 +264,8 @@ namespace bnhtradeScheduledTasks
Console.WriteLine("<5> Test Logic");
Console.WriteLine("<6> Test SKU");
Console.WriteLine("<7> Test Stock");
Console.WriteLine("<8> Test AmazonMWS Report");
Console.WriteLine("<9> Test Log");
Console.WriteLine("<8> Test Amazon SP-API Report");
Console.WriteLine("<9> ");
Console.WriteLine("<a> Test SP-API Fulfilment Inbound");
Console.WriteLine();
Console.WriteLine("<0> Back");
@@ -327,7 +290,7 @@ namespace bnhtradeScheduledTasks
{
Console.Clear();
new bnhtrade.Core.Test.Account.Account(dbCredentials.ConnectionString);
new bnhtrade.Core.Test.Account.Account();
Console.WriteLine("Done");
Console.WriteLine("Complete, press any key to continue...");
@@ -347,7 +310,7 @@ namespace bnhtradeScheduledTasks
{
Console.Clear();
new bnhtrade.Core.Test.Import.Report(dbCredentials, spapiCredentials);
new bnhtrade.Core.Test.Import.Report();
Console.WriteLine("Done");
Console.WriteLine("Complete, press any key to continue...");
@@ -357,7 +320,7 @@ namespace bnhtradeScheduledTasks
{
Console.Clear();
new bnhtrade.Core.Test.Logic.Logic(dbCredentials.ConnectionString);
new bnhtrade.Core.Test.Logic.Logic();
Console.WriteLine("Done");
Console.WriteLine("Complete, press any key to continue...");
@@ -367,7 +330,7 @@ namespace bnhtradeScheduledTasks
{
Console.Clear();
new bnhtrade.Core.Logic.Sku.Price.FbaPricing(dbCredentials.ConnectionString).Update();
new bnhtrade.Core.Logic.Sku.Price.FbaPricing().Update();
Console.WriteLine("Done");
Console.WriteLine("Complete, press any key to continue...");
@@ -377,7 +340,7 @@ namespace bnhtradeScheduledTasks
{
Console.Clear();
new bnhtrade.Core.Test.Stock.Stock(dbCredentials.ConnectionString);
new bnhtrade.Core.Test.Stock.Stock();
Console.WriteLine("Done");
Console.WriteLine("Complete, press any key to continue...");
@@ -387,7 +350,7 @@ namespace bnhtradeScheduledTasks
{
Console.Clear();
new bnhtrade.Core.Test.Amazon.MWS.Report(dbCredentials.ConnectionString);
new bnhtrade.Core.Test.Amazon.SP_API.Reports();
Console.WriteLine("Done");
Console.WriteLine("Complete, press any key to continue...");
@@ -397,13 +360,9 @@ namespace bnhtradeScheduledTasks
{
Console.Clear();
var timeeee = new DateTime(2014, 9, 1);
var logdate = new bnhtrade.Core.Data.Database.Log.DateTimeLog();
logdate.NewDateTimeUtc("_GET_AMAZON_FULFILLED_SHIPMENTS_DATA_", timeeee);
logdate.NewDateTimeUtc("_GET_FBA_FULFILLMENT_CUSTOMER_RETURNS_DATA_", timeeee);
logdate.NewDateTimeUtc("_GET_FBA_FULFILLMENT_INVENTORY_ADJUSTMENTS_DATA_", timeeee);
logdate.NewDateTimeUtc("_GET_FBA_REIMBURSEMENTS_DATA_", timeeee);
logdate.NewDateTimeUtc("_GET_FBA_FULFILLMENT_REMOVAL_ORDER_DETAIL_DATA_", timeeee);
Console.WriteLine("Nothing to do here");
Console.WriteLine("Done");
Console.WriteLine("Complete, press any key to continue...");
@@ -437,7 +396,7 @@ namespace bnhtradeScheduledTasks
Console.WriteLine("Starting all reports download...");
Thread.Sleep(3000);
Console.Clear();
new bnhtrade.Core.Logic.Utilities.NightlyRoutine(spapiCredentials, dbCredentials).DownloadAll();
new bnhtrade.Core.Logic.Utilities.NightlyRoutine().DownloadAll();
Console.WriteLine("Finished!! Exiting application...");
Thread.Sleep(3000);
}
@@ -445,8 +404,7 @@ namespace bnhtradeScheduledTasks
{
Console.WriteLine("Starting (unsafe) stock reconciliation...");
Console.Clear();
StockReconciliation task = new StockReconciliation();
var recon = new bnhtrade.Core.Logic.Stock.SkuTransactionReconcile(dbCredentials.ConnectionString);
var recon = new bnhtrade.Core.Logic.Stock.SkuTransactionReconcile();
recon.ReconcileStockTransactions(false);
Console.WriteLine("Progress: " + recon.ProgressMessage);
Console.WriteLine("Reconciled date: " + recon.LastItemDateTime.ToString());