mirror of
https://github.com/stokebob/bnhtrade.git
synced 2026-03-19 14:37:16 +00:00
Migrated projects to dotnet8
migrated all projects over to .net8 incomplete feature for gui shipments
This commit is contained in:
@@ -42,6 +42,70 @@
|
||||
<assemblyIdentity name="System.Text.Json" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-8.0.0.3" newVersion="8.0.0.3" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Microsoft.IdentityModel.Abstractions" publicKeyToken="31bf3856ad364e35" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-7.5.1.0" newVersion="7.5.1.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Security.Cryptography.ProtectedData" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-8.0.0.0" newVersion="8.0.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Security.AccessControl" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-6.0.0.1" newVersion="6.0.0.1" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Diagnostics.DiagnosticSource" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-8.0.0.1" newVersion="8.0.0.1" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Text.Encodings.Web" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-8.0.0.0" newVersion="8.0.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Buffers" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Microsoft.Identity.Client" publicKeyToken="0a613f4dd989e8ae" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.60.3.0" newVersion="4.60.3.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Azure.Core" publicKeyToken="92742159e12e44c8" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-1.39.0.0" newVersion="1.39.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Azure.Identity" publicKeyToken="92742159e12e44c8" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-1.11.3.0" newVersion="1.11.3.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Microsoft.IdentityModel.Protocols.OpenIdConnect" publicKeyToken="31bf3856ad364e35" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-7.5.1.0" newVersion="7.5.1.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Microsoft.IdentityModel.Protocols" publicKeyToken="31bf3856ad364e35" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-7.5.1.0" newVersion="7.5.1.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Microsoft.IdentityModel.Tokens" publicKeyToken="31bf3856ad364e35" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-7.5.1.0" newVersion="7.5.1.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.IdentityModel.Tokens.Jwt" publicKeyToken="31bf3856ad364e35" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-7.5.1.0" newVersion="7.5.1.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Microsoft.IdentityModel.JsonWebTokens" publicKeyToken="31bf3856ad364e35" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-7.5.1.0" newVersion="7.5.1.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Microsoft.IdentityModel.Logging" publicKeyToken="31bf3856ad364e35" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-7.5.1.0" newVersion="7.5.1.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Memory.Data" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-8.0.0.0" newVersion="8.0.0.0" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
</configuration>
|
||||
|
||||
@@ -7,7 +7,6 @@ using System.IO;
|
||||
using static FikaAmazonAPI.Utils.Constants;
|
||||
using System.Linq;
|
||||
using CsvHelper.Configuration;
|
||||
using NUnit.Framework.Interfaces;
|
||||
|
||||
namespace bnhtrade.Core.Data.Amazon.Report
|
||||
{
|
||||
|
||||
@@ -86,6 +86,25 @@ namespace bnhtrade.Core.Data.Amazon.Report
|
||||
ReportProcessingStatus = ProcessingStatus.NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Return a list of report that are currently available filtered parameters set in class
|
||||
/// </summary>
|
||||
/// <returns>report list</returns>
|
||||
protected IList<FikaAmazonAPI.AmazonSpApiSDK.Models.Reports.Report> ListAvailableReports()
|
||||
{
|
||||
var parameters = new ParameterReportList();
|
||||
parameters.reportTypes = new List<ReportTypes>() { reportType };
|
||||
parameters.marketplaceIds.Add(amznConn.GetCurrentMarketplace.ID);
|
||||
|
||||
// request from amazon
|
||||
return amznConn.Reports.GetReports(parameters);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// For reports that require a start and end period to report over.
|
||||
/// </summary>
|
||||
@@ -169,6 +188,22 @@ namespace bnhtrade.Core.Data.Amazon.Report
|
||||
}
|
||||
}
|
||||
|
||||
DownloadReport(reportId);
|
||||
}
|
||||
|
||||
protected void DownloadByReportId(string reportId)
|
||||
{
|
||||
Init();
|
||||
DownloadReport(reportId);
|
||||
}
|
||||
|
||||
private void DownloadReport(string reportId)
|
||||
{
|
||||
if (report == null)
|
||||
{
|
||||
WaitWhileProcessing(reportId);
|
||||
}
|
||||
|
||||
// test for processing status
|
||||
if (report.ProcessingStatus == FikaAmazonAPI.AmazonSpApiSDK.Models.Reports.Report.ProcessingStatusEnum.DONE)
|
||||
{
|
||||
@@ -246,12 +281,19 @@ namespace bnhtrade.Core.Data.Amazon.Report
|
||||
}
|
||||
|
||||
// save to file
|
||||
string reportFilePath = Config.GetTempFileDirectoryPath() + @"\SP-API-Reports\ " + report.ReportType.ToString() + " reportId_" + reportId + ".txt";
|
||||
string dirPath = Config.GetTempFileDirectoryPath() + @"\SP-API-Reports\";
|
||||
System.IO.Directory.CreateDirectory(dirPath);
|
||||
string reportFilePath = dirPath + report.ReportType.ToString() + " reportId_" + reportId + ".txt";
|
||||
System.IO.File.WriteAllText(reportFilePath, reportString);
|
||||
log.LogInformation("Amazon report #" + reportId + " sucessfully saved to disk.");
|
||||
this.ReportFilePath = reportFilePath;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// If a duplicate report has been recently requested, Amazon may return 'FATAL'. This method tests for, and attempts to retrive the duplicate report that is causing the error.
|
||||
/// </summary>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using bnhtrade.Core.Data.Amazon.SellingPartnerAPI;
|
||||
using FikaAmazonAPI;
|
||||
using FikaAmazonAPI.Parameter.Report;
|
||||
using FikaAmazonAPI.Utils;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@@ -10,11 +11,9 @@ using static FikaAmazonAPI.Utils.Constants;
|
||||
|
||||
namespace bnhtrade.Core.Data.Amazon.Report
|
||||
{
|
||||
public class SettlementReport
|
||||
public class SettlementReport : ReportLogic
|
||||
{
|
||||
private AmazonConnection amznConn = new SpApiConnection().Connection;
|
||||
|
||||
public SettlementReport ()
|
||||
public SettlementReport () : base(ReportTypes.GET_V2_SETTLEMENT_REPORT_DATA_FLAT_FILE_V2)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -25,28 +24,22 @@ namespace bnhtrade.Core.Data.Amazon.Report
|
||||
public List<string> ListAvaliableReports()
|
||||
{
|
||||
UI.Console.WriteLine("Requesting list of avaliable settlement reports form Amazon SP-API");
|
||||
var reportList = ListAvailableReports();
|
||||
|
||||
// set parameters
|
||||
var parameters = new ParameterReportList();
|
||||
parameters.reportTypes = new List<ReportTypes>() { ReportTypes.GET_V2_SETTLEMENT_REPORT_DATA_FLAT_FILE_V2};
|
||||
parameters.marketplaceIds.Add(amznConn.GetCurrentMarketplace.ID);
|
||||
|
||||
// request from amazon
|
||||
var result = amznConn.Reports.GetReports(parameters);
|
||||
|
||||
var returnList = new List<string>();
|
||||
foreach (var report in result)
|
||||
var reportIdList = new List<string>();
|
||||
foreach (var report in reportList)
|
||||
{
|
||||
returnList.Add(report.ReportId);
|
||||
reportIdList.Add(report.ReportId);
|
||||
}
|
||||
|
||||
UI.Console.WriteLine("{0} Settlement reports avaible on Amazon SP-API");
|
||||
return returnList;
|
||||
return reportIdList;
|
||||
}
|
||||
|
||||
public string GetFile(string reportId)
|
||||
public string GetReportFile(string reportId)
|
||||
{
|
||||
return amznConn.Reports.GetReportFile(reportId);
|
||||
DownloadByReportId(reportId);
|
||||
return ReportFilePath;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
//using System.Data.SqlClient;
|
||||
using System.Data.SqlClient;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
208
src/bnhtrade.Core/Data/Database/Account/CreateJournal.cs
Normal file
208
src/bnhtrade.Core/Data/Database/Account/CreateJournal.cs
Normal file
@@ -0,0 +1,208 @@
|
||||
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.Data.Database.Account
|
||||
{
|
||||
internal class CreateJournal : Connection
|
||||
{
|
||||
/// <summary>
|
||||
/// Old code needs sorting
|
||||
/// </summary>
|
||||
public int AccountJournalInsert(int journalTypeId, DateTime entryDate, string currencyCode,
|
||||
decimal amount, int debitAccountId = 0, int creditAccountId = 0, bool lockEntry = false)
|
||||
{
|
||||
int defaultDebit = 0;
|
||||
int defaultCredit = 0;
|
||||
|
||||
// ensure date is UTC
|
||||
entryDate = DateTime.SpecifyKind(entryDate, DateTimeKind.Utc);
|
||||
|
||||
// debit and credit locks are checked in journal post method
|
||||
using (TransactionScope scope = new TransactionScope())
|
||||
using (SqlConnection conn = new SqlConnection(SqlConnectionString))
|
||||
{
|
||||
conn.Open();
|
||||
|
||||
// insert the journal entry
|
||||
int journalId;
|
||||
|
||||
using (SqlCommand cmd = new SqlCommand(@"
|
||||
INSERT INTO tblAccountJournal
|
||||
(AccountJournalTypeID, EntryDate, IsLocked)
|
||||
OUTPUT INSERTED.AccountJournalID
|
||||
VALUES
|
||||
(@journalTypeId, @entryDate, @lockEntry)
|
||||
", conn))
|
||||
{
|
||||
// add parameters
|
||||
cmd.Parameters.AddWithValue("@journalTypeId", journalTypeId);
|
||||
cmd.Parameters.AddWithValue("@entryDate", entryDate.ToUniversalTime());
|
||||
cmd.Parameters.AddWithValue("@lockEntry", lockEntry);
|
||||
|
||||
//execute
|
||||
journalId = (int)cmd.ExecuteScalar();
|
||||
}
|
||||
|
||||
// insert journal entries
|
||||
//bool postResult = AccountJournalPostInsert(sqlConnectionString, journalId, entryDate, currencyCode, amount, debitAccountId, creditAccountId);
|
||||
bool postResult = AccountJournalPostInsert(journalId, entryDate, currencyCode, amount, debitAccountId, creditAccountId);
|
||||
|
||||
scope.Complete();
|
||||
return journalId;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Old code needs sorting
|
||||
/// </summary>
|
||||
internal bool AccountJournalPostInsert(int journalId, DateTime entryDate,
|
||||
string currencyCode, decimal amount, int debitAccountId = 0, int creditAccountId = 0)
|
||||
{
|
||||
int defaultDebit;
|
||||
int defaultCredit;
|
||||
entryDate = DateTime.SpecifyKind(entryDate, DateTimeKind.Utc);
|
||||
|
||||
using (TransactionScope scope = new TransactionScope())
|
||||
using (SqlConnection conn = new SqlConnection(SqlConnectionString))
|
||||
{
|
||||
conn.Open();
|
||||
|
||||
// ensure their are no other entries
|
||||
using (SqlCommand cmd = new SqlCommand(@"
|
||||
SELECT
|
||||
Count(tblAccountJournalPost.AccountJournalPostID) AS CountOfAccountJournalPostID
|
||||
FROM
|
||||
tblAccountJournalPost
|
||||
WHERE
|
||||
(((tblAccountJournalPost.AccountJournalID)=@AccountJournalID));
|
||||
", conn))
|
||||
{
|
||||
cmd.Parameters.AddWithValue("@AccountJournalID", journalId);
|
||||
|
||||
int count = (int)cmd.ExecuteScalar();
|
||||
|
||||
if (count > 0)
|
||||
{
|
||||
throw new Exception("Unable the insert journal posts, post already present AccountJournalID=" + journalId);
|
||||
}
|
||||
}
|
||||
|
||||
//checks
|
||||
using (SqlCommand cmd = new SqlCommand(@"
|
||||
SELECT
|
||||
tblAccountJournalType.ChartOfAccountID_Debit, tblAccountJournalType.ChartOfAccountID_Credit
|
||||
FROM
|
||||
tblAccountJournal
|
||||
INNER JOIN tblAccountJournalType
|
||||
ON tblAccountJournal.AccountJournalTypeID = tblAccountJournalType.AccountJournalTypeID
|
||||
WHERE
|
||||
(((tblAccountJournal.AccountJournalID)=@journalId));
|
||||
", conn))
|
||||
{
|
||||
cmd.Parameters.AddWithValue("@journalId", journalId);
|
||||
|
||||
using (SqlDataReader reader = cmd.ExecuteReader())
|
||||
{
|
||||
if (reader.Read())
|
||||
{
|
||||
// debit check
|
||||
if (reader.IsDBNull(0))
|
||||
{
|
||||
if (debitAccountId == 0)
|
||||
{
|
||||
throw new Exception("Debit Account ID required, default not set for journal type");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
defaultDebit = reader.GetInt32(0);
|
||||
if (debitAccountId == 0)
|
||||
{
|
||||
debitAccountId = defaultDebit;
|
||||
}
|
||||
else if (debitAccountId != defaultDebit)
|
||||
{
|
||||
throw new Exception("Debit Account ID supplied does not match default set for journal type");
|
||||
}
|
||||
|
||||
}
|
||||
// credit check
|
||||
if (reader.IsDBNull(1))
|
||||
{
|
||||
if (creditAccountId == 0)
|
||||
{
|
||||
throw new Exception("Credit Account ID required, default not set for journal type");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
defaultCredit = reader.GetInt32(1);
|
||||
if (creditAccountId == 0)
|
||||
{
|
||||
creditAccountId = defaultCredit;
|
||||
}
|
||||
else if (creditAccountId != defaultCredit)
|
||||
{
|
||||
throw new Exception("Credit Account ID supplied does not match default set for journal type");
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("AccountJournalID '" + journalId + "' does not exist.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// currency conversion
|
||||
if (currencyCode != "GBP")
|
||||
{
|
||||
amount = new Data.Database.Account.Currency().CurrencyConvertToGbp(currencyCode, amount, entryDate);
|
||||
}
|
||||
|
||||
// ensure decimal is rounded
|
||||
amount = Math.Round(amount, 2);
|
||||
|
||||
// insert debit post
|
||||
using (SqlCommand cmd = new SqlCommand(@"
|
||||
INSERT INTO tblAccountJournalPost
|
||||
(AccountJournalID, AccountChartOfID, AmountGbp)
|
||||
VALUES
|
||||
(@AccountJournalId, @AccountChartOfId, @AmountGbp)
|
||||
", conn))
|
||||
{
|
||||
// add parameters
|
||||
cmd.Parameters.AddWithValue("@AccountJournalId", journalId);
|
||||
cmd.Parameters.AddWithValue("@AccountChartOfId", debitAccountId);
|
||||
cmd.Parameters.AddWithValue("@AmountGbp", amount);
|
||||
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
|
||||
// insert credit post
|
||||
using (SqlCommand cmd = new SqlCommand(@"
|
||||
INSERT INTO tblAccountJournalPost
|
||||
(AccountJournalID, AccountChartOfID, AmountGbp)
|
||||
VALUES
|
||||
(@AccountJournalId, @AccountChartOfId, @AmountGbp)
|
||||
", conn))
|
||||
{
|
||||
// add parameters
|
||||
cmd.Parameters.AddWithValue("@AccountJournalId", journalId);
|
||||
cmd.Parameters.AddWithValue("@AccountChartOfId", creditAccountId);
|
||||
cmd.Parameters.AddWithValue("@AmountGbp", (amount * -1));
|
||||
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
|
||||
scope.Complete();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
199
src/bnhtrade.Core/Data/Database/Account/Currency.cs
Normal file
199
src/bnhtrade.Core/Data/Database/Account/Currency.cs
Normal file
@@ -0,0 +1,199 @@
|
||||
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.Account
|
||||
{
|
||||
internal class Currency : Connection
|
||||
{
|
||||
public decimal CurrencyConvertToGbp(string currencyCode, decimal amount, DateTime conversionDate)
|
||||
{
|
||||
if (currencyCode == "GBP" || amount == 0M)
|
||||
{
|
||||
return amount;
|
||||
}
|
||||
|
||||
if (currencyCode.Length != 3)
|
||||
{
|
||||
throw new Exception("Invalid currency code '" + currencyCode + "'");
|
||||
}
|
||||
|
||||
using (SqlConnection sqlConn = new SqlConnection(SqlConnectionString))
|
||||
{
|
||||
sqlConn.Open();
|
||||
|
||||
using (SqlCommand cmd = new SqlCommand(@"
|
||||
SELECT CurrencyUnitsPerGBP
|
||||
FROM tblAccountExchangeRate
|
||||
WHERE CurrencyCode=@currencyCode AND StartDate<=@conversionDate AND EndDate>@conversionDate
|
||||
", sqlConn))
|
||||
{
|
||||
cmd.Parameters.AddWithValue("@currencyCode", currencyCode);
|
||||
cmd.Parameters.AddWithValue("@conversionDate", conversionDate);
|
||||
|
||||
object result = cmd.ExecuteScalar();
|
||||
if (result != null)
|
||||
{
|
||||
return amount / Convert.ToDecimal(result);
|
||||
}
|
||||
}
|
||||
|
||||
// return reason for no record found
|
||||
using (SqlCommand cmd = new SqlCommand(@"
|
||||
SELECT CurrencyUnitsPerGBP
|
||||
FROM tblAccountExchangeRate
|
||||
WHERE CurrencyCode=@currencyCode
|
||||
", sqlConn))
|
||||
{
|
||||
cmd.Parameters.AddWithValue("@currencyCode", currencyCode);
|
||||
|
||||
object result = cmd.ExecuteScalar();
|
||||
if (result == null)
|
||||
{
|
||||
throw new Exception("Currency code '" + currencyCode + "' does not exist in Exchange Rate table");
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("Date range for " + currencyCode + " " + conversionDate.ToShortDateString() + " " +
|
||||
conversionDate.ToLongTimeString() + "' does not exist in Exchange Rate table");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int CurrencyExchangeRateInsert(int exchangeRateSource, string currencyCode,
|
||||
decimal currencyUnitsPerGbp, DateTime periodStart, DateTime periodEnd, bool checkOverride = false)
|
||||
{
|
||||
currencyUnitsPerGbp = decimal.Round(currencyUnitsPerGbp, 4);
|
||||
periodStart = DateTime.SpecifyKind(periodStart, DateTimeKind.Utc);
|
||||
periodEnd = DateTime.SpecifyKind(periodEnd, DateTimeKind.Utc);
|
||||
|
||||
// CHECKS
|
||||
// HMRC source only
|
||||
if (exchangeRateSource != 1)
|
||||
{
|
||||
throw new Exception("Function does not currently accept exchange rates from sources other than HMRC");
|
||||
}
|
||||
// currency code upper case only
|
||||
currencyCode = currencyCode.ToUpper();
|
||||
if (currencyCode.Length != 3)
|
||||
{
|
||||
throw new Exception("Invalid currency code '" + currencyCode + "'");
|
||||
}
|
||||
|
||||
if (periodEnd <= periodStart)
|
||||
{
|
||||
throw new Exception("Invalid date period.");
|
||||
}
|
||||
|
||||
if (checkOverride == false && (periodEnd - periodStart).Days > 31)
|
||||
{
|
||||
throw new Exception("Date period is greater than 31 days.");
|
||||
}
|
||||
|
||||
// retirve previous data
|
||||
DateTime? periodEndLast = null;
|
||||
using (SqlConnection sqlConn = new SqlConnection(SqlConnectionString))
|
||||
{
|
||||
sqlConn.Open();
|
||||
|
||||
using (SqlCommand cmd = new SqlCommand(@"
|
||||
SELECT Max(tblAccountExchangeRate.EndDate) AS MaxOfEndDate
|
||||
FROM tblAccountExchangeRate
|
||||
WHERE (((tblAccountExchangeRate.CurrencyCode) = @currencyCode))
|
||||
", sqlConn))
|
||||
{
|
||||
cmd.Parameters.AddWithValue("@currencyCode", currencyCode);
|
||||
|
||||
object obj = cmd.ExecuteScalar();
|
||||
|
||||
// currency code not existing
|
||||
if (obj == DBNull.Value && checkOverride == false)
|
||||
{
|
||||
throw new Exception("Currency code '" + currencyCode + "' does not exist in table");
|
||||
}
|
||||
// currency code exists
|
||||
else
|
||||
{
|
||||
periodEndLast = DateTime.SpecifyKind(Convert.ToDateTime(obj), DateTimeKind.Utc);
|
||||
|
||||
if (periodStart != periodEndLast)
|
||||
{
|
||||
throw new Exception("Invalid period start date -- must equal previous period end-date.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// retrive previous exchange rate and check
|
||||
decimal currencyUnitsPerGbpLast = 0;
|
||||
if (periodEndLast != null)
|
||||
{
|
||||
using (SqlCommand cmd = new SqlCommand(@"
|
||||
SELECT tblAccountExchangeRate.AccountExchangeRateID, tblAccountExchangeRate.CurrencyUnitsPerGBP
|
||||
FROM tblAccountExchangeRate
|
||||
WHERE (tblAccountExchangeRate.EndDate = @periodEndLast)
|
||||
AND (CurrencyCode = @currencyCode);
|
||||
", sqlConn))
|
||||
{
|
||||
cmd.Parameters.AddWithValue("@periodEndLast", periodEndLast);
|
||||
cmd.Parameters.AddWithValue("@currencyCode", currencyCode);
|
||||
|
||||
using (var reader = cmd.ExecuteReader())
|
||||
{
|
||||
if (reader.Read())
|
||||
{
|
||||
currencyUnitsPerGbpLast = reader.GetDecimal(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("Error that shouldn't happen! Check code @ 5129f3e6-2f7e-4883-bc73-b317d8fa4050");
|
||||
}
|
||||
// error if >1 line
|
||||
if (reader.Read())
|
||||
{
|
||||
string errText = "Multiple lines in currency exchange table for '" + currencyCode + "' where [EndDate]=" + periodEndLast.ToString();
|
||||
new Logic.Log.LogEvent().LogError(errText);
|
||||
throw new Exception(errText);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// check difference between current and previous exchange rates isn't too great
|
||||
if (checkOverride == false &&
|
||||
(currencyUnitsPerGbpLast > (currencyUnitsPerGbp * 1.05m) || currencyUnitsPerGbpLast < (currencyUnitsPerGbp * 0.95m))
|
||||
)
|
||||
{
|
||||
throw new Exception("Difference between supplied and previous exchange rates is greater than 5%");
|
||||
}
|
||||
|
||||
// MAKE THE INSERT
|
||||
int recordId = 0;
|
||||
using (SqlCommand cmd = new SqlCommand(@"
|
||||
INSERT INTO tblAccountExchangeRate (ExchangeRateSource, CurrencyCode, CurrencyUnitsPerGBP, StartDate, EndDate)
|
||||
OUTPUT INSERTED.AccountExchangeRateID
|
||||
VALUES (@exchangeRateSource, @currencyCode, @currencyUnitsPerGbp, @periodStart, @periodEnd);
|
||||
", sqlConn))
|
||||
{
|
||||
cmd.Parameters.AddWithValue("@exchangeRateSource", exchangeRateSource);
|
||||
cmd.Parameters.AddWithValue("@currencyCode", currencyCode);
|
||||
cmd.Parameters.AddWithValue("@currencyUnitsPerGbp", currencyUnitsPerGbp);
|
||||
cmd.Parameters.AddWithValue("@periodStart", periodStart);
|
||||
cmd.Parameters.AddWithValue("@periodEnd", periodEnd);
|
||||
|
||||
recordId = (int)cmd.ExecuteScalar();
|
||||
|
||||
if (recordId < 1)
|
||||
{
|
||||
throw new Exception("Error inserting record, did not retrive new record ID.");
|
||||
}
|
||||
}
|
||||
|
||||
return recordId;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
64
src/bnhtrade.Core/Data/Database/Account/DeleteJournal.cs
Normal file
64
src/bnhtrade.Core/Data/Database/Account/DeleteJournal.cs
Normal file
@@ -0,0 +1,64 @@
|
||||
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.Data.Database.Account
|
||||
{
|
||||
internal class DeleteJournal : Connection
|
||||
{
|
||||
/// <summary>
|
||||
/// Old code needs sorting
|
||||
/// </summary>
|
||||
public bool AccountJournalDelete(int accountJournalId)
|
||||
{
|
||||
// check if journal entry is locked
|
||||
using (TransactionScope scope = new TransactionScope())
|
||||
{
|
||||
bool IsLocked = new Data.Database.Account.ReadJournal().EntryIsLocked(accountJournalId);
|
||||
if (IsLocked == true)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
using (SqlConnection conn = new SqlConnection(SqlConnectionString))
|
||||
{
|
||||
conn.Open();
|
||||
|
||||
// make the delete
|
||||
using (SqlCommand cmd = new SqlCommand(@"
|
||||
DELETE FROM tblAccountJournalPost
|
||||
WHERE AccountJournalID=@accountJournalId;
|
||||
", conn))
|
||||
{
|
||||
cmd.Parameters.AddWithValue("@accountJournalId", accountJournalId);
|
||||
|
||||
int rows = cmd.ExecuteNonQuery();
|
||||
|
||||
if (rows == 0)
|
||||
{
|
||||
throw new Exception("Journal entry and/or entry posts do not exist for AccountJournalId=" + accountJournalId);
|
||||
}
|
||||
}
|
||||
|
||||
using (SqlCommand cmd = new SqlCommand(@"
|
||||
DELETE FROM tblAccountJournal
|
||||
WHERE AccountJournalID=@accountJournalId;
|
||||
", conn))
|
||||
{
|
||||
cmd.Parameters.AddWithValue("@accountJournalId", accountJournalId);
|
||||
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
|
||||
scope.Complete();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -10,7 +10,6 @@ namespace bnhtrade.Core.Data.Database.Account
|
||||
public class ReadAccountCode : Connection
|
||||
{
|
||||
private Data.Database.SqlWhereBuilder sqlWhere = new SqlWhereBuilder();
|
||||
private List<Model.Account.Account> resultList;
|
||||
|
||||
public ReadAccountCode()
|
||||
{
|
||||
@@ -27,26 +26,45 @@ namespace bnhtrade.Core.Data.Database.Account
|
||||
var dictionary = new Dictionary<uint, Model.Account.Account>();
|
||||
foreach (var item in list)
|
||||
{
|
||||
dictionary.Add(item.Id, item);
|
||||
dictionary.Add(item.Value.Id, item.Value);
|
||||
}
|
||||
return dictionary;
|
||||
}
|
||||
|
||||
public List<Model.Account.Account> ByAccountCode(List<int> accountCodeList)
|
||||
public Dictionary<uint, Model.Account.Account> ByAccountId(List<uint> accountIdList)
|
||||
{
|
||||
Innit();
|
||||
var resultDict = new Dictionary<uint, Model.Account.Account>();
|
||||
|
||||
if (accountIdList == null || !accountIdList.Any())
|
||||
{
|
||||
return resultDict;
|
||||
}
|
||||
|
||||
sqlWhere.In("tblAccountChartOf.AccountChartOfID", accountIdList, " WHERE ");
|
||||
resultDict = Execute(sqlWhere.SqlWhereString, sqlWhere.ParameterList);
|
||||
return resultDict;
|
||||
}
|
||||
|
||||
public Dictionary<uint, Model.Account.Account> ByAccountCode(List<int> accountCodeList)
|
||||
{
|
||||
Innit();
|
||||
var resultDict = new Dictionary<uint, Model.Account.Account>();
|
||||
|
||||
if (accountCodeList == null || !accountCodeList.Any())
|
||||
{
|
||||
return resultList;
|
||||
return resultDict;
|
||||
}
|
||||
|
||||
sqlWhere.In("tblAccountChartOf.AccountCode", accountCodeList, " WHERE ");
|
||||
return Execute(sqlWhere.SqlWhereString, sqlWhere.ParameterList);
|
||||
resultDict = Execute(sqlWhere.SqlWhereString, sqlWhere.ParameterList);
|
||||
return resultDict;
|
||||
}
|
||||
|
||||
private List<Model.Account.Account> Execute(string sqlWhere, Dictionary<string, object> parameters)
|
||||
private Dictionary<uint, Model.Account.Account> Execute(string sqlWhere, Dictionary<string, object> parameters)
|
||||
{
|
||||
var resultDict = new Dictionary<uint, Model.Account.Account>();
|
||||
|
||||
//build sql query
|
||||
string sqlString = @"
|
||||
SELECT tblAccountChartOf.AccountChartOfID
|
||||
@@ -91,18 +109,18 @@ namespace bnhtrade.Core.Data.Database.Account
|
||||
int multiplier = reader.GetInt32(6);
|
||||
|
||||
var result = new Model.Account.Account(tablePk, accountCode, title, description, type, basicType, multiplier);
|
||||
resultList.Add(result);
|
||||
resultDict.Add(tablePk, result);
|
||||
}
|
||||
}
|
||||
return resultList;
|
||||
}
|
||||
}
|
||||
}
|
||||
return resultDict;
|
||||
}
|
||||
|
||||
private void Innit()
|
||||
{
|
||||
resultList = new List<Model.Account.Account>();
|
||||
sqlWhere.Init();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
105
src/bnhtrade.Core/Data/Database/Account/ReadContact.cs
Normal file
105
src/bnhtrade.Core/Data/Database/Account/ReadContact.cs
Normal file
@@ -0,0 +1,105 @@
|
||||
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.Account
|
||||
{
|
||||
internal class ReadContact : Connection
|
||||
{
|
||||
private bnhtrade.Core.Data.Database.SqlWhereBuilder sqlBuilder;
|
||||
|
||||
public List<int> ContactIdList { get; set; }
|
||||
|
||||
public ReadContact()
|
||||
{
|
||||
Init();
|
||||
}
|
||||
|
||||
public void Init()
|
||||
{
|
||||
sqlBuilder = new SqlWhereBuilder();
|
||||
ContactIdList = new List<int>();
|
||||
}
|
||||
|
||||
public Dictionary<int, Model.Account.Contact> Read()
|
||||
{
|
||||
var returnList = new Dictionary<int, Model.Account.Contact>();
|
||||
sqlBuilder.Init();
|
||||
|
||||
//build sql query
|
||||
string sql = @"
|
||||
SELECT [ContactID]
|
||||
,[ContactName]
|
||||
,[PaypalName]
|
||||
,[PaypalEmail]
|
||||
,[EbayUsername]
|
||||
,[EbayEmail]
|
||||
,[RecordCreated]
|
||||
,[RecordModified]
|
||||
FROM [e2A].[dbo].[tblContact]
|
||||
WHERE 1=1 ";
|
||||
|
||||
// build the where statments
|
||||
if (ContactIdList.Any())
|
||||
{
|
||||
sqlBuilder.In("[ContactID]", ContactIdList, "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)
|
||||
{
|
||||
while (reader.Read())
|
||||
{
|
||||
int contactId = reader.GetInt32(0);
|
||||
string contactName = null;
|
||||
if (!reader.IsDBNull(1)) { contactName = reader.GetString(1); }
|
||||
string paypalName = null;
|
||||
if (!reader.IsDBNull(2)) { paypalName = reader.GetString(2); }
|
||||
string paypalEmail = null;
|
||||
if (!reader.IsDBNull(3)) { paypalEmail = reader.GetString(3); }
|
||||
string ebayUsername = null;
|
||||
if (!reader.IsDBNull(4)) { ebayUsername = reader.GetString(4); }
|
||||
string ebayEmail = null;
|
||||
if (!reader.IsDBNull(5)) { ebayEmail = reader.GetString(5); }
|
||||
DateTime recordCreated = DateTime.SpecifyKind(reader.GetDateTime(6), DateTimeKind.Utc);
|
||||
DateTime? recordModified = null;
|
||||
if (!reader.IsDBNull(7)) { recordModified = DateTime.SpecifyKind(reader.GetDateTime(7), DateTimeKind.Utc); }
|
||||
|
||||
var contact = new Model.Account.Contact();
|
||||
contact.ContactId = contactId;
|
||||
contact.ContantName = contactName;
|
||||
contact.ContactPaypalName = paypalName;
|
||||
contact.ContactPaypalEmail = paypalEmail;
|
||||
contact.ContactEbayName = ebayUsername;
|
||||
contact.ContactEbayEmail = ebayEmail;
|
||||
contact.Created = recordCreated;
|
||||
contact.Modified = recordModified;
|
||||
|
||||
returnList.Add(contactId, contact);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return returnList;
|
||||
}
|
||||
}
|
||||
}
|
||||
242
src/bnhtrade.Core/Data/Database/Account/ReadJournal.cs
Normal file
242
src/bnhtrade.Core/Data/Database/Account/ReadJournal.cs
Normal file
@@ -0,0 +1,242 @@
|
||||
using FikaAmazonAPI.AmazonSpApiSDK.Models.CatalogItems;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.SqlClient;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices.Marshalling;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using static System.ComponentModel.Design.ObjectSelectorEditor;
|
||||
|
||||
namespace bnhtrade.Core.Data.Database.Account
|
||||
{
|
||||
internal class ReadJournal : Connection
|
||||
{
|
||||
private bnhtrade.Core.Data.Database.SqlWhereBuilder sqlBuilder;
|
||||
|
||||
/// <summary>
|
||||
/// Filter the read results
|
||||
/// </summary>
|
||||
public List<uint> AccountJournalId { get; set; }
|
||||
|
||||
public ReadJournal()
|
||||
{
|
||||
Init();
|
||||
}
|
||||
|
||||
public void Init()
|
||||
{
|
||||
sqlBuilder = new SqlWhereBuilder();
|
||||
AccountJournalId = new List<uint>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <returns>Dictionary were key is the table primary key</returns>
|
||||
public Dictionary<uint, Core.Model.Account.Journal> Read()
|
||||
{
|
||||
sqlBuilder.Init();
|
||||
|
||||
//build sql query
|
||||
string sql = @"
|
||||
SELECT tblAccountJournal.AccountJournalID
|
||||
,tblAccountJournal.AccountJournalTypeID
|
||||
,tblAccountJournal.EntryDate
|
||||
,tblAccountJournal.PostDate
|
||||
,tblAccountJournal.LastModified
|
||||
,tblAccountJournal.IsLocked
|
||||
,tblAccountJournalPost.AccountJournalPostID
|
||||
,tblAccountJournalPost.AccountChartOfID
|
||||
,tblAccountJournalPost.AmountGbp
|
||||
FROM tblAccountJournal
|
||||
INNER JOIN tblAccountJournalPost ON tblAccountJournal.AccountJournalID = tblAccountJournalPost.AccountJournalID
|
||||
WHERE 1 = 1 ";
|
||||
|
||||
// build the where statments
|
||||
if (AccountJournalId.Any())
|
||||
{
|
||||
sqlBuilder.In("tblAccountJournal.AccountJournalID", AccountJournalId, "AND");
|
||||
}
|
||||
|
||||
// append where string to the sql
|
||||
if (sqlBuilder.IsSetSqlWhereString)
|
||||
{
|
||||
sql = sql + sqlBuilder.SqlWhereString;
|
||||
}
|
||||
|
||||
// build tuple list
|
||||
var dbJournalList = new List<(
|
||||
uint AccountJournalId
|
||||
, uint AccountJournalTypeId
|
||||
, DateTime EntryDate
|
||||
, DateTime PostDate
|
||||
, DateTime LastModified
|
||||
, bool IsLocked
|
||||
)>();
|
||||
|
||||
var dbJournalPostList = new List<(
|
||||
uint AccountJournalId
|
||||
, uint AccountJournalPostId
|
||||
, uint AccountChartOfId
|
||||
, decimal AmountGbp
|
||||
)>();
|
||||
|
||||
|
||||
bool hasRows = false;
|
||||
|
||||
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)
|
||||
{
|
||||
hasRows = true;
|
||||
uint lastJournalId = 0;
|
||||
while (reader.Read())
|
||||
{
|
||||
// read journal header
|
||||
uint journalId = (uint)reader.GetInt32(0);
|
||||
if (journalId != lastJournalId)
|
||||
{
|
||||
lastJournalId = journalId;
|
||||
|
||||
(uint AccountJournalId
|
||||
, uint AccountJournalTypeId
|
||||
, DateTime EntryDate
|
||||
, DateTime PostDate
|
||||
, DateTime LastModified
|
||||
, bool IsLocked
|
||||
)
|
||||
journal =
|
||||
( journalId
|
||||
, (uint)reader.GetInt32(1)
|
||||
, DateTime.SpecifyKind(reader.GetDateTime(2), DateTimeKind.Utc)
|
||||
, DateTime.SpecifyKind(reader.GetDateTime(3), DateTimeKind.Utc)
|
||||
, DateTime.SpecifyKind(reader.GetDateTime(4), DateTimeKind.Utc)
|
||||
, reader.GetBoolean(5)
|
||||
);
|
||||
|
||||
dbJournalList.Add(journal);
|
||||
}
|
||||
|
||||
// read journal posts
|
||||
(uint AccountJournalId
|
||||
, uint AccountJournalPostId
|
||||
, uint AccountChartOfId
|
||||
, decimal AmountGbp
|
||||
)
|
||||
journalPost =
|
||||
( journalId
|
||||
, (uint)reader.GetInt32(6)
|
||||
, (uint)reader.GetInt32(7)
|
||||
, reader.GetDecimal(8)
|
||||
);
|
||||
|
||||
dbJournalPostList.Add(journalPost);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var returnList = new Dictionary<uint, Core.Model.Account.Journal>();
|
||||
if (hasRows)
|
||||
{
|
||||
// build lists to filter db results by
|
||||
var journalTypeIdList = new List<uint>();
|
||||
var accountIdList = new List<uint>();
|
||||
foreach (var item in dbJournalList)
|
||||
{
|
||||
journalTypeIdList.Add(item.AccountJournalTypeId);
|
||||
}
|
||||
foreach (var item in dbJournalPostList)
|
||||
{
|
||||
accountIdList.Add(item.AccountChartOfId);
|
||||
}
|
||||
|
||||
// get journalTypes from db
|
||||
var dbJournalType = new Data.Database.Account.ReadJournalType();
|
||||
dbJournalType.IdList = journalTypeIdList;
|
||||
var journalTypeDict = dbJournalType.Read();
|
||||
|
||||
// get accounts from db
|
||||
var dbAccount = new Data.Database.Account.ReadAccountCode();
|
||||
var accountDict = dbAccount.ByAccountId(accountIdList);
|
||||
|
||||
// build final return dictionary
|
||||
foreach (var dbJournal in dbJournalList)
|
||||
{
|
||||
// build posts
|
||||
var newPosts = new List<Core.Model.Account.Journal.Post>();
|
||||
foreach (var dbJournalPost in dbJournalPostList)
|
||||
{
|
||||
if (dbJournalPost.AccountJournalId == dbJournal.AccountJournalId)
|
||||
{
|
||||
var newPost = new Core.Model.Account.Journal.Post(
|
||||
dbJournalPost.AccountJournalPostId
|
||||
, accountDict[dbJournalPost.AccountChartOfId]
|
||||
, dbJournalPost.AmountGbp);
|
||||
|
||||
newPosts.Add(newPost);
|
||||
}
|
||||
}
|
||||
|
||||
// create the journal
|
||||
var newJournal = new Core.Model.Account.Journal(
|
||||
dbJournal.AccountJournalId
|
||||
, journalTypeDict[dbJournal.AccountJournalTypeId]
|
||||
, newPosts
|
||||
, dbJournal.EntryDate
|
||||
, dbJournal.PostDate
|
||||
, dbJournal.LastModified
|
||||
, dbJournal.IsLocked);
|
||||
|
||||
returnList.Add(dbJournal.AccountJournalId, newJournal);
|
||||
}
|
||||
}
|
||||
// all done, return the list herevar
|
||||
return returnList;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test for locked journal entry
|
||||
/// </summary>
|
||||
/// <returns>False on locked journal entry</returns>
|
||||
public bool EntryIsLocked(int journalId)
|
||||
{
|
||||
using (SqlConnection conn = new SqlConnection(SqlConnectionString))
|
||||
{
|
||||
conn.Open();
|
||||
using (SqlCommand cmd = new SqlCommand(@"
|
||||
SELECT
|
||||
tblAccountJournal.IsLocked
|
||||
FROM
|
||||
tblAccountJournal
|
||||
WHERE
|
||||
tblAccountJournal.AccountJournalID=@accountJournalId;
|
||||
", conn))
|
||||
{
|
||||
cmd.Parameters.AddWithValue("@accountJournalId", journalId);
|
||||
|
||||
object obj = cmd.ExecuteScalar();
|
||||
if (obj == null)
|
||||
{
|
||||
throw new Exception("Journal entry not found for AccountJournalID=" + journalId);
|
||||
}
|
||||
else
|
||||
{
|
||||
return (bool)obj;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
144
src/bnhtrade.Core/Data/Database/Account/ReadJournalType.cs
Normal file
144
src/bnhtrade.Core/Data/Database/Account/ReadJournalType.cs
Normal file
@@ -0,0 +1,144 @@
|
||||
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.Account
|
||||
{
|
||||
internal class ReadJournalType : Connection
|
||||
{
|
||||
private bnhtrade.Core.Data.Database.SqlWhereBuilder sqlBuilder;
|
||||
|
||||
/// <summary>
|
||||
/// Results filter
|
||||
/// </summary>
|
||||
public List<uint> IdList { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Searches for the specificed phases within the item description. Uses the LIKE AND sql function
|
||||
/// </summary>
|
||||
public List<string> TitleList { get; set; }
|
||||
|
||||
public ReadJournalType()
|
||||
{
|
||||
Init();
|
||||
}
|
||||
|
||||
public void Init()
|
||||
{
|
||||
sqlBuilder = new SqlWhereBuilder();
|
||||
IdList = new List<uint>();
|
||||
TitleList = new List<string>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <returns>Dictionary where key is the table primary key</returns>
|
||||
public Dictionary<uint, Model.Account.JournalType> Read()
|
||||
{
|
||||
// create the return (emptyP list) here
|
||||
var returnList = new Dictionary<uint, Model.Account.JournalType>();
|
||||
sqlBuilder.Init();
|
||||
|
||||
//build sql query
|
||||
string sql = @"
|
||||
SELECT [AccountJournalTypeID]
|
||||
,[TypeTitle]
|
||||
,[ChartOfAccountID_Debit]
|
||||
,[ChartOfAccountID_Credit]
|
||||
FROM [e2A].[dbo].[tblAccountJournalType]
|
||||
WHERE 1 = 1 ";
|
||||
|
||||
// build the where statments
|
||||
if (IdList.Any())
|
||||
{
|
||||
sqlBuilder.In("AccountJournalTypeID", IdList, "AND");
|
||||
}
|
||||
if (TitleList.Any())
|
||||
{
|
||||
sqlBuilder.In("TypeTitle", TitleList, "AND");
|
||||
}
|
||||
|
||||
// append where string to the sql
|
||||
if (sqlBuilder.IsSetSqlWhereString)
|
||||
{
|
||||
sql = sql + sqlBuilder.SqlWhereString;
|
||||
}
|
||||
|
||||
// create dictionary to add credit/debit accounts on after db read
|
||||
var creditDict = new Dictionary<uint, uint>();
|
||||
var debitDict = new Dictionary<uint, uint>();
|
||||
|
||||
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)
|
||||
{
|
||||
while (reader.Read())
|
||||
{
|
||||
// read from db and create object
|
||||
uint journalTypeId = (uint)reader.GetInt32(0);
|
||||
string title = reader.GetString(1);
|
||||
int? debitAccountId = null;
|
||||
if (!reader.IsDBNull(2)) { debitAccountId = reader.GetInt32(2); }
|
||||
int? creditAccountId = null;
|
||||
if (!reader.IsDBNull(3)) { creditAccountId = reader.GetInt32(3); }
|
||||
|
||||
// build return list
|
||||
var item = new Model.Account.JournalType(journalTypeId, title);
|
||||
returnList.Add(journalTypeId, item);
|
||||
|
||||
// build dictionaries
|
||||
if (debitAccountId != null)
|
||||
{
|
||||
debitDict.Add(journalTypeId, (uint)debitAccountId);
|
||||
}
|
||||
if (creditAccountId != null)
|
||||
{
|
||||
creditDict.Add(journalTypeId, (uint)creditAccountId);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// get account objects from db
|
||||
var accountIdList = debitDict.Values.ToList();
|
||||
accountIdList.AddRange(creditDict.Values.ToList());
|
||||
var dbaccount = new Data.Database.Account.ReadAccountCode();
|
||||
var dbDict = dbaccount.ByAccountId(accountIdList);
|
||||
|
||||
// add to the returnlist
|
||||
foreach (var account in returnList.Values)
|
||||
{
|
||||
Model.Account.Account debitAccount = null;
|
||||
if (debitDict.ContainsKey(account.JournalTypeId))
|
||||
{
|
||||
debitAccount = dbDict[debitDict[account.JournalTypeId]];
|
||||
}
|
||||
|
||||
Model.Account.Account creditAccount = null;
|
||||
if (creditDict.ContainsKey(account.JournalTypeId))
|
||||
{
|
||||
creditAccount = dbDict[creditDict[account.JournalTypeId]]; // key of 59 needed
|
||||
}
|
||||
|
||||
account.AddDefaultAccounts(creditAccount, debitAccount);
|
||||
}
|
||||
|
||||
// all done, return the list here
|
||||
return returnList;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
178
src/bnhtrade.Core/Data/Database/Account/ReadPurchaseInvoice.cs
Normal file
178
src/bnhtrade.Core/Data/Database/Account/ReadPurchaseInvoice.cs
Normal file
@@ -0,0 +1,178 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.SqlClient;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using static System.ComponentModel.Design.ObjectSelectorEditor;
|
||||
|
||||
namespace bnhtrade.Core.Data.Database.Account
|
||||
{
|
||||
public class ReadPurchaseInvoice : Connection
|
||||
{
|
||||
private bnhtrade.Core.Data.Database.SqlWhereBuilder sqlBuilder;
|
||||
|
||||
public List<int> PurchaseInvoiceIdList { get; set; }
|
||||
|
||||
public ReadPurchaseInvoice()
|
||||
{
|
||||
Init();
|
||||
}
|
||||
|
||||
public void Init()
|
||||
{
|
||||
sqlBuilder = new SqlWhereBuilder();
|
||||
PurchaseInvoiceIdList = new List<int>();
|
||||
}
|
||||
|
||||
public Dictionary<int, Model.Account.PurchaseInvoice> Read()
|
||||
{
|
||||
var returnList = new Dictionary<int, Model.Account.PurchaseInvoice>();
|
||||
sqlBuilder.Init();
|
||||
|
||||
//build sql query
|
||||
string sql = @"
|
||||
SELECT tblPurchase.PurchaseID
|
||||
,tblPurchase.PurchaseNumber
|
||||
,tblPurchase.RecordID
|
||||
,tblPurchase.PurchaseDate
|
||||
,tblPurchase.ContactID
|
||||
,tblPurchase.SupplierRef
|
||||
,tblPurchase.PurchaseTotalAmount
|
||||
,tblPurchase.VatInclusiveAmounts
|
||||
,tblPurchase.RecordCreated
|
||||
,tblPurchase.RecordModified
|
||||
,tblPurchase.IsActive
|
||||
,tblAccountCurrency.CurrencyCode
|
||||
,tblPurchaseChannel.PurchaseChannelName
|
||||
,tblPurchaseStatus.PurchaseStatus
|
||||
FROM tblPurchase
|
||||
LEFT OUTER JOIN tblAccountCurrency ON tblPurchase.AccountCurrencyID = tblAccountCurrency.AccountCurrencyID
|
||||
LEFT OUTER JOIN tblPurchaseStatus ON tblPurchase.PurchaseStatusID = tblPurchaseStatus.PurchaseStatusID
|
||||
LEFT OUTER JOIN tblPurchaseChannel ON tblPurchase.PurchaseChannelID = tblPurchaseChannel.PurchaseChannelID
|
||||
WHERE 1 = 1
|
||||
";
|
||||
|
||||
// build the where statments
|
||||
if (PurchaseInvoiceIdList.Any())
|
||||
{
|
||||
sqlBuilder.In("[PurchaseID]", PurchaseInvoiceIdList, "AND");
|
||||
}
|
||||
|
||||
// append where string to the sql
|
||||
if (sqlBuilder.IsSetSqlWhereString)
|
||||
{
|
||||
sql = sql + sqlBuilder.SqlWhereString;
|
||||
}
|
||||
|
||||
// dictionary so we can fill in details afterwards
|
||||
var invoiceContactDict = new Dictionary<int, int>();
|
||||
var purchaseIdList = new List<int>();
|
||||
|
||||
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)
|
||||
{
|
||||
while (reader.Read())
|
||||
{
|
||||
|
||||
|
||||
int purchaseID = reader.GetInt32(0);
|
||||
int purchaseNumber = reader.GetInt32(1);
|
||||
int? recordID = null;
|
||||
if (!reader.IsDBNull(2)) { recordID = reader.GetInt32(2); }
|
||||
DateTime purchaseDate = DateTime.SpecifyKind(reader.GetDateTime(3), DateTimeKind.Utc);
|
||||
int? contactID = null;
|
||||
if (!reader.IsDBNull(4)) { contactID = reader.GetInt32(4);}
|
||||
string supplierRef = null;
|
||||
if (!reader.IsDBNull(5)) { supplierRef = reader.GetString(5);}
|
||||
decimal? purchaseTotalAmount = null;
|
||||
if (!reader.IsDBNull(6)) { purchaseTotalAmount = reader.GetDecimal(6);}
|
||||
bool vatInclusiveAmounts = reader.GetBoolean(7);
|
||||
DateTime recordCreated = DateTime.SpecifyKind(reader.GetDateTime(8), DateTimeKind.Utc);
|
||||
DateTime recordModified = DateTime.SpecifyKind(reader.GetDateTime(9), DateTimeKind.Utc);
|
||||
bool isActive = reader.GetBoolean(10);
|
||||
string currencyCode = reader.GetString(11);
|
||||
string purchaseChannelName = reader.GetString(12);
|
||||
string purchaseStatus = null;
|
||||
if (!reader.IsDBNull(13)) { purchaseStatus = reader.GetString(13);}
|
||||
|
||||
var invoice = new Model.Account.PurchaseInvoice();
|
||||
invoice.PurchaseID = purchaseID;
|
||||
invoice.PurchaseNumber = purchaseNumber;
|
||||
invoice.RecordID = recordID;
|
||||
invoice.PurchaseDate = purchaseDate;
|
||||
invoice.SupplierRef = supplierRef;
|
||||
//invoice.PurchaseTotalAmount = purchaseTotalAmount;
|
||||
invoice.VatInclusiveAmounts = vatInclusiveAmounts;
|
||||
invoice.RecordCreated = recordCreated;
|
||||
invoice.RecordModified = recordModified;
|
||||
invoice.IsActive = isActive;
|
||||
invoice.CurrencyCode = currencyCode;
|
||||
invoice.PurchaseChannel = purchaseChannelName;
|
||||
|
||||
// is there contact info that needs to be added?
|
||||
if (contactID != null)
|
||||
{
|
||||
invoiceContactDict.Add(purchaseID, (int)contactID);
|
||||
}
|
||||
|
||||
purchaseIdList.Add(purchaseID);
|
||||
|
||||
returnList.Add(purchaseID, invoice);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// add contact info
|
||||
if (invoiceContactDict.Any())
|
||||
{
|
||||
var readContact = new Data.Database.Account.ReadContact();
|
||||
readContact.ContactIdList = invoiceContactDict.Values.ToList();
|
||||
var contactDict = readContact.Read();
|
||||
|
||||
if (contactDict.Any())
|
||||
{
|
||||
foreach ( var invoice in returnList)
|
||||
{
|
||||
if (invoiceContactDict.ContainsKey(invoice.Value.PurchaseID))
|
||||
{
|
||||
int contactId = invoiceContactDict[invoice.Value.PurchaseID];
|
||||
invoice.Value.Contact = contactDict[contactId];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// add invoice lines
|
||||
var readLines = new Data.Database.Account.ReadPurchaseInvoiceLine();
|
||||
readLines.InvoiceIdList = purchaseIdList;
|
||||
var lines = readLines.Read();
|
||||
foreach(var invoice in returnList.Values)
|
||||
{
|
||||
foreach(var line in lines.Values)
|
||||
{
|
||||
if (line.PurchaseId == invoice.PurchaseID)
|
||||
{
|
||||
if (invoice.InvoiceLines == null)
|
||||
{
|
||||
invoice.InvoiceLines = new List<Model.Account.PurchaseInvoice.Line>();
|
||||
}
|
||||
invoice.InvoiceLines.Add(line);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return returnList;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,212 @@
|
||||
using Amazon.Runtime.Internal.Transform;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.SqlClient;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using static System.ComponentModel.Design.ObjectSelectorEditor;
|
||||
|
||||
namespace bnhtrade.Core.Data.Database.Account
|
||||
{
|
||||
internal class ReadPurchaseInvoiceLine : Connection
|
||||
{
|
||||
private bnhtrade.Core.Data.Database.SqlWhereBuilder sqlBuilder;
|
||||
|
||||
/// <summary>
|
||||
/// Results filter
|
||||
/// </summary>
|
||||
public List<int> InvoiceIdList { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Results filter
|
||||
/// </summary>
|
||||
public List<int> InvoiceLineIdList { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Results filter
|
||||
/// </summary>
|
||||
public List<string> StatusList { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Searches for the specificed phases within the item description. Uses the LIKE AND sql function
|
||||
/// </summary>
|
||||
public List<string> ItemDescription { get; set; }
|
||||
|
||||
public ReadPurchaseInvoiceLine()
|
||||
{
|
||||
Init();
|
||||
}
|
||||
|
||||
public void Init()
|
||||
{
|
||||
sqlBuilder = new SqlWhereBuilder();
|
||||
InvoiceIdList = new List<int>();
|
||||
InvoiceLineIdList = new List<int>();
|
||||
StatusList = new List<string>();
|
||||
ItemDescription = new List<string>();
|
||||
}
|
||||
|
||||
public Dictionary<int, Model.Account.PurchaseInvoice.Line> Read()
|
||||
{
|
||||
var returnList = new Dictionary<int, Model.Account.PurchaseInvoice.Line>();
|
||||
sqlBuilder.Init();
|
||||
|
||||
//build sql query
|
||||
string sql = @"
|
||||
SELECT tblPurchaseLine.PurchaseLineID
|
||||
,tblPurchaseLine.PurchaseID
|
||||
,tblPurchaseLineStatus.PurchaseLineStatus
|
||||
,tblPurchaseLine.SupplierRef
|
||||
,tblPurchaseLine.CheckedIn
|
||||
,tblPurchaseLine.ItemDescription
|
||||
,tblPurchaseLine.ItemQuantity
|
||||
,tblPurchaseLine.ItemGross
|
||||
,tblPurchaseLine.ItemTax
|
||||
,tblPurchaseLine.ShippingGross
|
||||
,tblPurchaseLine.ShippingTax
|
||||
,tblPurchaseLine.OtherGross
|
||||
,tblPurchaseLine.OtherTax
|
||||
,tblPurchaseLine.AccountTaxCodeID
|
||||
,tblPurchaseLine.Tax_AccountTransactionID
|
||||
,tblPurchaseLine.Net_AccountChartOfID
|
||||
,tblPurchaseLine.Net_AccountTransactionID
|
||||
,tblPurchaseLine.RecordCreated
|
||||
,tblPurchaseLine.RecordModified
|
||||
,tblPurchaseLine.IsActive
|
||||
,tblAccountTaxCode.TaxCode
|
||||
FROM tblPurchaseLine
|
||||
INNER JOIN tblPurchaseLineStatus ON tblPurchaseLine.PurchaseLineStatusID = tblPurchaseLineStatus.PurchaseLineStatusID
|
||||
LEFT OUTER JOIN tblAccountTaxCode ON tblPurchaseLine.AccountTaxCodeID = tblAccountTaxCode.AccountTaxCodeID
|
||||
WHERE 1 = 1 ";
|
||||
|
||||
// build the where statments
|
||||
if (InvoiceIdList.Any())
|
||||
{
|
||||
sqlBuilder.In("PurchaseID", InvoiceLineIdList, "AND");
|
||||
}
|
||||
if (InvoiceLineIdList.Any())
|
||||
{
|
||||
sqlBuilder.In("PurchaseLineID", InvoiceLineIdList, "AND");
|
||||
}
|
||||
if (StatusList.Any())
|
||||
{
|
||||
sqlBuilder.In("PurchaseLineStatus", InvoiceLineIdList, "AND");
|
||||
}
|
||||
if (ItemDescription.Any())
|
||||
{
|
||||
sqlBuilder.LikeAnd("ItemDescription", ItemDescription, "AND");
|
||||
}
|
||||
|
||||
|
||||
// append where string to the sql
|
||||
if (sqlBuilder.IsSetSqlWhereString)
|
||||
{
|
||||
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();
|
||||
|
||||
using (SqlCommand cmd = new SqlCommand(sql, conn))
|
||||
{
|
||||
sqlBuilder.AddParametersToSqlCommand(cmd);
|
||||
|
||||
using (SqlDataReader reader = cmd.ExecuteReader())
|
||||
{
|
||||
if (reader.HasRows)
|
||||
{
|
||||
while (reader.Read())
|
||||
{
|
||||
int purchaseLineID = reader.GetInt32(0);
|
||||
int purchaseID = reader.GetInt32(1);
|
||||
string purchaseLineStatus = reader.GetString(2);
|
||||
string supplierRef = null;
|
||||
if (!reader.IsDBNull(3)) { supplierRef = reader.GetString(3); }
|
||||
DateTime? checkedIn = null;
|
||||
if (!reader.IsDBNull(4)) { checkedIn = DateTime.SpecifyKind(reader.GetDateTime(4), DateTimeKind.Utc); }
|
||||
string itemDescription = null;
|
||||
if (!reader.IsDBNull(5)) { itemDescription = reader.GetString(5); }
|
||||
int itemQuantity = reader.GetInt32(6);
|
||||
decimal itemGross = 0;
|
||||
if (!reader.IsDBNull(7)) { itemGross = reader.GetDecimal(7); }
|
||||
decimal itemTax = 0;
|
||||
if (!reader.IsDBNull(8)) { itemTax = reader.GetDecimal(8); }
|
||||
decimal shippingGross = 0;
|
||||
if (!reader.IsDBNull(9)) { shippingGross = reader.GetDecimal(9); }
|
||||
decimal shippingTax = 0;
|
||||
if (!reader.IsDBNull(10)) { shippingTax = reader.GetDecimal(10); }
|
||||
decimal otherGross = 0;
|
||||
if (!reader.IsDBNull(11)) { otherGross = reader.GetDecimal(11); }
|
||||
decimal otherTax = 0;
|
||||
if (!reader.IsDBNull(12)) { otherTax = reader.GetDecimal(12); }
|
||||
int accountTaxCodeID = reader.GetInt32(13);
|
||||
int? tax_AccountTransactionID = null;
|
||||
if (!reader.IsDBNull(14)) { tax_AccountTransactionID = reader.GetInt32(14); }
|
||||
int net_AccountChartOfID = reader.GetInt32(15);
|
||||
int? net_AccountTransactionID = null;
|
||||
if (!reader.IsDBNull(16)) { net_AccountTransactionID = reader.GetInt32(16); }
|
||||
DateTime recordModified;
|
||||
DateTime recordCreated = DateTime.SpecifyKind(reader.GetDateTime(17), DateTimeKind.Utc);
|
||||
if (reader.IsDBNull(18)) { recordModified = recordCreated; }
|
||||
else { recordModified = DateTime.SpecifyKind(reader.GetDateTime(18), DateTimeKind.Utc); }
|
||||
bool isActive = reader.GetBoolean(19);
|
||||
string accountTaxCode = reader.GetString(20);
|
||||
|
||||
var line = new Model.Account.PurchaseInvoice.Line();
|
||||
line.PurchaseLineId = purchaseLineID;
|
||||
line.PurchaseId = purchaseID;
|
||||
line.Status = purchaseLineStatus;
|
||||
line.SupplierRef = supplierRef;
|
||||
line.CheckedIn = checkedIn;
|
||||
line.ItemDescription = itemDescription;
|
||||
line.ItemQuantity = itemQuantity;
|
||||
line.ItemGross = itemGross;
|
||||
line.ItemTax = itemTax;
|
||||
line.ShippingGross = shippingGross;
|
||||
line.ShippingTax = shippingTax;
|
||||
line.OtherGross = otherGross;
|
||||
line.OtherTax = otherTax;
|
||||
line.Tax_AccountTransactionId = tax_AccountTransactionID;
|
||||
line.Net_AccountChartOfId = net_AccountChartOfID;
|
||||
line.Net_AccountTransactionId = net_AccountTransactionID;
|
||||
line.RecordModified = recordModified;
|
||||
line.RecordCreated = recordCreated;
|
||||
line.IsActive = isActive;
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
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.Account
|
||||
{
|
||||
internal class ReadPurchaseInvoiceLineStatus : Connection
|
||||
{
|
||||
public Dictionary<int, Model.Account.PurchaseInvoiceLineStatus> Read()
|
||||
{
|
||||
var returnList = new Dictionary<int, Model.Account.PurchaseInvoiceLineStatus>();
|
||||
|
||||
using (SqlConnection conn = new SqlConnection(SqlConnectionString))
|
||||
{
|
||||
conn.Open();
|
||||
|
||||
using (SqlCommand cmd = new SqlCommand(@"
|
||||
SELECT [PurchaseLineStatusID]
|
||||
,[PurchaseLineStatus]
|
||||
,[ListSort]
|
||||
,[TimeStamp]
|
||||
FROM [e2A].[dbo].[tblPurchaseLineStatus]
|
||||
ORDER BY [ListSort]
|
||||
", conn))
|
||||
{
|
||||
|
||||
using (SqlDataReader reader = cmd.ExecuteReader())
|
||||
{
|
||||
if (!reader.HasRows)
|
||||
{
|
||||
// do something
|
||||
}
|
||||
else
|
||||
{
|
||||
while (reader.Read())
|
||||
{
|
||||
int id = reader.GetInt32(0);
|
||||
string name = reader.GetString(1);
|
||||
int lineSort = reader.GetInt32(2);
|
||||
|
||||
var returnItem = new Model.Account.PurchaseInvoiceLineStatus(id, name,lineSort);
|
||||
returnList.Add(id, returnItem );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return returnList;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
using FikaAmazonAPI.AmazonSpApiSDK.Models.ProductFees;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.SqlClient;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using static System.ComponentModel.Design.ObjectSelectorEditor;
|
||||
|
||||
namespace bnhtrade.Core.Data.Database.Account
|
||||
{
|
||||
internal class ReadPurchaseInvoiceLineSummary : Connection
|
||||
{
|
||||
public List<Model.Account.PurchaseInvoiceLineSummary> Read(DateTime periodTo, string lineStatus, List<string> descriptionSearch)
|
||||
{
|
||||
var returnList = new List<Model.Account.PurchaseInvoiceLineSummary>();
|
||||
var sqlBuilder = new bnhtrade.Core.Data.Database.SqlWhereBuilder();
|
||||
|
||||
//build sql query
|
||||
string sql = @"
|
||||
SELECT tblPurchase.PurchaseDate
|
||||
,tblPurchase.PurchaseID
|
||||
,tblPurchase.PurchaseNumber
|
||||
,tblPurchaseLine.PurchaseLineID
|
||||
,tblPurchaseLine.ItemDescription
|
||||
,tblPurchaseLineStatus.PurchaseLineStatus
|
||||
FROM tblPurchase
|
||||
INNER JOIN tblPurchaseLine ON tblPurchase.PurchaseID = tblPurchaseLine.PurchaseID
|
||||
INNER JOIN tblPurchaseLineStatus ON tblPurchaseLine.PurchaseLineStatusID = tblPurchaseLineStatus.PurchaseLineStatusID
|
||||
WHERE tblPurchase.PurchaseDate <= @purchaseDate
|
||||
";
|
||||
|
||||
if (lineStatus != null)
|
||||
{
|
||||
sql = sql + " AND PurchaseLineStatus = @purchaseLineStatus ";
|
||||
}
|
||||
|
||||
// build the where statments
|
||||
if (descriptionSearch.Any())
|
||||
{
|
||||
sqlBuilder.LikeAnd("ItemDescription", descriptionSearch, "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))
|
||||
{
|
||||
cmd.Parameters.AddWithValue("@purchaseDate", periodTo);
|
||||
if (lineStatus != null)
|
||||
{
|
||||
cmd.Parameters.AddWithValue("@purchaseLineStatus", lineStatus);
|
||||
}
|
||||
|
||||
sqlBuilder.AddParametersToSqlCommand(cmd);
|
||||
|
||||
using (SqlDataReader reader = cmd.ExecuteReader())
|
||||
{
|
||||
while (reader.Read())
|
||||
{
|
||||
DateTime purchaseDate = DateTime.SpecifyKind(reader.GetDateTime(0), DateTimeKind.Utc);
|
||||
int purchaseID = reader.GetInt32(1);
|
||||
int purchaseNumber = reader.GetInt32(2);
|
||||
int purchaseLineID = reader.GetInt32(3);
|
||||
string itemDescription = reader.GetString(4);
|
||||
string purchaseLineStatus = reader.GetString(5);
|
||||
|
||||
var item = new Model.Account.PurchaseInvoiceLineSummary();
|
||||
item.PurchaseDate = purchaseDate;
|
||||
item.PurchaseId = purchaseID;
|
||||
item.PurchaseNumber = purchaseNumber;
|
||||
item.PurchaseLineId = purchaseLineID;
|
||||
item.ItemDescription = itemDescription;
|
||||
item.LineStatus = purchaseLineStatus;
|
||||
|
||||
returnList.Add(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return returnList;
|
||||
}
|
||||
}
|
||||
}
|
||||
75
src/bnhtrade.Core/Data/Database/Account/UpdateJournal.cs
Normal file
75
src/bnhtrade.Core/Data/Database/Account/UpdateJournal.cs
Normal file
@@ -0,0 +1,75 @@
|
||||
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.Data.Database.Account
|
||||
{
|
||||
internal class UpdateJournal : Connection
|
||||
{
|
||||
public bool AccountJournalPostUpdate(int journalId, string currencyCode, decimal amount, int debitAccountId = 0, int creditAccountId = 0)
|
||||
{
|
||||
using (TransactionScope scope = new TransactionScope())
|
||||
using (SqlConnection conn = new SqlConnection(SqlConnectionString))
|
||||
{
|
||||
conn.Open();
|
||||
|
||||
// retrive journal entry date
|
||||
DateTime entryDate;
|
||||
using (SqlCommand cmd = new SqlCommand(@"
|
||||
SELECT
|
||||
tblAccountJournal.EntryDate
|
||||
FROM
|
||||
tblAccountJournal
|
||||
WHERE
|
||||
(((tblAccountJournal.AccountJournalID)=@accountJournalId));
|
||||
", conn))
|
||||
{
|
||||
cmd.Parameters.AddWithValue("@accountJournalId", journalId);
|
||||
|
||||
entryDate = DateTime.SpecifyKind((DateTime)cmd.ExecuteScalar(), DateTimeKind.Utc);
|
||||
}
|
||||
|
||||
// delete the original posts
|
||||
using (SqlCommand cmd = new SqlCommand(@"
|
||||
DELETE FROM
|
||||
tblAccountJournalPost
|
||||
WHERE
|
||||
(((tblAccountJournalPost.AccountJournalID)=@accountJournalId));
|
||||
", conn))
|
||||
{
|
||||
cmd.Parameters.AddWithValue("@accountJournalId", journalId);
|
||||
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
|
||||
//insert new posts
|
||||
//bool postResult = AccountJournalPostInsert(sqlConnectionString, journalId, entryDate, currencyCode, amount, debitAccountId, creditAccountId);
|
||||
bool postResult = new Data.Database.Account.CreateJournal().AccountJournalPostInsert(journalId, entryDate, currencyCode, amount, debitAccountId, creditAccountId);
|
||||
|
||||
// update modified date on journal
|
||||
using (SqlCommand cmd = new SqlCommand(@"
|
||||
UPDATE
|
||||
tblAccountJournal
|
||||
SET
|
||||
tblAccountJournal.LastModified=@utcNow
|
||||
WHERE
|
||||
(((tblAccountJournal.AccountJournalID)=@accountJournalId));
|
||||
", conn))
|
||||
{
|
||||
cmd.Parameters.AddWithValue("@accountJournalId", journalId);
|
||||
cmd.Parameters.AddWithValue("@utcNow", DateTime.UtcNow);
|
||||
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
|
||||
scope.Complete();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -104,7 +104,7 @@ namespace bnhtrade.Core.Data.Database.Export
|
||||
cmd.Parameters.AddWithValue("@invoiceID", invoiceId);
|
||||
cmd.Parameters.AddWithValue("@itemCode", invoiceList[i].InvoiceLineList[j].ItemCode);
|
||||
cmd.Parameters.AddWithValue("@netAmount", invoiceList[i].InvoiceLineList[j].UnitAmount);
|
||||
cmd.Parameters.AddWithValue("@accountCode", invoiceList[i].InvoiceLineList[j].AccountCode.AccountCode);
|
||||
cmd.Parameters.AddWithValue("@accountCode", (int)invoiceList[i].InvoiceLineList[j].AccountCode.AccountCode);
|
||||
cmd.Parameters.AddWithValue("@taxAmount", invoiceList[i].InvoiceLineList[j].TaxAmount);
|
||||
cmd.Parameters.AddWithValue("@taxCode", invoiceList[i].InvoiceLineList[j].TaxCode.TaxCode);
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using FikaAmazonAPI.AmazonSpApiSDK.Models.Finances;
|
||||
using FikaAmazonAPI.ConstructFeed.Messages;
|
||||
using NUnit.Framework.Constraints;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
@@ -11,7 +10,7 @@ using System.Runtime.ConstrainedExecution;
|
||||
using System.Security.Policy;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web.UI.WebControls;
|
||||
//using System.Web.UI.WebControls;
|
||||
|
||||
namespace bnhtrade.Core.Data.Database.Import
|
||||
{
|
||||
|
||||
@@ -9,7 +9,7 @@ using System.Transactions;
|
||||
|
||||
namespace bnhtrade.Core.Data.Database.Sku
|
||||
{
|
||||
public class InsertSku : Connection
|
||||
internal class InsertSku : Connection
|
||||
{
|
||||
public int InsertNew(int productId, int conditionId, int accountTaxCodeId)
|
||||
{
|
||||
|
||||
@@ -64,6 +64,89 @@ namespace bnhtrade.Core.Data.Database
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Append an 'Like' statement (with AND between each like string) and parameter list to the class properties
|
||||
/// </summary>
|
||||
/// <param name="columnReference">Name of the column to used to for the condition statement</param>
|
||||
/// <param name="phraseList">List of phrases to test in condition statement</param>
|
||||
/// <param name="wherePrefix">Optional prefix that gets added to the sql string result</param>
|
||||
public void LikeAnd(string columnReference, List<string> phraseList, string wherePrefix = null)
|
||||
{
|
||||
Like(columnReference, phraseList, true, wherePrefix);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Append an 'Like' statement (with OR between each like string) and parameter list to the class properties
|
||||
/// </summary>
|
||||
/// <param name="columnReference">Name of the column to used to for the condition statement</param>
|
||||
/// <param name="phraseList">List of phrases to test in condition statement</param>
|
||||
/// <param name="wherePrefix">Optional prefix that gets added to the sql string result</param>
|
||||
public void LikeOr(string columnReference, List<string> phraseList, string wherePrefix = null)
|
||||
{
|
||||
Like(columnReference, phraseList, false, wherePrefix);
|
||||
}
|
||||
|
||||
private void Like(string columnReference, List<string> phraseList, bool isAnd, string wherePrefix = null)
|
||||
{
|
||||
if (phraseList == null || !phraseList.Any())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// ensure no values are repeated
|
||||
var distinctList = phraseList.ToList();
|
||||
|
||||
// clean the list
|
||||
for (int i = 0; i < distinctList.Count; i++)
|
||||
{
|
||||
if (string.IsNullOrEmpty(distinctList[i]))
|
||||
{
|
||||
distinctList.RemoveAt(i);
|
||||
i--;
|
||||
}
|
||||
}
|
||||
|
||||
// check again
|
||||
if (distinctList == null || !distinctList.Any())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
string sqlWhere = @"
|
||||
";
|
||||
|
||||
if (wherePrefix != null)
|
||||
{
|
||||
sqlWhere += wherePrefix;
|
||||
}
|
||||
|
||||
|
||||
int listCount = distinctList.Count();
|
||||
for (int i = 0; i < listCount; i++, parameterCount++)
|
||||
{
|
||||
if (i > 0)
|
||||
{
|
||||
if (isAnd)
|
||||
{
|
||||
sqlWhere += " AND ";
|
||||
}
|
||||
else
|
||||
{
|
||||
sqlWhere += " OR ";
|
||||
}
|
||||
}
|
||||
|
||||
sqlWhere += " ( " + columnReference + " LIKE '%' + ";
|
||||
|
||||
string param = "@parameter" + parameterCount;
|
||||
sqlWhere += param;
|
||||
ParameterList.Add(param, distinctList[i]);
|
||||
|
||||
sqlWhere += " + '%' ) ";
|
||||
}
|
||||
SqlWhereString = SqlWhereString + sqlWhere;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Append an 'In' statement and parameter list to the class properties
|
||||
/// </summary>
|
||||
@@ -126,5 +209,26 @@ namespace bnhtrade.Core.Data.Database
|
||||
|
||||
In(columnReference, stringList, wherePrefix);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Append an 'In' statement and parameter list to the class properties
|
||||
/// </summary>
|
||||
/// <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="wherePrefix">Optional prefix that gets added to the sql string result</param>
|
||||
public void In(string columnReference, List<uint> orValueList, string wherePrefix = null)
|
||||
{
|
||||
var stringList = new List<string>();
|
||||
|
||||
if (orValueList != null || !orValueList.Any())
|
||||
{
|
||||
foreach (uint value in orValueList)
|
||||
{
|
||||
stringList.Add(value.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
In(columnReference, stringList, wherePrefix);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using NUnit.Framework.Internal;
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.SqlClient;
|
||||
using System.Linq;
|
||||
|
||||
23
src/bnhtrade.Core/Logic/Account/Currency.cs
Normal file
23
src/bnhtrade.Core/Logic/Account/Currency.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace bnhtrade.Core.Logic.Account
|
||||
{
|
||||
public class Currency
|
||||
{
|
||||
public decimal CurrencyConvertToGbp(string currencyCode, decimal amount, DateTime conversionDate)
|
||||
{
|
||||
return new Data.Database.Account.Currency().CurrencyConvertToGbp(currencyCode, amount, conversionDate);
|
||||
}
|
||||
|
||||
public int CurrencyExchangeRateInsert(int exchangeRateSource, string currencyCode,
|
||||
decimal currencyUnitsPerGbp, DateTime periodStart, DateTime periodEnd, bool checkOverride = false)
|
||||
{
|
||||
return new Data.Database.Account.Currency().CurrencyExchangeRateInsert(exchangeRateSource, currencyCode,
|
||||
currencyUnitsPerGbp, periodStart, periodEnd, checkOverride);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -35,7 +35,7 @@ namespace bnhtrade.Core.Logic.Account
|
||||
|
||||
public List<Model.Account.Account> ByAccountCode(List<int> accountCodeList)
|
||||
{
|
||||
return readAccountCode.ByAccountCode(accountCodeList);
|
||||
return readAccountCode.ByAccountCode(accountCodeList).Values.ToList();
|
||||
}
|
||||
|
||||
public Dictionary<int, Model.Account.Account> ConvertToDictionary(List<Model.Account.Account> accountCodeList)
|
||||
|
||||
25
src/bnhtrade.Core/Logic/Account/Journal.cs
Normal file
25
src/bnhtrade.Core/Logic/Account/Journal.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
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.Logic.Account
|
||||
{
|
||||
public class Journal
|
||||
{
|
||||
public int AccountJournalInsert(int journalTypeId, DateTime entryDate, string currencyCode,
|
||||
decimal amount, int debitAccountId = 0, int creditAccountId = 0, bool lockEntry = false)
|
||||
{
|
||||
return new Data.Database.Account.CreateJournal().AccountJournalInsert(journalTypeId, entryDate, currencyCode,
|
||||
amount, debitAccountId, creditAccountId, lockEntry);
|
||||
}
|
||||
|
||||
public bool AccountJournalDelete(int accountJournalId)
|
||||
{
|
||||
return new Data.Database.Account.DeleteJournal().AccountJournalDelete(accountJournalId);
|
||||
}
|
||||
}
|
||||
}
|
||||
12
src/bnhtrade.Core/Logic/Account/PurchaseInvoice.cs
Normal file
12
src/bnhtrade.Core/Logic/Account/PurchaseInvoice.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace bnhtrade.Core.Logic.Account
|
||||
{
|
||||
public class PurchaseInvoice : Core.Data.Database.Account.ReadPurchaseInvoice
|
||||
{
|
||||
}
|
||||
}
|
||||
21
src/bnhtrade.Core/Logic/Account/PurchaseInvoiceMisc.cs
Normal file
21
src/bnhtrade.Core/Logic/Account/PurchaseInvoiceMisc.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace bnhtrade.Core.Logic.Account
|
||||
{
|
||||
public class PurchaseInvoiceMisc
|
||||
{
|
||||
public List<Model.Account.PurchaseInvoiceLineStatus> ReadLineStatusToList()
|
||||
{
|
||||
return new Data.Database.Account.ReadPurchaseInvoiceLineStatus().Read().Values.ToList();
|
||||
}
|
||||
|
||||
public List<Model.Account.PurchaseInvoiceLineSummary> GetLineSummary(DateTime maxDate, string lineStatus, List<string> wordSearchList)
|
||||
{
|
||||
return new Data.Database.Account.ReadPurchaseInvoiceLineSummary().Read(maxDate,lineStatus, wordSearchList);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Linq;
|
||||
using bnhtrade.Core.Data.Amazon.Report;
|
||||
using System.Linq;
|
||||
|
||||
namespace bnhtrade.Core.Logic.Import
|
||||
{
|
||||
@@ -10,6 +11,7 @@ namespace bnhtrade.Core.Logic.Import
|
||||
|
||||
public AmazonSettlement()
|
||||
{
|
||||
amazonReport = new Data.Amazon.Report.SettlementReport();
|
||||
}
|
||||
|
||||
public void SyncDatabase()
|
||||
@@ -53,12 +55,12 @@ namespace bnhtrade.Core.Logic.Import
|
||||
}
|
||||
|
||||
// import into database
|
||||
var dbImport = new Data.Database.Import.AmazonSettlementInsert();
|
||||
var dbInsert = new Data.Database.Import.AmazonSettlementInsert();
|
||||
for (int i = 0; i < spapiReportIdList.Count(); i++)
|
||||
{
|
||||
UI.Console.WriteLine("Importing settlement report " + (i + 1) + " of " + spapiReportIdList.Count() + " (ReportID:" + spapiReportIdList[i] + ").");
|
||||
var filePath = amazonReport.GetFile(spapiReportIdList[i]);
|
||||
bool ack = dbImport.ByFlatFile(filePath, spapiReportIdList[i]);
|
||||
var filePath = amazonReport.GetReportFile(spapiReportIdList[i]);
|
||||
bool ack = dbInsert.ByFlatFile(filePath, spapiReportIdList[i]);
|
||||
log.LogInformation("Settlment Report imported (ReportID:" + spapiReportIdList[i] + ").");
|
||||
}
|
||||
|
||||
|
||||
@@ -28,8 +28,10 @@ namespace bnhtrade.Core.Logic.Sku
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
return new Data.Database.Sku.InsertSku().InsertNew(productId, conditionId, accountTaxCodeId);
|
||||
else
|
||||
{
|
||||
return new Data.Database.Sku.InsertSku().InsertNew(productId, conditionId, accountTaxCodeId);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Transactions;
|
||||
using System.Web.UI;
|
||||
|
||||
namespace bnhtrade.Core.Logic.Stock
|
||||
{
|
||||
|
||||
@@ -4,7 +4,6 @@ using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web.UI.WebControls;
|
||||
|
||||
namespace bnhtrade.Core.Model.Account
|
||||
{
|
||||
|
||||
27
src/bnhtrade.Core/Model/Account/Contact.cs
Normal file
27
src/bnhtrade.Core/Model/Account/Contact.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace bnhtrade.Core.Model.Account
|
||||
{
|
||||
public class Contact
|
||||
{
|
||||
public int ContactId { get; set; }
|
||||
|
||||
public string ContantName { get; set; }
|
||||
|
||||
public string ContactEbayName { get; set; }
|
||||
|
||||
public string ContactEbayEmail { get; set; }
|
||||
|
||||
public string ContactPaypalName { get; set; }
|
||||
|
||||
public string ContactPaypalEmail { get; set; }
|
||||
|
||||
public DateTime Created { get; set; }
|
||||
|
||||
public DateTime? Modified { get; set; }
|
||||
}
|
||||
}
|
||||
65
src/bnhtrade.Core/Model/Account/Journal.cs
Normal file
65
src/bnhtrade.Core/Model/Account/Journal.cs
Normal file
@@ -0,0 +1,65 @@
|
||||
using Microsoft.VisualBasic;
|
||||
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 Journal : IValidatableObject
|
||||
{
|
||||
internal Journal(uint journalId, Core.Model.Account.JournalType type, List<Post> posts, DateTime entryDate, DateTime postDate, DateTime lastModifed, bool isLocked)
|
||||
{
|
||||
JournalId = journalId;
|
||||
Type = type;
|
||||
Posts = posts;
|
||||
EntryDate = entryDate;
|
||||
PostDate = postDate;
|
||||
LastModified = lastModifed;
|
||||
IsLocked = isLocked;
|
||||
}
|
||||
|
||||
public uint JournalId { get; private set; }
|
||||
public Core.Model.Account.JournalType Type { get; private set; }
|
||||
public List<Post> Posts { get; private set; } = new List<Post>();
|
||||
public DateTime EntryDate { get; private set; }
|
||||
public DateTime PostDate { get; private set; }
|
||||
public DateTime LastModified { get;private set; }
|
||||
public bool IsLocked { get; private set; }
|
||||
|
||||
public class Post
|
||||
{
|
||||
internal Post(uint postId, Core.Model.Account.Account account, decimal amountGbp)
|
||||
{
|
||||
PostId = postId;
|
||||
Account = account;
|
||||
AmountGbp = amountGbp;
|
||||
}
|
||||
|
||||
public uint PostId { get; private set; }
|
||||
public Core.Model.Account.Account Account { get; private set; }
|
||||
public decimal AmountGbp { get; private set; }
|
||||
}
|
||||
|
||||
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
|
||||
{
|
||||
var result = new List<ValidationResult>();
|
||||
|
||||
// get total of posts
|
||||
decimal postTotal = 0;
|
||||
foreach (var post in Posts)
|
||||
{
|
||||
postTotal = postTotal + post.AmountGbp;
|
||||
}
|
||||
if (postTotal != 0)
|
||||
{
|
||||
result.Add(new ValidationResult("Account journal posts do not equal zero"));
|
||||
}
|
||||
|
||||
throw new NotImplementedException();
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
43
src/bnhtrade.Core/Model/Account/JournalType.cs
Normal file
43
src/bnhtrade.Core/Model/Account/JournalType.cs
Normal file
@@ -0,0 +1,43 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace bnhtrade.Core.Model.Account
|
||||
{
|
||||
public class JournalType
|
||||
{
|
||||
internal JournalType(uint journalTypeId, string title, Model.Account.Account defaultCreditAccount = null, Model.Account.Account defaultDebitAccount = null)
|
||||
{
|
||||
JournalTypeId = journalTypeId;
|
||||
Title = title;
|
||||
DefaultCreditAccount = defaultCreditAccount;
|
||||
DefaultDebitAccount = defaultDebitAccount;
|
||||
}
|
||||
|
||||
internal void AddDefaultAccounts(Model.Account.Account defaultCreditAccount = null, Model.Account.Account defaultDebitAccount = null)
|
||||
{
|
||||
DefaultCreditAccount = defaultCreditAccount;
|
||||
DefaultDebitAccount = defaultDebitAccount;
|
||||
}
|
||||
|
||||
public uint JournalTypeId { get ; private set; }
|
||||
|
||||
public string Title { get; private set; }
|
||||
|
||||
public Model.Account.Account DefaultDebitAccount { get; private set; }
|
||||
|
||||
public bool IsSetDefaultDebitAccount
|
||||
{
|
||||
get { return DefaultDebitAccount != null; }
|
||||
}
|
||||
|
||||
public Model.Account.Account DefaultCreditAccount { get; private set; }
|
||||
|
||||
public bool IsSetDefaultCreditAccount
|
||||
{
|
||||
get { return DefaultCreditAccount != null; }
|
||||
}
|
||||
}
|
||||
}
|
||||
172
src/bnhtrade.Core/Model/Account/PurchaseInvoice.cs
Normal file
172
src/bnhtrade.Core/Model/Account/PurchaseInvoice.cs
Normal file
@@ -0,0 +1,172 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace bnhtrade.Core.Model.Account
|
||||
{
|
||||
public class PurchaseInvoice
|
||||
{
|
||||
public int PurchaseID { get; set; }
|
||||
|
||||
public int PurchaseNumber { get; set; }
|
||||
|
||||
public int? RecordID { get; set; }
|
||||
|
||||
public DateTime PurchaseDate { get; set; }
|
||||
|
||||
public Model.Account.Contact Contact { get; set; }
|
||||
|
||||
public string SupplierRef { get; set; }
|
||||
|
||||
public string AccountCurrency { get; set; }
|
||||
|
||||
public string PurchaseChannel { get; set; }
|
||||
|
||||
public string CurrencyCode { get; set; }
|
||||
|
||||
public decimal InvoiceNetAmount
|
||||
{
|
||||
get
|
||||
{
|
||||
return InvoiceGrossAmount - InvoiceTaxAmount;
|
||||
}
|
||||
}
|
||||
|
||||
public decimal InvoiceTaxAmount
|
||||
{
|
||||
get
|
||||
{
|
||||
decimal amount = 0;
|
||||
foreach (var item in InvoiceLines)
|
||||
{
|
||||
amount = amount + item.LineTotalTax;
|
||||
}
|
||||
return amount;
|
||||
}
|
||||
}
|
||||
|
||||
public decimal InvoiceGrossAmount
|
||||
{
|
||||
get
|
||||
{
|
||||
decimal amount = 0;
|
||||
foreach (var item in InvoiceLines)
|
||||
{
|
||||
amount = amount + item.LineTotalGross;
|
||||
}
|
||||
return amount;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Value stored in database to check invoice lines against
|
||||
/// </summary>
|
||||
public decimal InvoiceGrossAmountCheck { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Don't know what this is for, all the amounts in the db are gross, so this is always true
|
||||
/// </summary>
|
||||
public bool VatInclusiveAmounts { get; set; }
|
||||
|
||||
public DateTime RecordCreated { get; set; }
|
||||
|
||||
public DateTime RecordModified { get; set; }
|
||||
|
||||
public bool IsActive { get; set; }
|
||||
|
||||
public List<Model.Account.PurchaseInvoice.Line> InvoiceLines { get; set; }
|
||||
|
||||
public class Line
|
||||
{
|
||||
public int PurchaseLineId { get; set; }
|
||||
|
||||
public int PurchaseId { get; set; }
|
||||
|
||||
public string Status { get; set; }
|
||||
|
||||
public string SupplierRef { get; set; }
|
||||
|
||||
public DateTime? CheckedIn { get; set; }
|
||||
|
||||
public string ItemDescription { get; set; }
|
||||
|
||||
public int ItemQuantity { get; set; }
|
||||
|
||||
public decimal ItemNet
|
||||
{
|
||||
get
|
||||
{
|
||||
return ItemGross - ItemTax;
|
||||
}
|
||||
}
|
||||
|
||||
public decimal ItemGross { get; set; }
|
||||
|
||||
public decimal ItemTax { get; set; }
|
||||
|
||||
public decimal ShippingNet
|
||||
{
|
||||
get
|
||||
{
|
||||
return ShippingGross - ShippingTax;
|
||||
}
|
||||
}
|
||||
|
||||
public decimal ShippingGross { get; set; }
|
||||
|
||||
public decimal ShippingTax { get; set; }
|
||||
|
||||
public decimal OtherNet
|
||||
{
|
||||
get
|
||||
{
|
||||
return OtherGross - OtherTax;
|
||||
}
|
||||
}
|
||||
|
||||
public decimal OtherGross { get; set; }
|
||||
|
||||
public decimal OtherTax { get; set; }
|
||||
|
||||
public decimal LineTotalNet
|
||||
{
|
||||
get
|
||||
{
|
||||
return (ItemGross + ShippingGross + OtherGross) - (ItemTax + ShippingTax + OtherTax);
|
||||
}
|
||||
}
|
||||
|
||||
public decimal LineTotalTax
|
||||
{
|
||||
get
|
||||
{
|
||||
return ItemTax + ShippingTax + OtherTax;
|
||||
}
|
||||
}
|
||||
|
||||
public decimal LineTotalGross
|
||||
{
|
||||
get
|
||||
{
|
||||
return ItemGross + ShippingGross + OtherGross;
|
||||
}
|
||||
}
|
||||
|
||||
public bnhtrade.Core.Model.Account.TaxCodeInfo AccountTaxCode { get; set; }
|
||||
|
||||
public int? Tax_AccountTransactionId { get; set; }
|
||||
|
||||
public int Net_AccountChartOfId { get; set; }
|
||||
|
||||
public int? Net_AccountTransactionId { get; set; }
|
||||
|
||||
public DateTime RecordCreated { get; set; }
|
||||
|
||||
public DateTime RecordModified { get; set; }
|
||||
|
||||
public bool IsActive { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
24
src/bnhtrade.Core/Model/Account/PurchaseInvoiceLineStatus.cs
Normal file
24
src/bnhtrade.Core/Model/Account/PurchaseInvoiceLineStatus.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace bnhtrade.Core.Model.Account
|
||||
{
|
||||
public class PurchaseInvoiceLineStatus
|
||||
{
|
||||
public PurchaseInvoiceLineStatus(int statusId, string statusName, int listSort)
|
||||
{
|
||||
PurchaseLineStatusId = statusId;
|
||||
PurchaseLineStatusName = statusName;
|
||||
ListSort = listSort;
|
||||
}
|
||||
|
||||
public int PurchaseLineStatusId { get; private set; }
|
||||
|
||||
public string PurchaseLineStatusName { get; private set; }
|
||||
|
||||
public int ListSort { get; private set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace bnhtrade.Core.Model.Account
|
||||
{
|
||||
public class PurchaseInvoiceLineSummary
|
||||
{
|
||||
public int PurchaseId { get; set; }
|
||||
public int PurchaseNumber { get; set; }
|
||||
public int PurchaseLineId { get; set; }
|
||||
public DateTime PurchaseDate { get; set; }
|
||||
public string ItemDescription { get; set; }
|
||||
public string LineStatus { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -9,7 +9,7 @@ namespace bnhtrade.Core.Model.Account
|
||||
{
|
||||
public class TaxCodeInfo : IValidatableObject
|
||||
{
|
||||
public TaxCodeInfo(string taxCodeId, string title, string description, decimal taxRatePercent, bool isMarginSchemeRate,
|
||||
public TaxCodeInfo(string taxCode, string title, string description, decimal taxRatePercent, bool isMarginSchemeRate,
|
||||
bool isValidOnExpense, bool isValidOnIncome, string taxType, bool isActive)
|
||||
{
|
||||
if (TaxRate < 0)
|
||||
@@ -24,7 +24,7 @@ namespace bnhtrade.Core.Model.Account
|
||||
throw new Exception("Tax rate is >= 100%");
|
||||
}
|
||||
|
||||
TaxCode = taxCodeId;
|
||||
TaxCode = taxCode;
|
||||
TaxCodeDescription = description;
|
||||
TaxRate = taxRatePercent;
|
||||
IsMarginScheme = isMarginSchemeRate;
|
||||
|
||||
@@ -9,24 +9,35 @@ namespace bnhtrade.Core.Model.Credentials
|
||||
public class bnhtradeDB
|
||||
{
|
||||
public string DataSource { get; private set; }
|
||||
|
||||
public string UserId { get; private set; }
|
||||
|
||||
public string UserPassword { get; private set; }
|
||||
|
||||
public string InitialCatalog { get; private set; } = "e2A";
|
||||
|
||||
public bool PersistSecurityInfo { get; private set; } = true;
|
||||
|
||||
public bool MultipleActiveResultSets { get; private set; } = true;
|
||||
|
||||
public uint ConnectionTimeout { get; private set; }
|
||||
|
||||
public string ConnectionString
|
||||
{ get
|
||||
{
|
||||
get
|
||||
{
|
||||
return "Data Source=" + DataSource + ";Initial Catalog=" + InitialCatalog + ";Persist Security Info=" + PersistSecurityInfo.ToString()
|
||||
+ ";User ID=" + UserId + ";Password=" + UserPassword + ";MultipleActiveResultSets=" + MultipleActiveResultSets.ToString();
|
||||
+ ";User ID=" + UserId + ";Password=" + UserPassword + ";MultipleActiveResultSets=" + MultipleActiveResultSets.ToString()
|
||||
+ ";Connect Timeout=" + ConnectionTimeout;
|
||||
}
|
||||
}
|
||||
|
||||
public bnhtradeDB (string source, string userId, string userPassword)
|
||||
public bnhtradeDB (string source, string userId, string userPassword, uint connectionTimeout = 30)
|
||||
{
|
||||
this.DataSource = source;
|
||||
this.UserId = userId;
|
||||
this.UserPassword = userPassword;
|
||||
this.ConnectionTimeout = connectionTimeout;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using CsvHelper.Configuration.Attributes;
|
||||
using NUnit.Framework.Interfaces;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
@@ -7,7 +7,6 @@ using System.Runtime.ConstrainedExecution;
|
||||
using System.Security.Policy;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web.UI.WebControls;
|
||||
|
||||
namespace bnhtrade.Core.Model.Import
|
||||
{
|
||||
|
||||
24
src/bnhtrade.Core/Model/Purchase/PurchaseLineStatus.cs
Normal file
24
src/bnhtrade.Core/Model/Purchase/PurchaseLineStatus.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace bnhtrade.Core.Model.Purchase
|
||||
{
|
||||
public class PurchaseLineStatus
|
||||
{
|
||||
public PurchaseLineStatus(int statusId, string statusName, int listSort)
|
||||
{
|
||||
PurchaseLineStatusId = statusId;
|
||||
PurchaseLineStatusName = statusName;
|
||||
ListSort = listSort;
|
||||
}
|
||||
|
||||
public int PurchaseLineStatusId {get; private set;}
|
||||
|
||||
public string PurchaseLineStatusName { get; private set;}
|
||||
|
||||
public int ListSort { get; private set;}
|
||||
}
|
||||
}
|
||||
@@ -60,7 +60,7 @@ namespace bnhtrade.Core
|
||||
)
|
||||
{
|
||||
// first off, check if listing-item already exists, return id if it does
|
||||
int listingItemId = EbayListingItemGet(sqlConnectionString, itemNumber, listingEnd);
|
||||
int listingItemId = EbayListingItemGet(sqlConnectionString, itemNumber, listingEnd);
|
||||
if (listingItemId > 0)
|
||||
{ return (listingItemId, false, false); }
|
||||
|
||||
@@ -228,642 +228,6 @@ namespace bnhtrade.Core
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
namespace Account
|
||||
{
|
||||
public class AccountQuery
|
||||
{
|
||||
public static decimal CurrencyConvertToGbp(string sqlConnectionString, string currencyCode, decimal amount, DateTime conversionDate)
|
||||
{
|
||||
if (currencyCode == "GBP" || amount == 0M)
|
||||
{
|
||||
return amount;
|
||||
}
|
||||
|
||||
if (currencyCode.Length != 3)
|
||||
{
|
||||
throw new Exception("Invalid currency code '" + currencyCode + "'");
|
||||
}
|
||||
|
||||
using (SqlConnection sqlConn = new SqlConnection(sqlConnectionString))
|
||||
{
|
||||
sqlConn.Open();
|
||||
|
||||
using (SqlCommand cmd = new SqlCommand(@"
|
||||
SELECT CurrencyUnitsPerGBP
|
||||
FROM tblAccountExchangeRate
|
||||
WHERE CurrencyCode=@currencyCode AND StartDate<=@conversionDate AND EndDate>@conversionDate
|
||||
", sqlConn))
|
||||
{
|
||||
cmd.Parameters.AddWithValue("@currencyCode", currencyCode);
|
||||
cmd.Parameters.AddWithValue("@conversionDate", conversionDate);
|
||||
|
||||
object result = cmd.ExecuteScalar();
|
||||
if (result != null)
|
||||
{
|
||||
return amount / Convert.ToDecimal(result);
|
||||
}
|
||||
}
|
||||
|
||||
// return reason for no record found
|
||||
using (SqlCommand cmd = new SqlCommand(@"
|
||||
SELECT CurrencyUnitsPerGBP
|
||||
FROM tblAccountExchangeRate
|
||||
WHERE CurrencyCode=@currencyCode
|
||||
", sqlConn))
|
||||
{
|
||||
cmd.Parameters.AddWithValue("@currencyCode", currencyCode);
|
||||
|
||||
object result = cmd.ExecuteScalar();
|
||||
if (result == null)
|
||||
{
|
||||
throw new Exception("Currency code '" + currencyCode + "' does not exist in Exchange Rate table");
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("Date range for " + currencyCode + " " + conversionDate.ToShortDateString() + " " +
|
||||
conversionDate.ToLongTimeString() + "' does not exist in Exchange Rate table");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static int CurrencyExchangeRateInsert(string sqlConnectionString, int exchangeRateSource, string currencyCode,
|
||||
decimal currencyUnitsPerGbp, DateTime periodStart, DateTime periodEnd, bool checkOverride = false)
|
||||
{
|
||||
currencyUnitsPerGbp = decimal.Round(currencyUnitsPerGbp, 4);
|
||||
periodStart = DateTime.SpecifyKind(periodStart, DateTimeKind.Utc);
|
||||
periodEnd = DateTime.SpecifyKind(periodEnd, DateTimeKind.Utc);
|
||||
|
||||
// CHECKS
|
||||
// HMRC source only
|
||||
if (exchangeRateSource != 1)
|
||||
{
|
||||
throw new Exception("Function does not currently accept exchange rates from sources other than HMRC");
|
||||
}
|
||||
// currency code upper case only
|
||||
currencyCode = currencyCode.ToUpper();
|
||||
if (currencyCode.Length != 3)
|
||||
{
|
||||
throw new Exception("Invalid currency code '" + currencyCode +"'");
|
||||
}
|
||||
|
||||
if (periodEnd <= periodStart)
|
||||
{
|
||||
throw new Exception("Invalid date period.");
|
||||
}
|
||||
|
||||
if (checkOverride == false && (periodEnd - periodStart).Days > 31)
|
||||
{
|
||||
throw new Exception("Date period is greater than 31 days.");
|
||||
}
|
||||
|
||||
// retirve previous data
|
||||
DateTime? periodEndLast = null;
|
||||
using (SqlConnection sqlConn = new SqlConnection(sqlConnectionString))
|
||||
{
|
||||
sqlConn.Open();
|
||||
|
||||
using (SqlCommand cmd = new SqlCommand(@"
|
||||
SELECT Max(tblAccountExchangeRate.EndDate) AS MaxOfEndDate
|
||||
FROM tblAccountExchangeRate
|
||||
WHERE (((tblAccountExchangeRate.CurrencyCode) = @currencyCode))
|
||||
", sqlConn))
|
||||
{
|
||||
cmd.Parameters.AddWithValue("@currencyCode", currencyCode);
|
||||
|
||||
object obj = cmd.ExecuteScalar();
|
||||
|
||||
// currency code not existing
|
||||
if (obj == DBNull.Value && checkOverride == false)
|
||||
{
|
||||
throw new Exception("Currency code '" + currencyCode + "' does not exist in table");
|
||||
}
|
||||
// currency code exists
|
||||
else
|
||||
{
|
||||
periodEndLast = DateTime.SpecifyKind(Convert.ToDateTime(obj), DateTimeKind.Utc);
|
||||
|
||||
if (periodStart != periodEndLast)
|
||||
{
|
||||
throw new Exception("Invalid period start date -- must equal previous period end-date.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// retrive previous exchange rate and check
|
||||
decimal currencyUnitsPerGbpLast = 0;
|
||||
if (periodEndLast != null)
|
||||
{
|
||||
using (SqlCommand cmd = new SqlCommand(@"
|
||||
SELECT tblAccountExchangeRate.AccountExchangeRateID, tblAccountExchangeRate.CurrencyUnitsPerGBP
|
||||
FROM tblAccountExchangeRate
|
||||
WHERE (tblAccountExchangeRate.EndDate = @periodEndLast)
|
||||
AND (CurrencyCode = @currencyCode);
|
||||
", sqlConn))
|
||||
{
|
||||
cmd.Parameters.AddWithValue("@periodEndLast", periodEndLast);
|
||||
cmd.Parameters.AddWithValue("@currencyCode", currencyCode);
|
||||
|
||||
using (var reader = cmd.ExecuteReader())
|
||||
{
|
||||
if (reader.Read())
|
||||
{
|
||||
currencyUnitsPerGbpLast = reader.GetDecimal(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("Error that shouldn't happen! Check code @ 5129f3e6-2f7e-4883-bc73-b317d8fa4050");
|
||||
}
|
||||
// error if >1 line
|
||||
if (reader.Read())
|
||||
{
|
||||
string errText = "Multiple lines in currency exchange table for '" + currencyCode + "' where [EndDate]=" + periodEndLast.ToString();
|
||||
new Logic.Log.LogEvent().LogError(errText);
|
||||
throw new Exception(errText);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// check difference between current and previous exchange rates isn't too great
|
||||
if (checkOverride == false &&
|
||||
(currencyUnitsPerGbpLast > (currencyUnitsPerGbp * 1.05m) || currencyUnitsPerGbpLast < (currencyUnitsPerGbp * 0.95m))
|
||||
)
|
||||
{
|
||||
throw new Exception("Difference between supplied and previous exchange rates is greater than 5%");
|
||||
}
|
||||
|
||||
// MAKE THE INSERT
|
||||
int recordId = 0;
|
||||
using (SqlCommand cmd = new SqlCommand(@"
|
||||
INSERT INTO tblAccountExchangeRate (ExchangeRateSource, CurrencyCode, CurrencyUnitsPerGBP, StartDate, EndDate)
|
||||
OUTPUT INSERTED.AccountExchangeRateID
|
||||
VALUES (@exchangeRateSource, @currencyCode, @currencyUnitsPerGbp, @periodStart, @periodEnd);
|
||||
", sqlConn))
|
||||
{
|
||||
cmd.Parameters.AddWithValue("@exchangeRateSource", exchangeRateSource);
|
||||
cmd.Parameters.AddWithValue("@currencyCode", currencyCode);
|
||||
cmd.Parameters.AddWithValue("@currencyUnitsPerGbp", currencyUnitsPerGbp);
|
||||
cmd.Parameters.AddWithValue("@periodStart", periodStart);
|
||||
cmd.Parameters.AddWithValue("@periodEnd", periodEnd);
|
||||
|
||||
recordId = (int)cmd.ExecuteScalar();
|
||||
|
||||
if (recordId < 1)
|
||||
{
|
||||
throw new Exception("Error inserting record, did not retrive new record ID.");
|
||||
}
|
||||
}
|
||||
|
||||
return recordId;
|
||||
}
|
||||
}
|
||||
|
||||
public static bool AccountJournalEntryIsLocked(string sqlConnectionString, int journalId)
|
||||
{
|
||||
using (SqlConnection conn = new SqlConnection(sqlConnectionString))
|
||||
{
|
||||
conn.Open();
|
||||
using (SqlCommand cmd = new SqlCommand(@"
|
||||
SELECT
|
||||
tblAccountJournal.IsLocked
|
||||
FROM
|
||||
tblAccountJournal
|
||||
WHERE
|
||||
tblAccountJournal.AccountJournalID=@accountJournalId;
|
||||
", conn))
|
||||
{
|
||||
cmd.Parameters.AddWithValue("@accountJournalId", journalId);
|
||||
|
||||
object obj = cmd.ExecuteScalar();
|
||||
if (obj == null)
|
||||
{
|
||||
throw new Exception("Journal entry not found for AccountJournalID=" + journalId);
|
||||
}
|
||||
else
|
||||
{
|
||||
return (bool)obj;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static int AccountJournalInsert(string sqlConnectionString, int journalTypeId, DateTime entryDate, string currencyCode,
|
||||
decimal amount, int debitAccountId = 0, int creditAccountId = 0, bool lockEntry = false)
|
||||
{
|
||||
int defaultDebit = 0;
|
||||
int defaultCredit = 0;
|
||||
|
||||
// ensure date is UTC
|
||||
entryDate = DateTime.SpecifyKind(entryDate, DateTimeKind.Utc);
|
||||
|
||||
// debit and credit locks are checked in journal post method
|
||||
using (TransactionScope scope = new TransactionScope())
|
||||
using (SqlConnection conn = new SqlConnection(sqlConnectionString))
|
||||
{
|
||||
conn.Open();
|
||||
|
||||
// insert the journal entry
|
||||
int journalId;
|
||||
|
||||
using (SqlCommand cmd = new SqlCommand(@"
|
||||
INSERT INTO tblAccountJournal
|
||||
(AccountJournalTypeID, EntryDate, IsLocked)
|
||||
OUTPUT INSERTED.AccountJournalID
|
||||
VALUES
|
||||
(@journalTypeId, @entryDate, @lockEntry)
|
||||
", conn))
|
||||
{
|
||||
// add parameters
|
||||
cmd.Parameters.AddWithValue("@journalTypeId", journalTypeId);
|
||||
cmd.Parameters.AddWithValue("@entryDate", entryDate.ToUniversalTime());
|
||||
cmd.Parameters.AddWithValue("@lockEntry", lockEntry);
|
||||
|
||||
//execute
|
||||
journalId = (int)cmd.ExecuteScalar();
|
||||
}
|
||||
|
||||
// insert journal entries
|
||||
bool postResult = AccountJournalPostInsert(sqlConnectionString, journalId, entryDate, currencyCode, amount, debitAccountId, creditAccountId);
|
||||
|
||||
scope.Complete();
|
||||
return journalId;
|
||||
}
|
||||
}
|
||||
|
||||
// return false on locked journal entry
|
||||
public static bool AccountJournalDelete(string sqlConnectionString, int accountJournalId)
|
||||
{
|
||||
// check if journal entry is locked
|
||||
using (TransactionScope scope = new TransactionScope())
|
||||
{
|
||||
bool IsLocked = Account.AccountQuery.AccountJournalEntryIsLocked(sqlConnectionString, accountJournalId);
|
||||
if (IsLocked == true)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
using (SqlConnection conn = new SqlConnection(sqlConnectionString))
|
||||
{
|
||||
conn.Open();
|
||||
|
||||
// make the delete
|
||||
using (SqlCommand cmd = new SqlCommand(@"
|
||||
DELETE FROM tblAccountJournalPost
|
||||
WHERE AccountJournalID=@accountJournalId;
|
||||
", conn))
|
||||
{
|
||||
cmd.Parameters.AddWithValue("@accountJournalId", accountJournalId);
|
||||
|
||||
int rows = cmd.ExecuteNonQuery();
|
||||
|
||||
if (rows == 0)
|
||||
{
|
||||
throw new Exception("Journal entry and/or entry posts do not exist for AccountJournalId=" + accountJournalId);
|
||||
}
|
||||
}
|
||||
|
||||
using (SqlCommand cmd = new SqlCommand(@"
|
||||
DELETE FROM tblAccountJournal
|
||||
WHERE AccountJournalID=@accountJournalId;
|
||||
", conn))
|
||||
{
|
||||
cmd.Parameters.AddWithValue("@accountJournalId", accountJournalId);
|
||||
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
|
||||
scope.Complete();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static bool AccountJournalPostInsert(string sqlConnectionString, int journalId, DateTime entryDate,
|
||||
string currencyCode, decimal amount, int debitAccountId = 0, int creditAccountId = 0)
|
||||
{
|
||||
int defaultDebit;
|
||||
int defaultCredit;
|
||||
entryDate = DateTime.SpecifyKind(entryDate, DateTimeKind.Utc);
|
||||
|
||||
using (TransactionScope scope = new TransactionScope())
|
||||
using (SqlConnection conn = new SqlConnection(sqlConnectionString))
|
||||
{
|
||||
conn.Open();
|
||||
|
||||
// ensure their are no other entries
|
||||
using (SqlCommand cmd = new SqlCommand(@"
|
||||
SELECT
|
||||
Count(tblAccountJournalPost.AccountJournalPostID) AS CountOfAccountJournalPostID
|
||||
FROM
|
||||
tblAccountJournalPost
|
||||
WHERE
|
||||
(((tblAccountJournalPost.AccountJournalID)=@AccountJournalID));
|
||||
", conn))
|
||||
{
|
||||
cmd.Parameters.AddWithValue("@AccountJournalID", journalId);
|
||||
|
||||
int count = (int)cmd.ExecuteScalar();
|
||||
|
||||
if (count > 0)
|
||||
{
|
||||
throw new Exception("Unable the insert journal posts, post already present AccountJournalID=" + journalId);
|
||||
}
|
||||
}
|
||||
|
||||
//checks
|
||||
using (SqlCommand cmd = new SqlCommand(@"
|
||||
SELECT
|
||||
tblAccountJournalType.ChartOfAccountID_Debit, tblAccountJournalType.ChartOfAccountID_Credit
|
||||
FROM
|
||||
tblAccountJournal
|
||||
INNER JOIN tblAccountJournalType
|
||||
ON tblAccountJournal.AccountJournalTypeID = tblAccountJournalType.AccountJournalTypeID
|
||||
WHERE
|
||||
(((tblAccountJournal.AccountJournalID)=@journalId));
|
||||
", conn))
|
||||
{
|
||||
cmd.Parameters.AddWithValue("@journalId", journalId);
|
||||
|
||||
using (SqlDataReader reader = cmd.ExecuteReader())
|
||||
{
|
||||
if (reader.Read())
|
||||
{
|
||||
// debit check
|
||||
if (reader.IsDBNull(0))
|
||||
{
|
||||
if (debitAccountId == 0)
|
||||
{
|
||||
throw new Exception("Debit Account ID required, default not set for journal type");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
defaultDebit = reader.GetInt32(0);
|
||||
if (debitAccountId == 0)
|
||||
{
|
||||
debitAccountId = defaultDebit;
|
||||
}
|
||||
else if (debitAccountId != defaultDebit)
|
||||
{
|
||||
throw new Exception("Debit Account ID supplied does not match default set for journal type");
|
||||
}
|
||||
|
||||
}
|
||||
// credit check
|
||||
if (reader.IsDBNull(1))
|
||||
{
|
||||
if (creditAccountId == 0)
|
||||
{
|
||||
throw new Exception("Credit Account ID required, default not set for journal type");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
defaultCredit = reader.GetInt32(1);
|
||||
if (creditAccountId == 0)
|
||||
{
|
||||
creditAccountId = defaultCredit;
|
||||
}
|
||||
else if (creditAccountId != defaultCredit)
|
||||
{
|
||||
throw new Exception("Credit Account ID supplied does not match default set for journal type");
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("AccountJournalID '" + journalId + "' does not exist.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// currency conversion
|
||||
if (currencyCode != "GBP")
|
||||
{
|
||||
amount = Core.Account.AccountQuery.CurrencyConvertToGbp(sqlConnectionString, currencyCode, amount, entryDate);
|
||||
}
|
||||
|
||||
// ensure decimal is rounded
|
||||
amount = Math.Round(amount, 2);
|
||||
|
||||
// insert debit post
|
||||
using (SqlCommand cmd = new SqlCommand(@"
|
||||
INSERT INTO tblAccountJournalPost
|
||||
(AccountJournalID, AccountChartOfID, AmountGbp)
|
||||
VALUES
|
||||
(@AccountJournalId, @AccountChartOfId, @AmountGbp)
|
||||
", conn))
|
||||
{
|
||||
// add parameters
|
||||
cmd.Parameters.AddWithValue("@AccountJournalId", journalId);
|
||||
cmd.Parameters.AddWithValue("@AccountChartOfId", debitAccountId);
|
||||
cmd.Parameters.AddWithValue("@AmountGbp", amount);
|
||||
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
|
||||
// insert credit post
|
||||
using (SqlCommand cmd = new SqlCommand(@"
|
||||
INSERT INTO tblAccountJournalPost
|
||||
(AccountJournalID, AccountChartOfID, AmountGbp)
|
||||
VALUES
|
||||
(@AccountJournalId, @AccountChartOfId, @AmountGbp)
|
||||
", conn))
|
||||
{
|
||||
// add parameters
|
||||
cmd.Parameters.AddWithValue("@AccountJournalId", journalId);
|
||||
cmd.Parameters.AddWithValue("@AccountChartOfId", creditAccountId);
|
||||
cmd.Parameters.AddWithValue("@AmountGbp", (amount * -1));
|
||||
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
|
||||
scope.Complete();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public static bool AccountJournalPostUpdate(string sqlConnectionString, int journalId, string currencyCode, decimal amount,
|
||||
int debitAccountId = 0, int creditAccountId = 0)
|
||||
{
|
||||
using (TransactionScope scope = new TransactionScope())
|
||||
using (SqlConnection conn = new SqlConnection(sqlConnectionString))
|
||||
{
|
||||
conn.Open();
|
||||
|
||||
// retrive journal entry date
|
||||
DateTime entryDate;
|
||||
using (SqlCommand cmd = new SqlCommand(@"
|
||||
SELECT
|
||||
tblAccountJournal.EntryDate
|
||||
FROM
|
||||
tblAccountJournal
|
||||
WHERE
|
||||
(((tblAccountJournal.AccountJournalID)=@accountJournalId));
|
||||
", conn))
|
||||
{
|
||||
cmd.Parameters.AddWithValue("@accountJournalId", journalId);
|
||||
|
||||
entryDate = DateTime.SpecifyKind((DateTime)cmd.ExecuteScalar(), DateTimeKind.Utc);
|
||||
}
|
||||
|
||||
// delete the original posts
|
||||
using (SqlCommand cmd = new SqlCommand(@"
|
||||
DELETE FROM
|
||||
tblAccountJournalPost
|
||||
WHERE
|
||||
(((tblAccountJournalPost.AccountJournalID)=@accountJournalId));
|
||||
", conn))
|
||||
{
|
||||
cmd.Parameters.AddWithValue("@accountJournalId", journalId);
|
||||
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
|
||||
//insert new posts
|
||||
bool postResult = AccountJournalPostInsert(sqlConnectionString, journalId, entryDate, currencyCode, amount, debitAccountId, creditAccountId);
|
||||
|
||||
// update modified date on journal
|
||||
using (SqlCommand cmd = new SqlCommand(@"
|
||||
UPDATE
|
||||
tblAccountJournal
|
||||
SET
|
||||
tblAccountJournal.LastModified=@utcNow
|
||||
WHERE
|
||||
(((tblAccountJournal.AccountJournalID)=@accountJournalId));
|
||||
", conn))
|
||||
{
|
||||
cmd.Parameters.AddWithValue("@accountJournalId", journalId);
|
||||
cmd.Parameters.AddWithValue("@utcNow", DateTime.UtcNow);
|
||||
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
|
||||
scope.Complete();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
namespace Sku
|
||||
{
|
||||
public class Sku
|
||||
{
|
||||
public static int GetSkuIdByType(string sqlConnectionString, int productId, int conditionId, int accountTaxCodeId, bool noMatchInsertNew)
|
||||
{
|
||||
using (TransactionScope scope = new TransactionScope())
|
||||
using (SqlConnection conn = new SqlConnection(sqlConnectionString))
|
||||
{
|
||||
conn.Open();
|
||||
|
||||
// look for existing entry
|
||||
using (SqlCommand cmd = new SqlCommand(@"
|
||||
SELECT
|
||||
tblSku.skuSkuID
|
||||
FROM
|
||||
tblSku
|
||||
WHERE
|
||||
(((tblSku.skuProductID)=@productId) AND ((tblSku.skuSkuConditionID)=@conditionId) AND ((tblSku.AccountTaxCodeID)=@accountTaxCodeId));
|
||||
", conn))
|
||||
{
|
||||
cmd.Parameters.AddWithValue("@productId", productId);
|
||||
cmd.Parameters.AddWithValue("@conditionId", conditionId);
|
||||
cmd.Parameters.AddWithValue("@accountTaxCodeId", accountTaxCodeId);
|
||||
|
||||
object obj = cmd.ExecuteScalar();
|
||||
if (obj != null)
|
||||
{
|
||||
return (int)obj;
|
||||
}
|
||||
}
|
||||
|
||||
// value check insert bool
|
||||
if (noMatchInsertNew == false)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
// get this far, check tax code id is a valid for SKU
|
||||
using (SqlCommand cmd = new SqlCommand(@"
|
||||
SELECT tblAccountTaxCode.InvoiceSales
|
||||
FROM tblAccountTaxCode
|
||||
WHERE (((tblAccountTaxCode.AccountTaxCodeID)=@accountTaxCodeId));
|
||||
", conn))
|
||||
{
|
||||
cmd.Parameters.AddWithValue("@accountTaxCodeId", accountTaxCodeId);
|
||||
|
||||
object obj = cmd.ExecuteScalar();
|
||||
|
||||
if (obj == null)
|
||||
{
|
||||
throw new Exception("AccountTaxCodeID=" + accountTaxCodeId + " doesn't exist!");
|
||||
}
|
||||
else
|
||||
{
|
||||
bool result = (bool)obj;
|
||||
if (result == false)
|
||||
{
|
||||
throw new Exception("AccountTaxCodeID=" + accountTaxCodeId + " is not a valid type for an SKU.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// get info to create sku number
|
||||
int skuCount;
|
||||
int skuSuffix;
|
||||
using (SqlCommand cmd = new SqlCommand("SELECT NEXT VALUE FOR SkuCountSequence;", conn))
|
||||
{
|
||||
skuCount = (int)cmd.ExecuteScalar();
|
||||
}
|
||||
using (SqlCommand cmd = new SqlCommand(@"
|
||||
SELECT tblSkuCondition.scnSkuNumberSuffix
|
||||
FROM tblSkuCondition
|
||||
WHERE (((tblSkuCondition.scnSkuConditionID)=@conditionId));
|
||||
", conn))
|
||||
{
|
||||
cmd.Parameters.AddWithValue("@conditionId", conditionId);
|
||||
|
||||
try
|
||||
{
|
||||
skuSuffix = (int)cmd.ExecuteScalar();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new Exception("Error retriving SKU number suffix for SkuConditionID=" + conditionId + "." +
|
||||
System.Environment.NewLine + "Error Message: " + ex.Message);
|
||||
}
|
||||
}
|
||||
string skuNumber = skuCount.ToString("D6") + "-" + skuSuffix.ToString("D2");
|
||||
|
||||
// insert new sku
|
||||
int skuId;
|
||||
using (SqlCommand cmd = new SqlCommand(@"
|
||||
INSERT INTO tblSku
|
||||
(skuSkuNumber, skuProductID, skuSkuConditionID, AccountTaxCodeID)
|
||||
OUTPUT INSERTED.skuSkuID
|
||||
VALUES
|
||||
(@skuNumber, @productId, @conditionId, @accountTaxCodeId)
|
||||
", conn))
|
||||
{
|
||||
cmd.Parameters.AddWithValue("@skuNumber", skuNumber);
|
||||
cmd.Parameters.AddWithValue("@productId", productId);
|
||||
cmd.Parameters.AddWithValue("@conditionId", conditionId);
|
||||
cmd.Parameters.AddWithValue("@accountTaxCodeId", accountTaxCodeId);
|
||||
|
||||
skuId = (int)cmd.ExecuteScalar();
|
||||
}
|
||||
|
||||
scope.Complete();
|
||||
return skuId;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
namespace Stock
|
||||
{
|
||||
@@ -878,7 +242,7 @@ namespace bnhtrade.Core
|
||||
conn.Open();
|
||||
|
||||
// add account journal entry
|
||||
int accountJournalId = Account.AccountQuery.AccountJournalInsert(sqlConnectionString, accountJournalType, entryDate, currencyCode, amount);
|
||||
int accountJournalId = new Logic.Account.Journal().AccountJournalInsert(accountJournalType, entryDate, currencyCode, amount);
|
||||
|
||||
// make the stock insert
|
||||
int stockId = WIP_StockInsertSub(sqlConnectionString, productId, conditionId, accountTaxCodeId,
|
||||
@@ -1068,7 +432,7 @@ namespace bnhtrade.Core
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("Manual delete of this stock type is not supported, use the moethod that created it!");
|
||||
throw new Exception("Manual delete of this stock type is not supported, use the method that created it!");
|
||||
}
|
||||
|
||||
// check there is only one stock journal entry for stock item
|
||||
@@ -1248,7 +612,7 @@ namespace bnhtrade.Core
|
||||
}
|
||||
|
||||
// delete account journal entry
|
||||
Account.AccountQuery.AccountJournalDelete(sqlConnectionString, accountJournalId);
|
||||
new Data.Database.Account.DeleteJournal().AccountJournalDelete(accountJournalId);
|
||||
|
||||
scope.Complete();
|
||||
}
|
||||
@@ -1398,6 +762,7 @@ namespace bnhtrade.Core
|
||||
}
|
||||
|
||||
// insert journal posts into database
|
||||
//new Data.Database.Stock
|
||||
Core.Stock.StockJournal.StockJournalPostInsert(conn, stockId, stockJournalId, journalPosts, isNewStock);
|
||||
|
||||
// consistency check
|
||||
@@ -1979,8 +1344,8 @@ namespace bnhtrade.Core
|
||||
conn.Open();
|
||||
|
||||
// create account journal entry
|
||||
int journalId = Account.AccountQuery.AccountJournalInsert(
|
||||
sqlConnectionString, accountJournalTypeIdNet, entryDate, currencyCode, amountNet, debitAccountId);
|
||||
int journalId = new Data.Database.Account.CreateJournal().AccountJournalInsert(
|
||||
accountJournalTypeIdNet, entryDate, currencyCode, amountNet, debitAccountId);
|
||||
|
||||
// add transaction to purchase line transaction table
|
||||
using (SqlCommand cmd = new SqlCommand(@"
|
||||
@@ -2042,8 +1407,7 @@ namespace bnhtrade.Core
|
||||
}
|
||||
|
||||
// make the update
|
||||
bool result = Core.Account.AccountQuery.AccountJournalPostUpdate(sqlConnectionString,
|
||||
accountJouranlId, currencyCode, amountNet, debitAccountId, creditAccountId);
|
||||
bool result = new Data.Database.Account.UpdateJournal().AccountJournalPostUpdate(accountJouranlId, currencyCode, amountNet, debitAccountId, creditAccountId);
|
||||
|
||||
scope.Complete();
|
||||
}
|
||||
@@ -2140,7 +1504,7 @@ namespace bnhtrade.Core
|
||||
}
|
||||
|
||||
// delete account journal entry
|
||||
Account.AccountQuery.AccountJournalDelete(sqlConnectionString, accountJournalId);
|
||||
new Data.Database.Account.DeleteJournal().AccountJournalDelete(accountJournalId);
|
||||
|
||||
scope.Complete();
|
||||
}
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("bnhtrade Database Client")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("bnhtrade Database Client")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2017")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("339d7413-3da7-46ea-a55c-255a9a6b95eb")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms.Design;
|
||||
|
||||
namespace bnhtrade.Core.Test.Account
|
||||
{
|
||||
@@ -10,10 +11,28 @@ namespace bnhtrade.Core.Test.Account
|
||||
{
|
||||
public Account()
|
||||
{
|
||||
//var inst = new Data.Database.Account.GetTaxCode(sqlConnectionString);
|
||||
//inst.
|
||||
Journal();
|
||||
}
|
||||
|
||||
//var taxInfo = inst.GetAll();
|
||||
public void PurchaseInvoice()
|
||||
{
|
||||
var read = new Data.Database.Account.ReadPurchaseInvoice();
|
||||
read.PurchaseInvoiceIdList = new List<int> { 14718, 100, 101, 102, 300, 400, 1200, 2734, 6339, 9999 }; // 10 in total
|
||||
var result = read.Read();
|
||||
}
|
||||
|
||||
public void PurchaseInvoiceLine()
|
||||
{
|
||||
var read = new Data.Database.Account.ReadPurchaseInvoiceLine();
|
||||
read.ItemDescription = new List<string> { "xbox", "kill" };
|
||||
var result = read.Read();
|
||||
}
|
||||
|
||||
public void Journal()
|
||||
{
|
||||
var read = new Data.Database.Account.ReadJournal();
|
||||
read.AccountJournalId = new List<uint> { 123, 300, 324, 5678, 22 };
|
||||
var result = read.Read();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
94
src/bnhtrade.Core/Test/_BoilerPlate/sql_Read.cs
Normal file
94
src/bnhtrade.Core/Test/_BoilerPlate/sql_Read.cs
Normal file
@@ -0,0 +1,94 @@
|
||||
using bnhtrade.Core.Data.Database;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.SqlClient;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace bnhtrade.Core.Test._BoilerPlate
|
||||
{
|
||||
internal class xxxxxxxYourClassNameHerexxxxxxxx : Connection
|
||||
{
|
||||
private bnhtrade.Core.Data.Database.SqlWhereBuilder sqlBuilder;
|
||||
|
||||
/// <summary>
|
||||
/// Results filter
|
||||
/// </summary>
|
||||
public List<int> ColumnTitle1List { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Searches for the specificed phases within the item description. Uses the LIKE AND sql function
|
||||
/// </summary>
|
||||
public List<string> ColumnTitle2List { get; set; }
|
||||
|
||||
public xxxxxxxYourClassNameHerexxxxxxxx()
|
||||
{
|
||||
Init();
|
||||
}
|
||||
|
||||
public void Init()
|
||||
{
|
||||
sqlBuilder = new SqlWhereBuilder();
|
||||
ColumnTitle1List = new List<int>();
|
||||
ColumnTitle2List = new List<string>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <returns>Dictionary were key is the table primary key</returns>
|
||||
public Dictionary<int, string> Read()
|
||||
{
|
||||
// create the return (emptyP list) here
|
||||
var returnList = new Dictionary<int, string>();
|
||||
sqlBuilder.Init();
|
||||
|
||||
//build sql query
|
||||
string sql = @"
|
||||
SELECT item1, item2, item3
|
||||
FROM tblPurchaseLine
|
||||
WHERE 1 = 1 ";
|
||||
|
||||
// build the where statments
|
||||
if (ColumnTitle1List.Any())
|
||||
{
|
||||
sqlBuilder.In("xxxxxxxxxxxxxxColumnTitle1xxxxxxxxxxxxxxxxxx", ColumnTitle1List, "AND");
|
||||
}
|
||||
if (ColumnTitle2List.Any())
|
||||
{
|
||||
sqlBuilder.In("xxxxxxxxxxxxxxColumnTitle2xxxxxxxxxxxxxxxxxx", ColumnTitle2List, "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)
|
||||
{
|
||||
while (reader.Read())
|
||||
{
|
||||
// read from db and create object
|
||||
// and add to return list
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// all done, return the list here
|
||||
return returnList;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,356 +1,30 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="..\..\packages\NUnit.4.1.0\build\NUnit.props" Condition="Exists('..\..\packages\NUnit.4.1.0\build\NUnit.props')" />
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{339D7413-3DA7-46EA-A55C-255A9A6B95EB}</ProjectGuid>
|
||||
<TargetFramework>net8.0-windows</TargetFramework>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>bnhtrade.Core</RootNamespace>
|
||||
<AssemblyName>bnhtrade.Core</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||
<TargetFrameworkProfile />
|
||||
<NuGetPackageImportStamp>
|
||||
</NuGetPackageImportStamp>
|
||||
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
|
||||
<UseWindowsForms>true</UseWindowsForms>
|
||||
<ImportWindowsDesktopTargets>true</ImportWindowsDesktopTargets>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>..\..\bin\Debug\core\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<OutputPath>..\..\bin\$(AssemblyName)\Debug\</OutputPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugType>none</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>..\..\bin\Release\core\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<OutputPath>..\..\bin\$(AssemblyName)\Release\</OutputPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<StartupObject />
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="AWSSDK.Core, Version=3.3.0.0, Culture=neutral, PublicKeyToken=885c28607f98e604, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\AWSSDK.Core.3.7.303.15\lib\net45\AWSSDK.Core.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="AWSSDK.SecurityToken, Version=3.3.0.0, Culture=neutral, PublicKeyToken=885c28607f98e604, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\AWSSDK.SecurityToken.3.7.300.76\lib\net45\AWSSDK.SecurityToken.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="AWSSDK.SQS, Version=3.3.0.0, Culture=neutral, PublicKeyToken=885c28607f98e604, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\AWSSDK.SQS.3.7.300.75\lib\net45\AWSSDK.SQS.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="CsvHelper, Version=31.0.0.0, Culture=neutral, PublicKeyToken=8c4959082be5c823, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\CsvHelper.31.0.4\lib\net47\CsvHelper.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Dapper, Version=2.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\Dapper.2.1.35\lib\net461\Dapper.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Dapper.Contrib, Version=2.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\Dapper.Contrib.2.0.78\lib\net461\Dapper.Contrib.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="FikaAmazonAPI, Version=1.7.17.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\CSharpAmazonSpAPI.1.7.17\lib\netstandard2.0\FikaAmazonAPI.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Bcl.AsyncInterfaces, Version=8.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\Microsoft.Bcl.AsyncInterfaces.8.0.0\lib\net462\Microsoft.Bcl.AsyncInterfaces.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Bcl.HashCode, Version=1.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\Microsoft.Bcl.HashCode.1.1.1\lib\net461\Microsoft.Bcl.HashCode.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\Newtonsoft.Json.13.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="nunit.framework, Version=4.0.1.0, Culture=neutral, PublicKeyToken=2638cd05610744eb, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\NUnit.4.1.0\lib\net462\nunit.framework.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="nunit.framework.legacy, Version=4.0.1.0, Culture=neutral, PublicKeyToken=2638cd05610744eb, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\NUnit.4.1.0\lib\net462\nunit.framework.legacy.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="RestSharp, Version=110.2.0.0, Culture=neutral, PublicKeyToken=598062e77f915f75, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\RestSharp.110.2.0\lib\net471\RestSharp.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="RestSharp.Serializers.NewtonsoftJson, Version=110.2.0.0, Culture=neutral, PublicKeyToken=598062e77f915f75, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\RestSharp.Serializers.NewtonsoftJson.110.2.0\lib\net471\RestSharp.Serializers.NewtonsoftJson.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="StandardSocketsHttpHandler, Version=2.2.0.8, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\StandardSocketsHttpHandler.2.2.0.8\lib\netstandard2.0\StandardSocketsHttpHandler.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Buffers, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.ComponentModel.Annotations, Version=4.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\System.ComponentModel.Annotations.5.0.0\lib\net461\System.ComponentModel.Annotations.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.ComponentModel.DataAnnotations" />
|
||||
<Reference Include="System.Configuration" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.IO.Compression.FileSystem" />
|
||||
<Reference Include="System.Memory, Version=4.0.1.2, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\System.Memory.4.5.5\lib\net461\System.Memory.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Numerics" />
|
||||
<Reference Include="System.Numerics.Vectors, Version=4.1.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Reflection, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\System.Reflection.4.3.0\lib\net462\System.Reflection.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\System.Runtime.CompilerServices.Unsafe.6.0.0\lib\net461\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Runtime.Serialization" />
|
||||
<Reference Include="System.Text.Encodings.Web, Version=8.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\System.Text.Encodings.Web.8.0.0\lib\net462\System.Text.Encodings.Web.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Text.Json, Version=8.0.0.3, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\System.Text.Json.8.0.3\lib\net462\System.Text.Json.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Threading.Tasks.Extensions, Version=4.2.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Transactions" />
|
||||
<Reference Include="System.ValueTuple, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\System.ValueTuple.4.5.0\lib\net47\System.ValueTuple.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Web" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Compile Remove="Data\Database\Inventory\**" />
|
||||
<EmbeddedResource Remove="Data\Database\Inventory\**" />
|
||||
<None Remove="Data\Database\Inventory\**" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Data\Amazon\FbaInventory\GetFbaInventoryInfo.cs" />
|
||||
<Compile Include="Data\Amazon\Feeds\GetFeed.cs" />
|
||||
<Compile Include="Data\Amazon\Feeds\SubmittFeed.cs" />
|
||||
<Compile Include="Data\Amazon\Feeds\SampleFeeds.cs" />
|
||||
<Compile Include="Data\Amazon\FulFillmentInbound\GetShipmentItems.cs" />
|
||||
<Compile Include="Data\Amazon\FulFillmentInbound\GetShipments.cs" />
|
||||
<Compile Include="Data\Amazon\FulFillmentInbound\CreateInboundShipmentPlan.cs" />
|
||||
<Compile Include="Data\Amazon\ProductFee\GetFeeEstimate.cs" />
|
||||
<Compile Include="Data\Amazon\ProductPricing\GetCompetitivePricing.cs" />
|
||||
<Compile Include="Data\Amazon\Report\FbaInventoryAdustment.cs" />
|
||||
<Compile Include="Data\Amazon\Report\FbaInventoryAge.cs" />
|
||||
<Compile Include="Data\Amazon\Report\FbaInventory.cs" />
|
||||
<Compile Include="Data\Amazon\Report\FbaInventoryReceipt.cs" />
|
||||
<Compile Include="Data\Amazon\Report\FbaCustomerReturn.cs" />
|
||||
<Compile Include="Data\Amazon\Report\FbaInventoryLedgerDetailed.cs" />
|
||||
<Compile Include="Data\Amazon\Report\FbaReimbursement.cs" />
|
||||
<Compile Include="Data\Amazon\Report\FbaRemovalOrder.cs" />
|
||||
<Compile Include="Data\Amazon\Report\FbaSaleShipment.cs" />
|
||||
<Compile Include="Data\Amazon\Report\ReportLogic.cs" />
|
||||
<Compile Include="Data\Amazon\SellingPartnerAPI\SpApiConnection.cs" />
|
||||
<Compile Include="Data\Amazon\SellingPartnerAPI\Defaults.cs" />
|
||||
<Compile Include="Data\Amazon\Report\SettlementReport.cs" />
|
||||
<Compile Include="Data\Amazon\SellingPartnerAPI\Services\ReportService.cs" />
|
||||
<Compile Include="Data\Amazon\SellingPartnerAPI\Utils\CurrentDateTime.cs" />
|
||||
<Compile Include="Config.cs" />
|
||||
<Compile Include="Data\Database\Account\CreateInvoiceLineItem.cs" />
|
||||
<Compile Include="Data\Database\Account\ReadAccountCode.cs" />
|
||||
<Compile Include="Data\Database\Account\ReadTaxCode.cs" />
|
||||
<Compile Include="Data\Database\Amazon\FeeEstimate.cs" />
|
||||
<Compile Include="Data\Database\Connection.cs" />
|
||||
<Compile Include="Data\Database\Consistency\ImportAmazonSettlement.cs" />
|
||||
<Compile Include="Data\Database\Account\ReadInvoiceLineItem.cs" />
|
||||
<Compile Include="Data\Database\Constants.cs" />
|
||||
<Compile Include="Data\Database\Export\CreateAmazonFeedSubmission.cs" />
|
||||
<Compile Include="Data\Database\Export\ReadAmazonFeedSubmission.cs" />
|
||||
<Compile Include="Data\Database\Export\UpdateAmazonFeedSubmission.cs" />
|
||||
<Compile Include="Data\Database\AmazonFba\ReadShipmentInfo.cs" />
|
||||
<Compile Include="Data\Database\AmazonFba\ReadShipmentPrimaryKey.cs" />
|
||||
<Compile Include="Data\Database\AmazonFba\SetShipmentInfo.cs" />
|
||||
<Compile Include="Data\Database\Import\AmazonFbaInventoryAdjustment.cs" />
|
||||
<Compile Include="Data\Database\Import\AmazonFbaInventoryLedgerDetail.cs" />
|
||||
<Compile Include="Data\Database\Product\ReadProduct.cs" />
|
||||
<Compile Include="Data\Database\Product\ReadProductId.cs" />
|
||||
<Compile Include="Data\Database\ReadRandomData.cs" />
|
||||
<Compile Include="Data\Database\Sku\InsertSku.cs" />
|
||||
<Compile Include="Data\Database\Sku\ReadSku.cs" />
|
||||
<Compile Include="Data\Database\Stock\InsertSkuTransactionType.cs" />
|
||||
<Compile Include="Data\Database\Stock\JournalCrud.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\Stock.cs" />
|
||||
<Compile Include="Logic\Import\Amazon.cs" />
|
||||
<Compile Include="Logic\Import\AmazonFbaInventoryAdjustment.cs" />
|
||||
<Compile Include="Data\Database\Import\AmazonFbaInventoryAgeData.cs" />
|
||||
<Compile Include="Data\Database\Import\AmazonFbaInventoryData.cs" />
|
||||
<Compile Include="Data\Database\Import\AmazonFbaInventoryReceipt.cs" />
|
||||
<Compile Include="Data\Database\Import\AmazonFbaReimbursement.cs" />
|
||||
<Compile Include="Data\Database\Import\AmazonFbaRemovalOrder.cs" />
|
||||
<Compile Include="Data\Database\Import\AmazonFbaCustomerReturn.cs" />
|
||||
<Compile Include="Data\Database\Import\AmazonFbaSaleShipment.cs" />
|
||||
<Compile Include="Data\Database\Import\AmazonSettlementInsert.cs" />
|
||||
<Compile Include="Data\Database\Import\AmazonSettlementRead.cs" />
|
||||
<Compile Include="Data\Database\Import\AmazonSettlementHeaderRead.cs" />
|
||||
<Compile Include="Data\Database\Import\AmazonFbaInventoryAgeRead.cs" />
|
||||
<Compile Include="Data\Database\Import\AmazonSettlementUpdate.cs" />
|
||||
<Compile Include="Data\Database\Product\CreateCompetitivePrice.cs" />
|
||||
<Compile Include="Data\Database\Product\ReadCompetitivePrice.cs" />
|
||||
<Compile Include="Data\Database\Sku\Price\CreatePricingDetail.cs" />
|
||||
<Compile Include="Data\Database\Sku\Price\ReadPricingDetail.cs" />
|
||||
<Compile Include="Data\Database\Sku\Price\ReadParameter.cs" />
|
||||
<Compile Include="Data\Database\Log\DateTimeLog.cs" />
|
||||
<Compile Include="Data\Database\Log\LogEvent.cs" />
|
||||
<Compile Include="Data\Database\Programmability\Sequence.cs" />
|
||||
<Compile Include="Data\Database\Sku\ReadSkuConditionInfo.cs" />
|
||||
<Compile Include="Data\Database\Stock\InsertSkuTransaction.cs" />
|
||||
<Compile Include="Data\Database\Stock\DeleteSkuTransaction.cs" />
|
||||
<Compile Include="Data\Database\Stock\ReadSkuTransaction.cs" />
|
||||
<Compile Include="Data\Database\Stock\ReadSkuTransactionType.cs" />
|
||||
<Compile Include="Data\Database\Stock\ReadStatusBalance.cs" />
|
||||
<Compile Include="Data\Database\Stock\ReadStatusTransaction.cs" />
|
||||
<Compile Include="Data\Database\Stock\ReadStockId.cs" />
|
||||
<Compile Include="Data\Database\Stock\UpdateSkuTransaction.cs" />
|
||||
<Compile Include="Data\Database\SqlWhereBuilder.cs" />
|
||||
<Compile Include="Extensions.cs" />
|
||||
<Compile Include="Logic\Account\GetAccountCodeInfo.cs" />
|
||||
<Compile Include="Logic\Account\GetInvoiceLineItem.cs" />
|
||||
<Compile Include="Logic\Account\TaxCalculation.cs" />
|
||||
<Compile Include="Logic\Account\GetTaxCodeInfo.cs" />
|
||||
<Compile Include="Logic\Import\AmazonFbaInventory.cs" />
|
||||
<Compile Include="Logic\Import\AmazonFbaInventoryAge.cs" />
|
||||
<Compile Include="Logic\Import\AmazonFbaInventoryLedgerDetail.cs" />
|
||||
<Compile Include="Logic\Import\AmazonFbaInventoryReceipt.cs" />
|
||||
<Compile Include="Logic\Import\AmazonFbaCustomerReturn.cs" />
|
||||
<Compile Include="Logic\Import\AmazonFbaReimbursement.cs" />
|
||||
<Compile Include="Logic\Import\AmazonFbaRemovalOrder.cs" />
|
||||
<Compile Include="Logic\Import\AmazonFbaSaleShipment.cs" />
|
||||
<Compile Include="Logic\Import\AmazonSettlement.cs" />
|
||||
<Compile Include="Logic\Product\AmazonCompetitivePrice.cs" />
|
||||
<Compile Include="Logic\Product\AmazonEstimateFee.cs" />
|
||||
<Compile Include="Logic\Product\GetProductInfo.cs" />
|
||||
<Compile Include="Logic\Sku\GetSkuInfo.cs" />
|
||||
<Compile Include="Logic\Stock\StatusTypeBalance.cs" />
|
||||
<Compile Include="Logic\Stock\SkuTransactionImport.cs" />
|
||||
<Compile Include="Logic\Stock\StatusBalance.cs" />
|
||||
<Compile Include="Logic\Utilities\EasyMD5.cs" />
|
||||
<Compile Include="Logic\Utilities\File.cs" />
|
||||
<Compile Include="Logic\Utilities\NightlyRoutine.cs" />
|
||||
<Compile Include="Logic\Validate\AccountCode.cs" />
|
||||
<Compile Include="Logic\Validate\CurrencyCode.cs" />
|
||||
<Compile Include="Logic\Validate\SalesInvoice.cs" />
|
||||
<Compile Include="Logic\AmazonFBAInbound\ShipmentInfoPersistanceUpdate.cs" />
|
||||
<Compile Include="Data\Database\Export\CreateSalesInvoice.cs" />
|
||||
<Compile Include="Logic\Export\AmazonSubmitFile.cs" />
|
||||
<Compile Include="Logic\Sku\GetSkuConditionInfo.cs" />
|
||||
<Compile Include="Logic\Stock\StatusReallocate.cs" />
|
||||
<Compile Include="Logic\Stock\SkuTransactionReconcile.cs" />
|
||||
<Compile Include="Logic\Stock\SkuTransactionCrud.cs" />
|
||||
<Compile Include="Logic\Stock\SkuTransactionTypeCrud.cs" />
|
||||
<Compile Include="Logic\Export\SalesInvoice.cs" />
|
||||
<Compile Include="Logic\Export\AmazonSettlement.cs" />
|
||||
<Compile Include="Logic\Validate\AmazonSettlement.cs" />
|
||||
<Compile Include="Logic\Product\GetCompetitivePrice.cs" />
|
||||
<Compile Include="Logic\Sku\Price\FbaPricing.cs" />
|
||||
<Compile Include="Logic\Sku\Price\UpdateRepricingValues.cs" />
|
||||
<Compile Include="Logic\Utilities\CalculateMD5.cs" />
|
||||
<Compile Include="Logic\Utilities\DateTimeParse.cs" />
|
||||
<Compile Include="Logic\Validate\AmazonIventoryLoaderFile.cs" />
|
||||
<Compile Include="Logic\Validate\Format.cs" />
|
||||
<Compile Include="Logic\Validate\SkuTransaction.cs" />
|
||||
<Compile Include="Logic\Validate\TaxCodeInfo.cs" />
|
||||
<Compile Include="Logic\Validate\Validate.cs" />
|
||||
<Compile Include="Logic\Log\LogEvent.cs" />
|
||||
<Compile Include="Logic\Utilities\DateTimeCheck.cs" />
|
||||
<Compile Include="Logic\Utilities\DecimalCheck.cs" />
|
||||
<Compile Include="Logic\Utilities\PropertyCheck.cs" />
|
||||
<Compile Include="Logic\Utilities\StringCheck.cs" />
|
||||
<Compile Include="Logic\Utilities\AccountVat.cs" />
|
||||
<Compile Include="Logic\Validate\SkuPriceInfo.cs" />
|
||||
<Compile Include="Model\Account\Account.cs" />
|
||||
<Compile Include="Model\Account\InvoiceHeader.cs" />
|
||||
<Compile Include="Model\Account\Invoice.cs" />
|
||||
<Compile Include="Model\Account\InvoiceLineItem.cs" />
|
||||
<Compile Include="Model\Account\SalesInvoice.cs" />
|
||||
<Compile Include="Model\Account\TaxCodeInfo.cs" />
|
||||
<Compile Include="Model\AmazonFba\ShippingPlanItem.cs" />
|
||||
<Compile Include="Model\Amazon\ProductFeeEstimate.cs" />
|
||||
<Compile Include="Model\Credentials\AmazonSPAPI.cs" />
|
||||
<Compile Include="Model\Credentials\bnhtradeDB.cs" />
|
||||
<Compile Include="Model\Data\DatabaseFileStream.cs" />
|
||||
<Compile Include="Model\Export\AmazonFeedSubmission.cs" />
|
||||
<Compile Include="Model\Export\AmazonIventoryLoaderFile.cs" />
|
||||
<Compile Include="Model\Import\AmazonFbaInventoryLedgerDetail.cs" />
|
||||
<Compile Include="Model\Import\AmazonFbaReimbursement.cs" />
|
||||
<Compile Include="Model\Import\AmazonSettlement.cs" />
|
||||
<Compile Include="Model\Import\AmazonSettlementHeader.cs" />
|
||||
<Compile Include="Model\Product\CompetitivePrice.cs" />
|
||||
<Compile Include="Model\Product\ProductInfo.cs" />
|
||||
<Compile Include="Model\Amazon\ProductCompetitivePrice.cs" />
|
||||
<Compile Include="Model\Sku\Price\DetailRequest.cs" />
|
||||
<Compile Include="Model\Sku\Price\DetailResponce.cs" />
|
||||
<Compile Include="Model\Sku\Price\PriceInfo.cs" />
|
||||
<Compile Include="Model\Sku\Price\SkuPriceParameter.cs" />
|
||||
<Compile Include="Model\Sku\Price\SkuRepriceInfo.cs" />
|
||||
<Compile Include="Model\Sku\Sku.cs" />
|
||||
<Compile Include="Model\Sku\SkuConditionInfo.cs" />
|
||||
<Compile Include="Model\Stock\JournalEntry.cs" />
|
||||
<Compile Include="Model\Stock\SkuTransactionDepreciated.cs" />
|
||||
<Compile Include="Model\Stock\SkuTransactionCreate.cs" />
|
||||
<Compile Include="Model\Stock\SkuTransactionType.cs" />
|
||||
<Compile Include="Model\Stock\SkuTransaction.cs" />
|
||||
<Compile Include="Model\Stock\Status.cs" />
|
||||
<Compile Include="Model\Stock\StatusBalance.cs" />
|
||||
<Compile Include="Model\Stock\StatusTransaction.cs" />
|
||||
<Compile Include="Model\Stock\StatusType.cs" />
|
||||
<Compile Include="Test\Account\Account.cs" />
|
||||
<Compile Include="Test\Amazon\SP-API\FulfillmentInboundV0.cs" />
|
||||
<Compile Include="Test\Amazon\SP-API\Reports.cs" />
|
||||
<Compile Include="Test\Amazon\SP-API\VariousCalls.cs" />
|
||||
<Compile Include="Test\AutoExec.cs" />
|
||||
<Compile Include="Test\Export\Export.cs" />
|
||||
<Compile Include="Test\Import\Report.cs" />
|
||||
<Compile Include="Test\InboundShipmentInfo.cs" />
|
||||
<Compile Include="Logic\AmazonFBAInbound\ShipmentAddByFNSKU.cs" />
|
||||
<Compile Include="Test\InboundShipmentInfoSync.cs" />
|
||||
<Compile Include="Test\Amazon\Amazon.cs" />
|
||||
<Compile Include="Test\Logic\Export.cs" />
|
||||
<Compile Include="Test\Sku\Sku.cs" />
|
||||
<Compile Include="Test\SQLLoop.cs" />
|
||||
<Compile Include="Model\AmazonFba\ShipmentInfo.cs" />
|
||||
<Compile Include="Test\Stock\Stock.cs" />
|
||||
<Compile Include="Test\_BoilerPlate\ClassFromSql.cs" />
|
||||
<Compile Include="Test\_BoilerPlate\Sql.cs" />
|
||||
<Compile Include="UI\Console.cs" />
|
||||
<Compile Include="Model\AmazonFba\ShipmentItemInfo.cs" />
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Properties\Settings.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||
<DependentUpon>Settings.settings</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Logic\Sku\GetSkuId.cs" />
|
||||
<Compile Include="Data\Database\Sku\GetSkuId.cs" />
|
||||
<Compile Include="UI\ConsoleProgressBar.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="App.config" />
|
||||
<None Include="packages.config" />
|
||||
<None Include="Properties\Settings.settings">
|
||||
<Generator>SettingsSingleFileGenerator</Generator>
|
||||
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="Data\Database\Inventory\" />
|
||||
<Folder Include="Model\Inventory\" />
|
||||
<Folder Include="Model\Product\ProductPricing\" />
|
||||
<Folder Include="Test\Product\" />
|
||||
@@ -361,18 +35,23 @@
|
||||
<Analyzer Include="..\..\packages\AWSSDK.SQS.3.7.300.75\analyzers\dotnet\cs\AWSSDK.SQS.CodeAnalysis.dll" />
|
||||
<Analyzer Include="..\..\packages\AWSSDK.SQS.3.7.300.75\analyzers\dotnet\cs\SharedAnalysisCode.dll" />
|
||||
</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\NUnit.4.1.0\build\NUnit.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\NUnit.4.1.0\build\NUnit.props'))" />
|
||||
</Target>
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
<ItemGroup>
|
||||
<PackageReference Include="AWSSDK.Core" Version="3.7.303.15" />
|
||||
<PackageReference Include="AWSSDK.SecurityToken" Version="3.7.300.76">
|
||||
<TreatAsUsed>true</TreatAsUsed>
|
||||
</PackageReference>
|
||||
<PackageReference Include="CSharpAmazonSpAPI" Version="1.7.17" />
|
||||
<PackageReference Include="CsvHelper" Version="31.0.4" />
|
||||
<PackageReference Include="Dapper" Version="2.1.35" />
|
||||
<PackageReference Include="Dapper.Contrib" Version="2.0.78">
|
||||
<TreatAsUsed>true</TreatAsUsed>
|
||||
</PackageReference>
|
||||
<PackageReference Include="RestSharp" Version="110.2.0" />
|
||||
<PackageReference Include="RestSharp.Serializers.NewtonsoftJson" Version="110.2.0" />
|
||||
<PackageReference Include="System.Data.SqlClient" Version="4.8.6" />
|
||||
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Remove="Data\Database\Product\UpdateAmazonFeeEstimate.cs" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -1,29 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="AWSSDK.Core" version="3.7.303.15" targetFramework="net472" />
|
||||
<package id="AWSSDK.SecurityToken" version="3.7.300.76" targetFramework="net472" />
|
||||
<package id="AWSSDK.SQS" version="3.7.300.75" targetFramework="net472" />
|
||||
<package id="CSharpAmazonSpAPI" version="1.7.17" targetFramework="net472" />
|
||||
<package id="CsvHelper" version="31.0.4" targetFramework="net472" />
|
||||
<package id="Dapper" version="2.1.35" targetFramework="net472" />
|
||||
<package id="Dapper.Contrib" version="2.0.78" targetFramework="net472" />
|
||||
<package id="Microsoft.Bcl.AsyncInterfaces" version="8.0.0" targetFramework="net472" />
|
||||
<package id="Microsoft.Bcl.HashCode" version="1.1.1" targetFramework="net472" />
|
||||
<package id="Microsoft.CSharp" version="4.7.0" targetFramework="net471" />
|
||||
<package id="Newtonsoft.Json" version="13.0.3" targetFramework="net472" />
|
||||
<package id="NUnit" version="4.1.0" targetFramework="net472" />
|
||||
<package id="RestSharp" version="110.2.0" targetFramework="net472" />
|
||||
<package id="RestSharp.Serializers.NewtonsoftJson" version="110.2.0" targetFramework="net472" />
|
||||
<package id="StandardSocketsHttpHandler" version="2.2.0.8" targetFramework="net472" />
|
||||
<package id="System.Buffers" version="4.5.1" targetFramework="net472" />
|
||||
<package id="System.Collections" version="4.3.0" targetFramework="net472" />
|
||||
<package id="System.ComponentModel.Annotations" version="5.0.0" targetFramework="net472" />
|
||||
<package id="System.Memory" version="4.5.5" targetFramework="net472" />
|
||||
<package id="System.Numerics.Vectors" version="4.5.0" targetFramework="net472" />
|
||||
<package id="System.Reflection" version="4.3.0" targetFramework="net472" />
|
||||
<package id="System.Runtime.CompilerServices.Unsafe" version="6.0.0" targetFramework="net471" />
|
||||
<package id="System.Text.Encodings.Web" version="8.0.0" targetFramework="net472" />
|
||||
<package id="System.Text.Json" version="8.0.3" targetFramework="net472" />
|
||||
<package id="System.Threading.Tasks.Extensions" version="4.5.4" targetFramework="net471" />
|
||||
<package id="System.ValueTuple" version="4.5.0" targetFramework="net472" />
|
||||
</packages>
|
||||
Reference in New Issue
Block a user