mirror of
https://github.com/stokebob/bnhtrade.git
synced 2026-03-19 14:37:16 +00:00
* complete read invoices from db * wip * wip * wip * wip * wip * wip * wip * wip * updated nuget package spapi * WIP * wip, now test * wip, jut need to fix tax inclusive line amounts not supported * wip * wip, before I f everything up * no, it complies now, this is the one before I f everything up * wip * wip * wip, logic ready for testing * wip it builds!!!! * wip tested, working, need to complete the gui section * wip * wip * wip - created export invoice data delete, time for testing * wip testing phase * wip - delete function fully tested and working * wip on to sorting out the issue with settlement invoices not tallying * wip * wip * wip * wip * wip before I complete change the ReadInvoiceLineItem sections * that appears to have worked, on with the main quest * no it's doesn't work, saving before i remove the confusing cache system (just use a dictionary!!) * wipping picadilli * wip * wip * implemented uow on inovice export, now for testing * wip * wip all tested do invoice currency convertion fearure * wip * pretty much done so long as xero accepts the exported invoices * Complete!
178 lines
4.7 KiB
C#
178 lines
4.7 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace bnhtrade.Core.Model.Account
|
|
{
|
|
public class PurchaseInvoice
|
|
{
|
|
// the purchase/sales invoice models are fragmented. The sales invoice inherits from an abstract invoice class. However, this purchase invoice
|
|
// model doesn't, it was setup in the early development to mirror an Amazon report.
|
|
// At some point I would like to correct this, i.e. have the purchase invoice model inherit from the abstract invoice class.
|
|
// this will take some unpicking
|
|
|
|
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; }
|
|
}
|
|
}
|
|
}
|