mirror of
https://github.com/stokebob/bnhtrade.git
synced 2026-03-19 22:47:15 +00:00
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:
@@ -1,8 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
|
||||
<appSettings configSource="app.local.config" />
|
||||
|
||||
<configSections>
|
||||
</configSections>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
|
||||
</startup>
|
||||
@@ -18,7 +17,7 @@
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Microsoft.Bcl.AsyncInterfaces" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-7.0.0.0" newVersion="7.0.0.0" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-8.0.0.0" newVersion="8.0.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
||||
@@ -38,7 +37,7 @@
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Text.Json" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-7.0.0.2" newVersion="7.0.0.2" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-8.0.0.3" newVersion="8.0.0.3" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
|
||||
@@ -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());
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace bnhtrade_Scheduled_Tasks.Properties {
|
||||
|
||||
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.4.0.0")]
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.9.0.0")]
|
||||
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
|
||||
|
||||
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="..\..\packages\ILMerge.3.0.29\build\ILMerge.props" Condition="Exists('..\..\packages\ILMerge.3.0.29\build\ILMerge.props')" />
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
@@ -36,7 +35,7 @@
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>..\..\artifiacts\Debug\</OutputPath>
|
||||
<OutputPath>..\..\bin\Debug\console\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
@@ -45,7 +44,7 @@
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugType>none</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>..\..\artifiacts\Release\</OutputPath>
|
||||
<OutputPath>..\..\bin\Release\console\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
@@ -76,10 +75,6 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="App.config" />
|
||||
<None Include="app.local.config">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="packages.config" />
|
||||
<None Include="Properties\Settings.settings">
|
||||
<Generator>SettingsSingleFileGenerator</Generator>
|
||||
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
||||
@@ -104,13 +99,7 @@
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
||||
<PropertyGroup>
|
||||
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
|
||||
</PropertyGroup>
|
||||
<Error Condition="!Exists('..\..\packages\ILMerge.3.0.29\build\ILMerge.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\ILMerge.3.0.29\build\ILMerge.props'))" />
|
||||
</Target>
|
||||
<PropertyGroup>
|
||||
<PostBuildEvent>xcopy /E /Y "$(SolutionDir)artifiacts\Release" "C:\Users\Bobbie\Dropbox\Apps\bnhtrade"</PostBuildEvent>
|
||||
<PostBuildEvent>xcopy /E /Y "$(TargetDir)" "C:\Users\Bobbie\Dropbox\Apps\bnhtrade"</PostBuildEvent>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
@@ -1,4 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="ILMerge" version="3.0.29" targetFramework="net471" />
|
||||
</packages>
|
||||
Reference in New Issue
Block a user