mirror of
https://github.com/stokebob/bnhtrade.git
synced 2026-03-19 06:27:15 +00:00
wip
This commit is contained in:
@@ -8,7 +8,7 @@ using static System.ComponentModel.Design.ObjectSelectorEditor;
|
||||
|
||||
namespace bnhtrade.Core.Data.Database.Account
|
||||
{
|
||||
internal class PurchaseInvoice : Connection
|
||||
public class PurchaseInvoice : Connection
|
||||
{
|
||||
private bnhtrade.Core.Data.Database.SqlWhereBuilder sqlBuilder;
|
||||
|
||||
|
||||
@@ -44,6 +44,7 @@ namespace bnhtrade.Core.Data.Database.Account
|
||||
InvoiceIdList = new List<int>();
|
||||
InvoiceLineIdList = new List<int>();
|
||||
StatusList = new List<string>();
|
||||
ItemDescription = new List<string>();
|
||||
}
|
||||
|
||||
public Dictionary<int, Model.Account.PurchaseInvoice.Line> Read()
|
||||
@@ -104,6 +105,9 @@ namespace bnhtrade.Core.Data.Database.Account
|
||||
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();
|
||||
@@ -173,14 +177,35 @@ namespace bnhtrade.Core.Data.Database.Account
|
||||
line.RecordModified = recordModified;
|
||||
line.RecordCreated = recordCreated;
|
||||
line.IsActive = isActive;
|
||||
line.AccountTaxCode = accountTaxCode;
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,16 +6,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace bnhtrade.Core.Logic.Account
|
||||
{
|
||||
public class PurchaseInvoice
|
||||
public class PurchaseInvoice : Core.Data.Database.Account.PurchaseInvoice
|
||||
{
|
||||
public List<Model.Account.PurchaseInvoiceLineStatus> ReadLineStatusToList()
|
||||
{
|
||||
return new Data.Database.Account.PurchaseInvoiceLineStatus().Read().Values.ToList();
|
||||
}
|
||||
|
||||
public List<Model.Account.PurchaseInvoiceLineSummary> GetLineSummary(DateTime maxDate, string lineStatus, List<string> wordSearchList)
|
||||
{
|
||||
return new Data.Database.Account.PurchaseInvoiceLineSummary().Read(maxDate,lineStatus, wordSearchList);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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.PurchaseInvoiceLineStatus().Read().Values.ToList();
|
||||
}
|
||||
|
||||
public List<Model.Account.PurchaseInvoiceLineSummary> GetLineSummary(DateTime maxDate, string lineStatus, List<string> wordSearchList)
|
||||
{
|
||||
return new Data.Database.Account.PurchaseInvoiceLineSummary().Read(maxDate,lineStatus, wordSearchList);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,18 +9,71 @@ 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 PurchaseTotalAmount { 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; }
|
||||
@@ -28,24 +81,91 @@ namespace bnhtrade.Core.Model.Account
|
||||
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 string AccountTaxCode { 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; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user