3.0.1.3 Requirements
This commit is contained in:
@@ -15,7 +15,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
|
||||
//-------------------------------------------------------------------
|
||||
public static class Version
|
||||
{
|
||||
private static String version { get; } = "3.0.1.2";
|
||||
private static String version { get; } = "3.0.1.3";
|
||||
// Retrieve version.
|
||||
public static String GetFullVersion() { return version; }
|
||||
public static String GetAppVersion()
|
||||
@@ -40,6 +40,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
|
||||
// 3.0.1 19-Feb-25 Portal Transactions.
|
||||
// 3.0.1.1 19-Feb-25 Portal tidy.
|
||||
// 3.0.1.2 26-Feb-25 Requirements & tidy.
|
||||
// 3.0.1.3 02-Mar-25 Requirements.
|
||||
//-------------------------------------------------------------------
|
||||
// 3.0.0 Jul-2021 Initial demo test version.
|
||||
// 02-Feb-25 Initial live deployment.
|
||||
|
||||
@@ -0,0 +1,229 @@
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.Bus;
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.Consoles;
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.Core;
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.Mgr;
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.Mgr.Control;
|
||||
using Sarand.Net.Standard.Base.App;
|
||||
using Sarand.Net.Standard.Base.Bus;
|
||||
using Sarand.Net.Standard.Base.CodeTypes;
|
||||
using Sarand.Net.Standard.Base.Core;
|
||||
using Sarand.Net.Standard.Base.Dbas;
|
||||
using Sarand.Net.Standard.Base.Diary;
|
||||
using Sarand.Net.Standard.Base.Email;
|
||||
using Sarand.Net.Standard.Base.Interfaces;
|
||||
using Sarand.Net.Standard.Base.ItemData;
|
||||
using Sarand.Net.Standard.Base.ItemDocs;
|
||||
using Sarand.Net.Standard.Base.ItemOptions;
|
||||
using Sarand.Net.Standard.Base.ReferenceData;
|
||||
using Sarand.Net.Standard.Base.Security;
|
||||
using Sarand.Net.Standard.Base.UpdateLog;
|
||||
using Sarand.Net.Standard.Base.Utils;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace Sarand.BusinessMgr.Net.Standard.Base.App
|
||||
{
|
||||
//=======================================================================
|
||||
// Internals - Reference Data.
|
||||
//=======================================================================
|
||||
partial class SbmInternals
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
// Reference data.
|
||||
private class ReferenceData
|
||||
{
|
||||
public Dictionary<SysId, SaRegion> Regions { get; set; } = null;
|
||||
public Dictionary<SysId, SaCurrency> Currencies { get; set; } = null;
|
||||
public Dictionary<SysId, SaTaxCode> TaxCodes { get; set; } = null;
|
||||
public Dictionary<SysId, SaUnitMeasure> UnitsOfMeasure { get; set; } = null;
|
||||
}
|
||||
private ReferenceData rfd { get; } = new ReferenceData();
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// T a x C o d e s
|
||||
//-------------------------------------------------------------------
|
||||
private void populateRegions()
|
||||
{
|
||||
if (rfd.Regions != null) return;
|
||||
SaRegion.Params prmRegion = new SaRegion.Params();
|
||||
prmRegion.StatusCat = SaRegion.StatusCat.Any;
|
||||
rfd.Regions = ReferenceDataConsole.GetRegionList(prmRegion).ToDictionary(region => region.Id, region => region);
|
||||
}
|
||||
public List<SaRegion> GetRegions()
|
||||
{
|
||||
populateRegions();
|
||||
return new List<SaRegion>(rfd.Regions.Values);
|
||||
}
|
||||
public SaRegion GetRegionById(SysId regionId)
|
||||
{
|
||||
if (!SysId.IsValid(regionId)) return null;
|
||||
populateRegions();
|
||||
return rfd.Regions.GetValueOrDefault(regionId);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// C u r r e n c i e s
|
||||
//-------------------------------------------------------------------
|
||||
public static ushort CurrencyDecimalsDefault { get; } = 2;
|
||||
|
||||
// Current Currency - as defined by Organisation (or default).
|
||||
public String GetCurrentCurrencyCode()
|
||||
{
|
||||
return SaReferenceDataConsole.GetDefaultCurrencyCode();
|
||||
}
|
||||
public SaCurrency GetCurrentCurrency()
|
||||
{
|
||||
return GetCurrencies().FirstOrDefault(item => item.Code.EqualsCI(GetCurrentCurrencyCode()));
|
||||
}
|
||||
public ushort GetCurrentCurrencyDecimals()
|
||||
{
|
||||
return GetCurrencyDecimals(GetCurrentCurrency());
|
||||
}
|
||||
|
||||
// Currency Decimals.
|
||||
/// <summary>Constrain Currency Decimals - Min: 0, Max: 4.</summary>
|
||||
public static ushort GetCurrencyDecimals(ushort currencyDecimals)
|
||||
{
|
||||
return (ushort)Math.Min(4, Math.Max(0, (int)currencyDecimals));
|
||||
}
|
||||
/// <summary>
|
||||
/// Get the number of decimal places for the specified currency.
|
||||
/// <br/>Defaults to 'Current' currency if not specified or found.
|
||||
/// </summary>
|
||||
public ushort GetCurrencyDecimals(SaCurrency currency)
|
||||
{
|
||||
ushort currencyDecimals = CurrencyDecimalsDefault;
|
||||
if (currency == null)
|
||||
currency = GetCurrentCurrency();
|
||||
if (currency != null)
|
||||
currencyDecimals = (ushort)currency.Decimals;
|
||||
return GetCurrencyDecimals(currencyDecimals);
|
||||
}
|
||||
/// <summary>
|
||||
/// Get the number of decimal places for the specified currency.
|
||||
/// <br/>Defaults to 'Current' currency if not specified or found.
|
||||
/// </summary>
|
||||
public ushort GetCurrencyDecimalsById(SysId currencyId)
|
||||
{
|
||||
return GetCurrencyDecimals(GetCurrencyById(currencyId));
|
||||
}
|
||||
|
||||
// Currencies.
|
||||
private void populateCurrencies()
|
||||
{
|
||||
if (rfd.Currencies != null) return;
|
||||
SaCurrency.Params prmCurrency = new SaCurrency.Params();
|
||||
prmCurrency.StatusCat = SaCurrency.StatusCat.Any;
|
||||
rfd.Currencies = ReferenceDataConsole.GetCurrencyList(prmCurrency).ToDictionary(currency => currency.Id, currency => currency);
|
||||
}
|
||||
public List<SaCurrency> GetCurrencies()
|
||||
{
|
||||
populateCurrencies();
|
||||
return new List<SaCurrency>(rfd.Currencies.Values);
|
||||
}
|
||||
public SaCurrency GetCurrencyById(SysId currencyId)
|
||||
{
|
||||
if (!SysId.IsValid(currencyId)) return null;
|
||||
populateCurrencies();
|
||||
return rfd.Currencies.GetValueOrDefault(currencyId);
|
||||
}
|
||||
public SaCurrency GetCurrencyByCode(String currencyCode)
|
||||
{
|
||||
if (StringUtil.IsBlank(currencyCode))
|
||||
return null;
|
||||
populateCurrencies();
|
||||
return rfd.Currencies.Values.FirstOrDefault(item => item.Code.EqualsCI(currencyCode));
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// T a x C o d e s
|
||||
//-------------------------------------------------------------------
|
||||
public String GetDefaultTaxCode()
|
||||
{
|
||||
return SaReferenceDataConsole.GetTaxCode(SaTaxCodeType.Std);
|
||||
}
|
||||
private void populateTaxCodes()
|
||||
{
|
||||
if (rfd.TaxCodes != null) return;
|
||||
SaTaxCode.Params prmTaxCode = new SaTaxCode.Params();
|
||||
prmTaxCode.StatusCat = SaTaxCode.StatusCat.Any;
|
||||
rfd.TaxCodes = ReferenceDataConsole.GetTaxCodeList(prmTaxCode).ToDictionary(taxCode => taxCode.Id, taxCode => taxCode);
|
||||
}
|
||||
public List<SaTaxCode> GetTaxCodes()
|
||||
{
|
||||
populateTaxCodes();
|
||||
return new List<SaTaxCode>(rfd.TaxCodes.Values);
|
||||
}
|
||||
public List<SaTaxCode> GetTaxCodesEffectiveOn(DateTime effectiveOn)
|
||||
{
|
||||
populateTaxCodes();
|
||||
return new List<SaTaxCode>(rfd.TaxCodes.Values.Where(tax => tax.IsEffectiveOn(effectiveOn)));
|
||||
}
|
||||
public SaTaxCode GetTaxCodeById(SysId taxCodeId)
|
||||
{
|
||||
if (!SysId.IsValid(taxCodeId)) return null;
|
||||
populateTaxCodes();
|
||||
return rfd.TaxCodes.GetValueOrDefault(taxCodeId);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// U n i t s O f M e a s u r e
|
||||
//-------------------------------------------------------------------
|
||||
public SaUomType GetDefaultUomType()
|
||||
{
|
||||
return SaUomType.Pack_Each;
|
||||
}
|
||||
private void populateUnitsOfMeasure()
|
||||
{
|
||||
if (rfd.UnitsOfMeasure != null) return;
|
||||
SaUnitMeasure.Params prmUnitMeasure = new SaUnitMeasure.Params();
|
||||
prmUnitMeasure.StatusCat = SaUnitMeasure.StatusCat.Any;
|
||||
rfd.UnitsOfMeasure = ReferenceDataConsole.GetUnitMeasureList(prmUnitMeasure).ToDictionary(unitMeasure => unitMeasure.Id, unitMeasure => unitMeasure);
|
||||
}
|
||||
public List<SaUnitMeasure> GetUnitsOfMeasure()
|
||||
{
|
||||
populateUnitsOfMeasure();
|
||||
return new List<SaUnitMeasure>(rfd.UnitsOfMeasure.Values);
|
||||
}
|
||||
public SaUnitMeasure GetUnitOfMeasureById(SysId unitMeasureId)
|
||||
{
|
||||
if (!SysId.IsValid(unitMeasureId)) return null;
|
||||
populateUnitsOfMeasure();
|
||||
return rfd.UnitsOfMeasure.GetValueOrDefault(unitMeasureId);
|
||||
}
|
||||
public SaUnitMeasure GetDefaultUnitOfMeasureByCategory(SaUomCategory uomCategory)
|
||||
{
|
||||
populateUnitsOfMeasure();
|
||||
return rfd.UnitsOfMeasure.Values.FirstOrDefault(item => item.Category == uomCategory && item.CategoryDefault);
|
||||
}
|
||||
public SaUomType GetUnitOfMeasureType(SysId unitMeasureId)
|
||||
{
|
||||
return GetUnitOfMeasureById(unitMeasureId)?.UnitType ?? SaUomType.Unknown;
|
||||
}
|
||||
public String GetUnitOfMeasureCode(SysId unitMeasureId)
|
||||
{
|
||||
return GetUnitOfMeasureById(unitMeasureId)?.Code ?? "";
|
||||
}
|
||||
public String GetUnitOfMeasureCaption(SysId unitMeasureId)
|
||||
{
|
||||
return GetUnitOfMeasureById(unitMeasureId)?.GetCaption() ?? "";
|
||||
}
|
||||
public List<SaUnitMeasure> GetUnitsOfMeasureByCategory(SaUomCategory uomCategory)
|
||||
{
|
||||
if (uomCategory == 0) return null;
|
||||
populateUnitsOfMeasure();
|
||||
return new List<SaUnitMeasure>(rfd.UnitsOfMeasure.Values.Where(item => item.Category == uomCategory));
|
||||
}
|
||||
public SaUnitMeasure GetUnitOfMeasureByType(SaUomType uomType)
|
||||
{
|
||||
if (uomType == 0) return null;
|
||||
populateUnitsOfMeasure();
|
||||
return rfd.UnitsOfMeasure.Values.FirstOrDefault(item => item.UnitType == uomType);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -25,7 +25,9 @@ using System.Linq;
|
||||
namespace Sarand.BusinessMgr.Net.Standard.Base.App
|
||||
{
|
||||
//=======================================================================
|
||||
public class SbmInternals : SacsDisposable, ISbmOrganisationConfig
|
||||
// Internals.
|
||||
//=======================================================================
|
||||
public partial class SbmInternals : SacsDisposable, ISbmOrganisationConfig
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Definitions.
|
||||
@@ -94,11 +96,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
|
||||
// Configurations.
|
||||
private SbmStockControlConfig stockControlConfig;
|
||||
private SbmRequirementCostingConfig requirementCostingConfig;
|
||||
// Reference data.
|
||||
private Dictionary<SysId, SaRegion> regions = null;
|
||||
private Dictionary<SysId, SaCurrency> currencies = null;
|
||||
private Dictionary<SysId, SaTaxCode> taxCodes = null;
|
||||
private Dictionary<SysId, SaUnitMeasure> unitsOfMeasure = null;
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
@@ -132,11 +129,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
|
||||
if (mgr.stockMgr != null) mgr.stockMgr.Dispose();
|
||||
if (mgr.processMgr != null) mgr.processMgr.Dispose();
|
||||
if (mgr.dataItemMgr != null) mgr.dataItemMgr.Dispose();
|
||||
// Reference data.
|
||||
if (regions != null) regions.Values.ToList().ClearAndDispose();
|
||||
if (currencies != null) currencies.Values.ToList().ClearAndDispose();
|
||||
if (taxCodes != null) taxCodes.Values.ToList().ClearAndDispose();
|
||||
if (unitsOfMeasure != null) unitsOfMeasure.Values.ToList().ClearAndDispose();
|
||||
// Consoles.
|
||||
// Database console doesn't require disposal.
|
||||
if (con.sessionConsole != null) con.sessionConsole.Dispose();
|
||||
@@ -488,153 +480,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// T a x C o d e s
|
||||
//-------------------------------------------------------------------
|
||||
private void populateRegions()
|
||||
{
|
||||
if (regions != null) return;
|
||||
SaRegion.Params prmRegion = new SaRegion.Params();
|
||||
prmRegion.StatusCat = SaRegion.StatusCat.Any;
|
||||
regions = ReferenceDataConsole.GetRegionList(prmRegion).ToDictionary(region => region.Id, region => region);
|
||||
}
|
||||
public List<SaRegion> GetRegions()
|
||||
{
|
||||
populateRegions();
|
||||
return new List<SaRegion>(regions.Values);
|
||||
}
|
||||
public SaRegion GetRegionById(SysId regionId)
|
||||
{
|
||||
if (!SysId.IsValid(regionId)) return null;
|
||||
populateRegions();
|
||||
return regions.GetValueOrDefault(regionId);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// C u r r e n c i e s
|
||||
//-------------------------------------------------------------------
|
||||
private void populateCurrencies()
|
||||
{
|
||||
if (currencies != null) return;
|
||||
SaCurrency.Params prmCurrency = new SaCurrency.Params();
|
||||
prmCurrency.StatusCat = SaCurrency.StatusCat.Any;
|
||||
currencies = ReferenceDataConsole.GetCurrencyList(prmCurrency).ToDictionary(currency => currency.Id, currency => currency);
|
||||
}
|
||||
public List<SaCurrency> GetCurrencies()
|
||||
{
|
||||
populateCurrencies();
|
||||
return new List<SaCurrency>(currencies.Values);
|
||||
}
|
||||
public SaCurrency GetCurrencyById(SysId currencyId)
|
||||
{
|
||||
if (!SysId.IsValid(currencyId)) return null;
|
||||
populateCurrencies();
|
||||
return currencies.GetValueOrDefault(currencyId);
|
||||
}
|
||||
public SaCurrency GetCurrencyByCode(String currencyCode)
|
||||
{
|
||||
if (StringUtil.IsBlank(currencyCode))
|
||||
return null;
|
||||
populateCurrencies();
|
||||
return currencies.Values.Where(item => item.Code.EqualsCI(currencyCode)).FirstOrDefault();
|
||||
}
|
||||
// Currency Decimals.
|
||||
public static byte CurrencyDecimalsDefault { get; } = 2;
|
||||
public byte GetCurrencyDecimalsForCurrencyById(SysId currencyId)
|
||||
{
|
||||
byte currencyDecimals = CurrencyDecimalsDefault;
|
||||
SaCurrency currency = GetCurrencyById(currencyId);
|
||||
if (currency != null)
|
||||
currencyDecimals = (byte)Math.Min(4, Math.Max(0, (int)currency.Decimals));
|
||||
return currencyDecimals;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// T a x C o d e s
|
||||
//-------------------------------------------------------------------
|
||||
public String GetDefaultTaxCode()
|
||||
{
|
||||
return StringUtil.OnBlank(SaReferenceDataConsole.GetReferenceDataCodes(ReferenceDataSystemCode.TaxCodeType).GetCodeForType(SaTaxCodeType.Std), $"{SaTaxCodeType.Std}");
|
||||
}
|
||||
private void populateTaxCodes()
|
||||
{
|
||||
if (taxCodes != null) return;
|
||||
SaTaxCode.Params prmTaxCode = new SaTaxCode.Params();
|
||||
prmTaxCode.StatusCat = SaTaxCode.StatusCat.Any;
|
||||
taxCodes = ReferenceDataConsole.GetTaxCodeList(prmTaxCode).ToDictionary(taxCode => taxCode.Id, taxCode => taxCode);
|
||||
}
|
||||
public List<SaTaxCode> GetTaxCodes()
|
||||
{
|
||||
populateTaxCodes();
|
||||
return new List<SaTaxCode>(taxCodes.Values);
|
||||
}
|
||||
public List<SaTaxCode> GetTaxCodesEffectiveOn(DateTime effectiveOn)
|
||||
{
|
||||
populateTaxCodes();
|
||||
return new List<SaTaxCode>(taxCodes.Values.Where(tax => tax.IsEffectiveOn(effectiveOn)));
|
||||
}
|
||||
public SaTaxCode GetTaxCodeById(SysId taxCodeId)
|
||||
{
|
||||
if (!SysId.IsValid(taxCodeId)) return null;
|
||||
populateTaxCodes();
|
||||
return taxCodes.GetValueOrDefault(taxCodeId);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// U n i t s O f M e a s u r e
|
||||
//-------------------------------------------------------------------
|
||||
public SaUomType GetDefaultUomType()
|
||||
{
|
||||
return SaUomType.Pack_Each;
|
||||
}
|
||||
private void populateUnitsOfMeasure()
|
||||
{
|
||||
if (unitsOfMeasure != null) return;
|
||||
SaUnitMeasure.Params prmUnitMeasure = new SaUnitMeasure.Params();
|
||||
prmUnitMeasure.StatusCat = SaUnitMeasure.StatusCat.Any;
|
||||
unitsOfMeasure = ReferenceDataConsole.GetUnitMeasureList(prmUnitMeasure).ToDictionary(unitMeasure => unitMeasure.Id, unitMeasure => unitMeasure);
|
||||
}
|
||||
public List<SaUnitMeasure> GetUnitsOfMeasure()
|
||||
{
|
||||
populateUnitsOfMeasure();
|
||||
return new List<SaUnitMeasure>(unitsOfMeasure.Values);
|
||||
}
|
||||
public SaUnitMeasure GetUnitOfMeasureById(SysId unitMeasureId)
|
||||
{
|
||||
if (!SysId.IsValid(unitMeasureId)) return null;
|
||||
populateUnitsOfMeasure();
|
||||
return unitsOfMeasure.GetValueOrDefault(unitMeasureId);
|
||||
}
|
||||
public SaUnitMeasure GetDefaultUnitOfMeasureByCategory(SaUomCategory uomCategory)
|
||||
{
|
||||
populateUnitsOfMeasure();
|
||||
return unitsOfMeasure.Values.FirstOrDefault(item => item.Category == uomCategory && item.CategoryDefault);
|
||||
}
|
||||
public SaUomType GetUnitOfMeasureType(SysId unitMeasureId)
|
||||
{
|
||||
return GetUnitOfMeasureById(unitMeasureId)?.UnitType ?? SaUomType.Unknown;
|
||||
}
|
||||
public String GetUnitOfMeasureCode(SysId unitMeasureId)
|
||||
{
|
||||
return GetUnitOfMeasureById(unitMeasureId)?.Code ?? "";
|
||||
}
|
||||
public String GetUnitOfMeasureCaption(SysId unitMeasureId)
|
||||
{
|
||||
return GetUnitOfMeasureById(unitMeasureId)?.GetCaption() ?? "";
|
||||
}
|
||||
public List<SaUnitMeasure> GetUnitsOfMeasureByCategory(SaUomCategory uomCategory)
|
||||
{
|
||||
if (uomCategory == 0) return null;
|
||||
populateUnitsOfMeasure();
|
||||
return new List<SaUnitMeasure>(unitsOfMeasure.Values.Where(item => item.Category == uomCategory));
|
||||
}
|
||||
public SaUnitMeasure GetUnitOfMeasureByType(SaUomCategory uomCategory, SaUomType uomType)
|
||||
{
|
||||
if (uomCategory == 0 || uomType == 0) return null;
|
||||
populateUnitsOfMeasure();
|
||||
return unitsOfMeasure.Values.Where(item => item.Category == uomCategory && item.UnitType == uomType).FirstOrDefault();
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Organisation configuration.
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
@@ -1131,6 +1131,11 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
|
||||
return new SbmItemId(Sbm.ItemType.Commodity, Id);
|
||||
}
|
||||
|
||||
public String GetCaption()
|
||||
{
|
||||
return StringUtil.TrimWhitespace($"{Code} - {DescBrief}");
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
public Data GetData() { return data.Clone(); }
|
||||
|
||||
@@ -91,30 +91,30 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Consoles
|
||||
|
||||
// Transaction types cannot be created locally if they are either imported from or exported to Sage.
|
||||
// In the case of exports, it is the 'proforma' equivalent that can be created for export.
|
||||
createTransaction_PurchaseOrder = true;
|
||||
createTransaction_SalesQuote = true;
|
||||
createTransaction_SalesOrder = true;
|
||||
createTrans_SalesInvoice = true;
|
||||
if (createTransaction_PurchaseOrder) createTransaction_PurchaseOrder = !dfnSageInt.importPurchaseOrder && !dfnSageInt.exportPurchaseOrder;
|
||||
if (createTransaction_SalesOrder) createTransaction_SalesOrder = !dfnSageInt.importSalesOrder && !dfnSageInt.exportSalesOrder;
|
||||
if (createTrans_SalesInvoice) createTrans_SalesInvoice = !dfnSageInt.importProductInvoice && !dfnSageInt.exportProductInvoice && !dfnSageInt.importServiceInvoice && !dfnSageInt.exportServiceInvoice && !dfnSageInt.importSalesOrderInvoice && !dfnSageInt.bexport_SalesOrderInvoice;
|
||||
if (createTransaction_PurchaseOrder) createTransaction_PurchaseOrder = !dfnQBooksInt.importPurchaseOrder && !dfnQBooksInt.exportPurchaseOrder;
|
||||
if (createTransaction_SalesOrder) createTransaction_SalesOrder = !dfnQBooksInt.importSalesOrder && !dfnQBooksInt.exportSalesOrder;
|
||||
if (createTrans_SalesInvoice) createTrans_SalesInvoice = !dfnQBooksInt.importProductInvoice && !dfnQBooksInt.exportProductInvoice && !dfnQBooksInt.importServiceInvoice && !dfnQBooksInt.exportServiceInvoice && !dfnQBooksInt.importSalesOrderInvoice && !dfnQBooksInt.bexport_SalesOrderInvoice;
|
||||
mbr.CreateTransaction_PurchaseOrder = true;
|
||||
mbr.CreateTransaction_SalesQuote = true;
|
||||
mbr.CreateTransaction_SalesOrder = true;
|
||||
mbr.CreateTransaction_SalesInvoice = true;
|
||||
if (mbr.CreateTransaction_PurchaseOrder) mbr.CreateTransaction_PurchaseOrder = !dfnSageInt.importPurchaseOrder && !dfnSageInt.exportPurchaseOrder;
|
||||
if (mbr.CreateTransaction_SalesOrder) mbr.CreateTransaction_SalesOrder = !dfnSageInt.importSalesOrder && !dfnSageInt.exportSalesOrder;
|
||||
if (mbr.CreateTransaction_SalesInvoice) mbr.CreateTransaction_SalesInvoice = !dfnSageInt.importProductInvoice && !dfnSageInt.exportProductInvoice && !dfnSageInt.importServiceInvoice && !dfnSageInt.exportServiceInvoice && !dfnSageInt.importSalesOrderInvoice && !dfnSageInt.bexport_SalesOrderInvoice;
|
||||
if (mbr.CreateTransaction_PurchaseOrder) mbr.CreateTransaction_PurchaseOrder = !dfnQBooksInt.importPurchaseOrder && !dfnQBooksInt.exportPurchaseOrder;
|
||||
if (mbr.CreateTransaction_SalesOrder) mbr.CreateTransaction_SalesOrder = !dfnQBooksInt.importSalesOrder && !dfnQBooksInt.exportSalesOrder;
|
||||
if (mbr.CreateTransaction_SalesInvoice) mbr.CreateTransaction_SalesInvoice = !dfnQBooksInt.importProductInvoice && !dfnQBooksInt.exportProductInvoice && !dfnQBooksInt.importServiceInvoice && !dfnQBooksInt.exportServiceInvoice && !dfnQBooksInt.importSalesOrderInvoice && !dfnQBooksInt.bexport_SalesOrderInvoice;
|
||||
|
||||
// Sales quotes are also imported from Sage Sales Orders.
|
||||
createTransaction_SalesQuote = createTransaction_SalesOrder;
|
||||
mbr.CreateTransaction_SalesQuote = mbr.CreateTransaction_SalesOrder;
|
||||
}
|
||||
switch (type)
|
||||
{
|
||||
case Sbm.TransactionType.SalesQuote:
|
||||
return createTransaction_SalesQuote;
|
||||
return mbr.CreateTransaction_SalesQuote;
|
||||
case Sbm.TransactionType.SalesOrder:
|
||||
return createTransaction_SalesOrder;
|
||||
return mbr.CreateTransaction_SalesOrder;
|
||||
case Sbm.TransactionType.SalesInvoice:
|
||||
return createTrans_SalesInvoice;
|
||||
return mbr.CreateTransaction_SalesInvoice;
|
||||
case Sbm.TransactionType.PurchaseOrder:
|
||||
return createTransaction_PurchaseOrder;
|
||||
return mbr.CreateTransaction_PurchaseOrder;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -337,8 +337,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Consoles
|
||||
{
|
||||
// Build the list of transaction types that are allowed to be raised from the specified type.
|
||||
List<TypeCodeDesc> transTypes = new List<TypeCodeDesc>();
|
||||
if (transactionTypes_Full.Count == 0) transactionTypes_Full = Internals.GetSystemCodes(Sbm.SystemCode.TransactionType);
|
||||
foreach (TypeCodeDesc transTypeTo in transactionTypes_Full)
|
||||
if (mbr.TransactionTypes_Full == null) mbr.TransactionTypes_Full = Internals.GetSystemCodes(Sbm.SystemCode.TransactionType);
|
||||
foreach (TypeCodeDesc transTypeTo in mbr.TransactionTypes_Full)
|
||||
{
|
||||
//if ((Sbm.TransactionType)typeTo.iType == typeFrom) continue;
|
||||
if (CanRaiseTransaction(typeFrom, (Sbm.TransactionType)transTypeTo.Type))
|
||||
@@ -352,9 +352,9 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Consoles
|
||||
{
|
||||
// Build the list of transaction types that are allowed to be raised to the specified type.
|
||||
List<TypeCodeDesc> transTypes = new List<TypeCodeDesc>();
|
||||
if (transactionTypes_Full.Count == 0) transactionTypes_Full = Internals.GetSystemCodes(Sbm.SystemCode.TransactionType);
|
||||
if (mbr.TransactionTypes_Full.Count == 0) mbr.TransactionTypes_Full = Internals.GetSystemCodes(Sbm.SystemCode.TransactionType);
|
||||
//transTypes_Full.GotoStart();
|
||||
foreach (TypeCodeDesc transTypeTo in transactionTypes_Full)
|
||||
foreach (TypeCodeDesc transTypeTo in mbr.TransactionTypes_Full)
|
||||
{
|
||||
//TypeCodeDesc & typeTo = transTypes_Full.Index();
|
||||
if ((Sbm.TransactionType)transTypeTo.Type == typeTo) continue;
|
||||
|
||||
@@ -78,15 +78,14 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Consoles
|
||||
this.InternalsSupplied = internalsSupplied;
|
||||
}
|
||||
public SbmInternals InternalsSupplied { get; }
|
||||
public SbmInstanceConfig InstanceConfig { get; set; }
|
||||
public SbmOrganisationConfig OrganisationConfig { get; set; }
|
||||
public List<TypeCodeDesc> TransactionTypes_Full { get;set; }
|
||||
public bool CreateTransaction_PurchaseOrder, CreateTransaction_SalesQuote, CreateTransaction_SalesOrder, CreateTransaction_SalesInvoice;
|
||||
}
|
||||
private DataMembers mbr { get; }
|
||||
private List<TypeCodeDesc> transactionTypes_Full = new List<TypeCodeDesc>();
|
||||
private SbmInstanceConfig instanceConfig;
|
||||
private SbmOrganisationConfig organisationConfig;
|
||||
private AccountsInterfaceDfn dfnSageInt = new AccountsInterfaceDfn();
|
||||
private AccountsInterfaceDfn dfnQBooksInt = new AccountsInterfaceDfn();
|
||||
private bool createTransaction_PurchaseOrder, createTransaction_SalesQuote, createTransaction_SalesOrder, createTrans_SalesInvoice;
|
||||
private bool productionControl;
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
@@ -112,8 +111,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Consoles
|
||||
private SbmInternals Internals { get { return mbr.InternalsSupplied; } }
|
||||
public ISbmUserOrganisationContext UserContext { get { return Internals.UserContext; } }
|
||||
public SbmSessionContext SessionContext { get { return Internals.SessionContext; } }
|
||||
public SbmInstanceConfig InstanceConfig { get { if (instanceConfig == null) { instanceConfig = SbmGlobals.Application.GetInstanceConfig(SessionContext); } return instanceConfig; } }
|
||||
public SbmOrganisationConfig OrganisationConfig { get { if (organisationConfig == null) { organisationConfig = SbmGlobals.Application.GetOrganisationConfig(UserContext); } return organisationConfig; } }
|
||||
public SbmInstanceConfig InstanceConfig { get { if (mbr.InstanceConfig == null) { mbr.InstanceConfig = SbmGlobals.Application.GetInstanceConfig(SessionContext); } return mbr.InstanceConfig; } }
|
||||
public SbmOrganisationConfig OrganisationConfig { get { if (mbr.OrganisationConfig == null) { mbr.OrganisationConfig = SbmGlobals.Application.GetOrganisationConfig(UserContext); } return mbr.OrganisationConfig; } }
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// C r e a t e C o n s o l e
|
||||
@@ -326,7 +325,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Consoles
|
||||
// Update Log.
|
||||
public virtual bool IsColumnChangeLogged(SbmDbDfn.ColumnIdx column)
|
||||
{
|
||||
return instanceConfig.IsColumnChangeLogged(column, false);
|
||||
return InstanceConfig.IsColumnChangeLogged(column, false);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
@@ -0,0 +1,127 @@
|
||||
using Org.BouncyCastle.Asn1.Ocsp;
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.App;
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.Bus;
|
||||
using Sarand.Net.Standard.Base.App;
|
||||
using Sarand.Net.Standard.Base.Bus;
|
||||
using Sarand.Net.Standard.Base.ReferenceData;
|
||||
using Sarand.Net.Standard.Base.Utils;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Sarand.BusinessMgr.Net.Standard.Base.Helpers
|
||||
{
|
||||
//=======================================================================
|
||||
public static class SbmRequirementHelper
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Utilities.
|
||||
public static decimal Round(decimal? value, ushort decimals)
|
||||
{
|
||||
return Decimal.Round((decimal)value, decimals, MidpointRounding.AwayFromZero);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Calculate Requirement amounts.
|
||||
public class CalculateRequest
|
||||
{
|
||||
public CalculateRequest(SbmInternals internals) { this.Internals = internals; }
|
||||
public SbmInternals Internals { get; }
|
||||
public SysId TransactionId { get; set; }
|
||||
public Sbm.TransactionType TransactionType { get; set; }
|
||||
public SysId CommodityId { get; set; }
|
||||
public SysId CurrencyId { get; set; }
|
||||
public String TaxCode { get; set; }
|
||||
public DateTime TaxEffective { get; set; } = DateTime.Today;
|
||||
public decimal AmountUnit { get; set; }
|
||||
public decimal Quantity { get; set; }
|
||||
public decimal PercentDiscount { get; set; }
|
||||
public decimal AmountDiscount { get; set; }
|
||||
}
|
||||
public class CalculateRespose
|
||||
{
|
||||
public decimal? AmountUnit { get; set; }
|
||||
public decimal? Quantity { get; set; }
|
||||
public decimal? AmountAct { get; set; }
|
||||
public decimal? PercentDisc { get; set; }
|
||||
public decimal? AmountDisc { get; set; }
|
||||
public decimal? AmountNet { get; set; }
|
||||
public decimal? RateTax { get; set; }
|
||||
public decimal? AmountTax { get; set; }
|
||||
public decimal? AmountTot { get; set; }
|
||||
public bool Success { get; set; }
|
||||
}
|
||||
public static CalculateRespose Calculate(CalculateRequest request)
|
||||
{
|
||||
CalculateRespose response = new CalculateRespose();
|
||||
|
||||
// Transaction.
|
||||
// Currently only retrieved if Transaction type not specified.
|
||||
if (request.TransactionType == 0)
|
||||
{
|
||||
SysId transactionId = request.TransactionId;
|
||||
SbmTransaction transaction = request.Internals.TransactionMgr.GetTransactionById(transactionId);
|
||||
if (transaction == null && SysId.IsValid(transactionId))
|
||||
{
|
||||
SaLogger.Warn($"{SysUtil.Fn} Failed to retrieve Transaction. Id: {transactionId}");
|
||||
return response;
|
||||
}
|
||||
if (transaction != null) request.TransactionType = transaction.TransactionType;
|
||||
if (request.TransactionType <= 0)
|
||||
{
|
||||
SaLogger.Warn($"{SysUtil.Fn} Transaction type not specified.");
|
||||
return response;
|
||||
}
|
||||
}
|
||||
|
||||
// Commodity. [not required as yet]
|
||||
bool retrieveCommodity = false;
|
||||
if (retrieveCommodity)
|
||||
{
|
||||
SysId commodityId = request.CommodityId;
|
||||
SbmCommodity commodity = request.Internals.CommodityMgr.GetCommodityById(commodityId);
|
||||
if (commodity == null && SysId.IsValid(commodityId))
|
||||
{
|
||||
SaLogger.Warn($"{SysUtil.Fn} Failed to retrieve Commodity. Id: {commodityId}");
|
||||
return response;
|
||||
}
|
||||
}
|
||||
|
||||
// Currency.
|
||||
ushort currencyDecimals = request.Internals.GetCurrencyDecimalsById(request.CurrencyId);
|
||||
|
||||
// Unit amount.
|
||||
// NB Use the supplied amount rather than reverting to the Commodity price as the Unit Amount may have been manually modified.
|
||||
response.AmountUnit = Round(request.AmountUnit, currencyDecimals);
|
||||
|
||||
// Actual amount.
|
||||
response.Quantity = request.Quantity;
|
||||
response.AmountAct = Round(response.AmountUnit * response.Quantity, currencyDecimals);
|
||||
|
||||
// Discount.
|
||||
response.AmountDisc = request.AmountDiscount;
|
||||
if (Math.Abs((decimal)response.AmountDisc) < 0.01m && Math.Abs(request.PercentDiscount) > 0.01m && Math.Abs(request.PercentDiscount) < 100.0m)
|
||||
response.AmountDisc = response.AmountAct * request.PercentDiscount / 100.0m;
|
||||
response.AmountDisc = Round(response.AmountDisc * response.Quantity, currencyDecimals);
|
||||
|
||||
// Net amount.
|
||||
response.AmountNet = Round(response.AmountAct - response.AmountDisc, currencyDecimals);
|
||||
|
||||
// Tax.
|
||||
SaTaxCode taxCode = request.Internals.GetTaxCodesEffectiveOn(request.TaxEffective).FirstOrDefault(tax => tax.Code.EqualsCI(request.TaxCode));
|
||||
response.RateTax = taxCode?.TaxRate ?? 0.0m;
|
||||
response.AmountTax = Round(response.AmountNet * response.RateTax / 100.0m, currencyDecimals);
|
||||
|
||||
// Total amount.
|
||||
response.AmountTot = Round(response.AmountNet + response.AmountTax, currencyDecimals);
|
||||
|
||||
response.Success = true;
|
||||
return response;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Sarand.BusinessMgr.Net.Standard.Base.Helpers
|
||||
{
|
||||
//=======================================================================
|
||||
public static class SbmTransactionHelper
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -239,10 +239,10 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr
|
||||
{
|
||||
return Internals.GetCurrencyByCode(currencyCode);
|
||||
}
|
||||
protected static byte CurrencyDecimalsDefault { get { return SbmInternals.CurrencyDecimalsDefault; } }
|
||||
protected byte GetCurrencyDecimalsForCurrencyById(SysId currencyId)
|
||||
protected static ushort CurrencyDecimalsDefault { get { return SbmInternals.CurrencyDecimalsDefault; } }
|
||||
protected ushort GetCurrencyDecimalsForCurrencyById(SysId currencyId)
|
||||
{
|
||||
return Internals.GetCurrencyDecimalsForCurrencyById(currencyId);
|
||||
return Internals.GetCurrencyDecimalsById(currencyId);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
@@ -9,6 +9,7 @@ using Sarand.Net.Standard.Base.ReferenceData;
|
||||
using Sarand.Net.Standard.Base.Utils;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using static Sarand.BusinessMgr.Net.Standard.Base.App.Sbm;
|
||||
|
||||
namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr
|
||||
{
|
||||
@@ -28,22 +29,27 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr
|
||||
// Transaction properties.
|
||||
public abstract Sbm.TransactionType GetTransactionType(SysId transactionId);
|
||||
|
||||
public DateTime GetTransactionTaxEffectiveDate(SbmTransaction transaction)
|
||||
// Tax Effective date.
|
||||
public DateTime GetTransactionTaxEffectiveDate(Sbm.TransactionType transactionType, SaStatus status, DateTime raised, DateTime inProgress)
|
||||
{
|
||||
// Original thinking was that the status would have an effect on the tax point.
|
||||
SbmTransaction.StatusCat transactionStatusCat = SbmTransaction.GetCategoryForStatus(transaction.Status);
|
||||
SbmTransaction.StatusCat transactionStatusCat = SbmTransaction.GetCategoryForStatus(status);
|
||||
|
||||
// Nov-08 Current thinking is that the only differences is whether the 'In Progress' date has been specified and whether that should be used in preference to the 'Raised' date.
|
||||
if (DateUtil.IsValid(transaction.InProgress) && (transactionStatusCat == SbmTransaction.StatusCat.Open || transactionStatusCat == SbmTransaction.StatusCat.Closed))
|
||||
if (DateUtil.IsValid(inProgress) && (transactionStatusCat == SbmTransaction.StatusCat.Open || transactionStatusCat == SbmTransaction.StatusCat.Closed))
|
||||
{
|
||||
if (SessionConsole.UseInProgressTaxDateAsTaxPoint(transaction.TransactionType))
|
||||
return transaction.InProgress;
|
||||
if (SessionConsole.UseInProgressTaxDateAsTaxPoint(transactionType))
|
||||
return inProgress;
|
||||
}
|
||||
// Otherwise, use 'Raised' date.
|
||||
if (DateUtil.IsValid(transaction.Raised))
|
||||
return transaction.Raised;
|
||||
if (DateUtil.IsValid(raised))
|
||||
return raised;
|
||||
return DateTime.Today;
|
||||
}
|
||||
public DateTime GetTransactionTaxEffectiveDate(SbmTransaction transaction)
|
||||
{
|
||||
return GetTransactionTaxEffectiveDate(transaction.TransactionType, transaction.Status, transaction.Raised, transaction.InProgress);
|
||||
}
|
||||
|
||||
// Labour cost.
|
||||
public abstract decimal GetTransCostLabourRateHourDefault();
|
||||
|
||||
@@ -95,10 +95,10 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Procs
|
||||
{
|
||||
return Internals.GetCurrencyByCode(currencyCode);
|
||||
}
|
||||
protected static byte CurrencyDecimalsDefault { get { return SbmInternals.CurrencyDecimalsDefault; } }
|
||||
protected byte GetCurrencyDecimalsForCurrencyById(SysId currencyId)
|
||||
protected static ushort CurrencyDecimalsDefault { get { return SbmInternals.CurrencyDecimalsDefault; } }
|
||||
protected ushort GetCurrencyDecimalsForCurrencyById(SysId currencyId)
|
||||
{
|
||||
return Internals.GetCurrencyDecimalsForCurrencyById(currencyId);
|
||||
return Internals.GetCurrencyDecimalsById(currencyId);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user