mirror of
https://github.com/stokebob/bnhtrade.git
synced 2026-03-25 17:17:15 +00:00
Added invoice export function and started implementation of unitofwork pattern (#43)
* 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!
This commit is contained in:
41
src/bnhtrade.Core/Logic/Account/InvoiceLineItemService.cs
Normal file
41
src/bnhtrade.Core/Logic/Account/InvoiceLineItemService.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace bnhtrade.Core.Logic.Account
|
||||
{
|
||||
public class InvoiceLineItemService
|
||||
{
|
||||
private Logic.Log.LogEvent log = new Logic.Log.LogEvent();
|
||||
|
||||
/// <summary>
|
||||
/// Creates new 'default' item code entry. The item code and title are set, will require updating by user before use.
|
||||
/// </summary>
|
||||
/// <param name="itemCode">Item code string</param>
|
||||
/// <returns></returns>
|
||||
public Model.Account.InvoiceLineItem CreateNew(string itemCode)
|
||||
{
|
||||
new Data.Database.Account.CreateInvoiceLineItem().CreateDefault(itemCode);
|
||||
var item = new Data.Database.Account.ReadInvoiceLineItem().ByItemCode(new List<string> { itemCode });
|
||||
if (item == null || item.Count == 0)
|
||||
{
|
||||
log.LogError("InvoiceLineItemService.CreateNew", "Error creating new invoice line item in database for item code: " + itemCode);
|
||||
throw new Exception("Error creating new invoice line item in database");
|
||||
}
|
||||
return item[0];
|
||||
}
|
||||
|
||||
public Dictionary<string, Model.Account.InvoiceLineItem> GetLineItems(List<string> itemCodes)
|
||||
{
|
||||
var dbResult = new Data.Database.Account.ReadInvoiceLineItem().ByItemCode(itemCodes);
|
||||
var returnDict = new Dictionary<string, Model.Account.InvoiceLineItem>();
|
||||
foreach ( var item in dbResult)
|
||||
{
|
||||
returnDict.Add(item.Value.ItemCode, item.Value);
|
||||
}
|
||||
return returnDict;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user