mirror of
https://github.com/stokebob/bnhtrade.git
synced 2026-03-19 06:27:15 +00:00
Export amazon settlement report fix
This commit is contained in:
19
src/bnhtrade.Core/Test/Account/GetTaxInfo.cs
Normal file
19
src/bnhtrade.Core/Test/Account/GetTaxInfo.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace bnhtrade.Core.Test.Account
|
||||
{
|
||||
public class GetTaxInfo
|
||||
{
|
||||
public GetTaxInfo(string sqlConnectionString)
|
||||
{
|
||||
//var inst = new Data.Database.Account.GetTaxCode(sqlConnectionString);
|
||||
//inst.
|
||||
|
||||
//var taxInfo = inst.GetAll();
|
||||
}
|
||||
}
|
||||
}
|
||||
31
src/bnhtrade.Core/Test/AutoExec.cs
Normal file
31
src/bnhtrade.Core/Test/AutoExec.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace bnhtrade.Core.Test
|
||||
{
|
||||
public class AutoExec
|
||||
{
|
||||
private string sqlConnectionString;
|
||||
|
||||
public AutoExec(string sqlConnectionString)
|
||||
{
|
||||
this.sqlConnectionString = sqlConnectionString;
|
||||
|
||||
// --------------- start this ------------------- //
|
||||
AmazonSettlement();
|
||||
}
|
||||
private void AmazonSettlement()
|
||||
{
|
||||
var instance = new Core.Logic.Export.AmazonSettlementData(sqlConnectionString);
|
||||
instance.ToInvoice();
|
||||
}
|
||||
|
||||
private void Import()
|
||||
{
|
||||
var instance = new Test.Import.AmazonSettlement(sqlConnectionString);
|
||||
}
|
||||
}
|
||||
}
|
||||
25
src/bnhtrade.Core/Test/Import/AmazonSettlement.cs
Normal file
25
src/bnhtrade.Core/Test/Import/AmazonSettlement.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace bnhtrade.Core.Test.Import
|
||||
{
|
||||
public class AmazonSettlement
|
||||
{
|
||||
private string sqlConnectionString;
|
||||
public AmazonSettlement(string sqlConnectionString)
|
||||
{
|
||||
this.sqlConnectionString = sqlConnectionString;
|
||||
ReadSettlementFromDatabase();
|
||||
}
|
||||
|
||||
public void ReadSettlementFromDatabase()
|
||||
{
|
||||
|
||||
var instance = new Data.Database.Import.ReadAmazonSettlement(sqlConnectionString);
|
||||
var answer = instance.BySettlementId("11796400482");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -74,10 +74,5 @@ namespace bnhtrade.Core.Test
|
||||
var result = task.GetShipmentInfo();
|
||||
|
||||
}
|
||||
public void Test()
|
||||
{
|
||||
var job = new Logic.AmazonFBAInbound.UpdateDatabaseShipmentInfo(sqlConnectionString);
|
||||
job.GetNew();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
26
src/bnhtrade.Core/Test/Logic/Export.cs
Normal file
26
src/bnhtrade.Core/Test/Logic/Export.cs
Normal 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.Logic
|
||||
{
|
||||
public class Export
|
||||
{
|
||||
private string sqlConnectionString;
|
||||
public Export(string sqlConnectionString)
|
||||
{
|
||||
this.sqlConnectionString = sqlConnectionString;
|
||||
|
||||
// method you want to start here
|
||||
UpdateXeroWithAmzonSettlementData();
|
||||
|
||||
}
|
||||
public void UpdateXeroWithAmzonSettlementData()
|
||||
{
|
||||
var instance = new bnhtrade.Core.Logic.Export.AmazonSettlementData(sqlConnectionString);
|
||||
instance.ToInvoice();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -30,7 +30,7 @@ namespace bnhtrade.Core.Test
|
||||
total = (int)cmd.ExecuteScalar();
|
||||
}
|
||||
|
||||
var progress = new UI.Utility.ConsoleProgressBar(total, "Processing " + total + " records...");
|
||||
var progress = new UI.Console.ProgressBar(total, "Processing " + total + " records...");
|
||||
|
||||
using (SqlCommand cmd = new SqlCommand(@"
|
||||
SELECT * FROM tblStockJournal
|
||||
|
||||
139
src/bnhtrade.Core/Test/_BoilerPlate/ClassFromSql.cs
Normal file
139
src/bnhtrade.Core/Test/_BoilerPlate/ClassFromSql.cs
Normal file
@@ -0,0 +1,139 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace bnhtrade.Core.Test._BoilerPlate
|
||||
{
|
||||
class ClassFromSql
|
||||
{
|
||||
/* copy the following code in SSMS query, set variables and execute
|
||||
|
||||
DECLARE @TableName VARCHAR(MAX) = 'tblOrder' -- Replace 'tblOrder' with your table name
|
||||
DECLARE @TableSchema VARCHAR(MAX) = NULL -- If required, replace NULL with your schema name i.e. 'Markets'
|
||||
DECLARE @result varchar(max) = ''
|
||||
|
||||
SET @result = @result + 'using System;' + CHAR(13) + CHAR(13)
|
||||
|
||||
IF (@TableSchema IS NOT NULL)
|
||||
BEGIN
|
||||
SET @result = @result + 'namespace ' + @TableSchema + CHAR(13) + '{' + CHAR(13)
|
||||
END
|
||||
|
||||
SET @result = @result + 'public class ' + @TableName + CHAR(13) + '{'
|
||||
|
||||
SELECT
|
||||
@result = @result + CHAR(13)
|
||||
+ ' public ' + ColumnType + ' ' + ColumnName + ' { get; set; } '
|
||||
FROM (SELECT
|
||||
c.COLUMN_NAME AS ColumnName,
|
||||
CASE c.DATA_TYPE
|
||||
WHEN 'bigint' THEN CASE C.IS_NULLABLE
|
||||
WHEN 'YES' THEN 'Int64?'
|
||||
ELSE 'Int64'
|
||||
END
|
||||
WHEN 'binary' THEN 'Byte[]'
|
||||
WHEN 'bit' THEN CASE C.IS_NULLABLE
|
||||
WHEN 'YES' THEN 'bool?'
|
||||
ELSE 'bool'
|
||||
END
|
||||
WHEN 'char' THEN 'string'
|
||||
WHEN 'date' THEN CASE C.IS_NULLABLE
|
||||
WHEN 'YES' THEN 'DateTime?'
|
||||
ELSE 'DateTime'
|
||||
END
|
||||
WHEN 'datetime' THEN CASE C.IS_NULLABLE
|
||||
WHEN 'YES' THEN 'DateTime?'
|
||||
ELSE 'DateTime'
|
||||
END
|
||||
WHEN 'datetime2' THEN CASE C.IS_NULLABLE
|
||||
WHEN 'YES' THEN 'DateTime?'
|
||||
ELSE 'DateTime'
|
||||
END
|
||||
WHEN 'datetimeoffset' THEN CASE C.IS_NULLABLE
|
||||
WHEN 'YES' THEN 'DateTimeOffset?'
|
||||
ELSE 'DateTimeOffset'
|
||||
END
|
||||
WHEN 'decimal' THEN CASE C.IS_NULLABLE
|
||||
WHEN 'YES' THEN 'decimal?'
|
||||
ELSE 'decimal'
|
||||
END
|
||||
WHEN 'float' THEN CASE C.IS_NULLABLE
|
||||
WHEN 'YES' THEN 'Single?'
|
||||
ELSE 'Single'
|
||||
END
|
||||
WHEN 'image' THEN 'Byte[]'
|
||||
WHEN 'int' THEN CASE C.IS_NULLABLE
|
||||
WHEN 'YES' THEN 'int?'
|
||||
ELSE 'int'
|
||||
END
|
||||
WHEN 'money' THEN CASE C.IS_NULLABLE
|
||||
WHEN 'YES' THEN 'decimal?'
|
||||
ELSE 'decimal'
|
||||
END
|
||||
WHEN 'nchar' THEN 'string'
|
||||
WHEN 'ntext' THEN 'string'
|
||||
WHEN 'numeric' THEN CASE C.IS_NULLABLE
|
||||
WHEN 'YES' THEN 'decimal?'
|
||||
ELSE 'decimal'
|
||||
END
|
||||
WHEN 'nvarchar' THEN 'string'
|
||||
WHEN 'real' THEN CASE C.IS_NULLABLE
|
||||
WHEN 'YES' THEN 'Double?'
|
||||
ELSE 'Double'
|
||||
END
|
||||
WHEN 'smalldatetime' THEN CASE C.IS_NULLABLE
|
||||
WHEN 'YES' THEN 'DateTime?'
|
||||
ELSE 'DateTime'
|
||||
END
|
||||
WHEN 'smallint' THEN CASE C.IS_NULLABLE
|
||||
WHEN 'YES' THEN 'Int16?'
|
||||
ELSE 'Int16'
|
||||
END
|
||||
WHEN 'smallmoney' THEN CASE C.IS_NULLABLE
|
||||
WHEN 'YES' THEN 'decimal?'
|
||||
ELSE 'decimal'
|
||||
END
|
||||
WHEN 'text' THEN 'string'
|
||||
WHEN 'time' THEN CASE C.IS_NULLABLE
|
||||
WHEN 'YES' THEN 'TimeSpan?'
|
||||
ELSE 'TimeSpan'
|
||||
END
|
||||
WHEN 'timestamp' THEN 'Byte[]'
|
||||
WHEN 'tinyint' THEN CASE C.IS_NULLABLE
|
||||
WHEN 'YES' THEN 'Byte?'
|
||||
ELSE 'Byte'
|
||||
END
|
||||
WHEN 'uniqueidentifier' THEN CASE C.IS_NULLABLE
|
||||
WHEN 'YES' THEN 'Guid?'
|
||||
ELSE 'Guid'
|
||||
END
|
||||
WHEN 'varbinary' THEN 'Byte[]'
|
||||
WHEN 'varchar' THEN 'string'
|
||||
ELSE 'Object'
|
||||
END AS ColumnType,
|
||||
c.ORDINAL_POSITION
|
||||
FROM INFORMATION_SCHEMA.COLUMNS c
|
||||
WHERE c.TABLE_NAME = @TableName
|
||||
AND ISNULL(@TableSchema, c.TABLE_SCHEMA) = c.TABLE_SCHEMA) t
|
||||
ORDER BY t.ORDINAL_POSITION
|
||||
|
||||
SET @result = @result + CHAR(13)
|
||||
|
||||
SET @result = @result + '}' + CHAR(13)
|
||||
|
||||
IF (@TableSchema IS NOT NULL)
|
||||
BEGIN
|
||||
SET @result = @result + CHAR(13) + '}'
|
||||
END
|
||||
|
||||
PRINT @result
|
||||
*/
|
||||
}
|
||||
|
||||
class ourputy
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
196
src/bnhtrade.Core/Test/_BoilerPlate/Sql.cs
Normal file
196
src/bnhtrade.Core/Test/_BoilerPlate/Sql.cs
Normal file
@@ -0,0 +1,196 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.SqlClient;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Transactions;
|
||||
|
||||
namespace bnhtrade.Core.Test._BoilerPlate
|
||||
{
|
||||
public class Sql
|
||||
{
|
||||
public void Select()
|
||||
{
|
||||
using (SqlConnection conn = new SqlConnection())
|
||||
{
|
||||
conn.Open();
|
||||
|
||||
using (SqlCommand cmd = new SqlCommand(@"
|
||||
SELECT
|
||||
column01
|
||||
,column02
|
||||
,column03
|
||||
,column04
|
||||
FROM tblTable
|
||||
WHERE
|
||||
column01 = @value01
|
||||
OR column01 = @value02
|
||||
OR column01 = @value03
|
||||
OR column01 = @value04
|
||||
", conn))
|
||||
{
|
||||
cmd.Parameters.AddWithValue("@value01", "xxxxxxxx");
|
||||
cmd.Parameters.AddWithValue("@value02", "xxxxxxxx");
|
||||
cmd.Parameters.AddWithValue("@value03", "xxxxxxxx");
|
||||
cmd.Parameters.AddWithValue("@value04", "xxxxxxxx");
|
||||
|
||||
using (SqlDataReader reader = cmd.ExecuteReader())
|
||||
{
|
||||
if (!reader.HasRows)
|
||||
{
|
||||
// do something
|
||||
}
|
||||
else
|
||||
{
|
||||
while (reader.Read())
|
||||
{
|
||||
// do some thing with the data
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public string SelectByList(List<string> stringList)
|
||||
{
|
||||
// check input list for items
|
||||
if (stringList == null || !stringList.Any())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
// build SQL string
|
||||
string sqlString = @"
|
||||
SELECT
|
||||
value01
|
||||
,value02
|
||||
FROM
|
||||
tblTable
|
||||
WHERE
|
||||
";
|
||||
|
||||
var parameterValueList = new List<Tuple<string, string>>();
|
||||
foreach (var item in stringList)
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(item))
|
||||
{
|
||||
int count = parameterValueList.Count;
|
||||
var parameterValue = new Tuple<string, string>("@parameter" + count, item);
|
||||
parameterValueList.Add(parameterValue);
|
||||
if (count == 0)
|
||||
{
|
||||
sqlString = sqlString + @"
|
||||
value01 = " + parameterValue.Item1;
|
||||
}
|
||||
else
|
||||
{
|
||||
sqlString = sqlString + @"
|
||||
OR value01 = " + parameterValue.Item1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (parameterValueList.Count == 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
// execute query and build result list
|
||||
var skuTaxCodeList = new List<Tuple<string, string>>();
|
||||
using (SqlConnection conn = new SqlConnection())
|
||||
{
|
||||
conn.Open();
|
||||
|
||||
using (SqlCommand cmd = new SqlCommand(sqlString, conn))
|
||||
{
|
||||
foreach (var item in parameterValueList)
|
||||
{
|
||||
cmd.Parameters.AddWithValue(item.Item1, item.Item2);
|
||||
}
|
||||
|
||||
using (SqlDataReader reader = cmd.ExecuteReader())
|
||||
{
|
||||
if (!reader.HasRows)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
while (reader.Read())
|
||||
{
|
||||
// read data and build return object
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return "Complete"; // return object
|
||||
}
|
||||
public void Insert()
|
||||
{
|
||||
using (TransactionScope scope = new TransactionScope())
|
||||
{
|
||||
using (SqlConnection conn = new SqlConnection())
|
||||
{
|
||||
conn.Open();
|
||||
|
||||
using (SqlCommand cmd = new SqlCommand(@"
|
||||
INSERT INTO tblTable (
|
||||
column01
|
||||
,column02
|
||||
,column03
|
||||
,column04
|
||||
)
|
||||
OUTPUT INSERTED.TablePk
|
||||
VALUES (
|
||||
@value01
|
||||
,@value02
|
||||
,@value03
|
||||
,@value04
|
||||
)
|
||||
", conn))
|
||||
{
|
||||
cmd.Parameters.AddWithValue("@value01", "xxxxxxxx");
|
||||
cmd.Parameters.AddWithValue("@value02", "xxxxxxxx");
|
||||
cmd.Parameters.AddWithValue("@value03", "xxxxxxxx");
|
||||
cmd.Parameters.AddWithValue("@value04", "xxxxxxxx");
|
||||
|
||||
int tablePk = (int)cmd.ExecuteScalar();
|
||||
}
|
||||
}
|
||||
scope.Complete();
|
||||
}
|
||||
}
|
||||
public void Update()
|
||||
{
|
||||
using (TransactionScope scope = new TransactionScope())
|
||||
{
|
||||
using (SqlConnection conn = new SqlConnection())
|
||||
{
|
||||
conn.Open();
|
||||
|
||||
using (SqlCommand cmd = new SqlCommand(@"
|
||||
UPDATE
|
||||
tblTable
|
||||
SET
|
||||
column01 = @value01
|
||||
column02 = @value02
|
||||
column03 = @value03
|
||||
column04 = @value04
|
||||
WHERE
|
||||
column05 = @value05
|
||||
", conn))
|
||||
{
|
||||
cmd.Parameters.AddWithValue("@value01", "xxxxxxxx");
|
||||
cmd.Parameters.AddWithValue("@value02", "xxxxxxxx");
|
||||
cmd.Parameters.AddWithValue("@value03", "xxxxxxxx");
|
||||
cmd.Parameters.AddWithValue("@value04", "xxxxxxxx");
|
||||
cmd.Parameters.AddWithValue("@value04", "xxxxxxxx");
|
||||
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
}
|
||||
scope.Complete();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user