Session Console and Internals.

This commit is contained in:
Andy Howard
2025-01-16 13:19:58 +00:00
parent ee988b1f76
commit 61ecd59794
187 changed files with 4681 additions and 3647 deletions
@@ -43,7 +43,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Consoles
/// Replace dynamic tags in email message body.
/// <para></para>
/// </summary>
public void ReplaceDynamicEmailBodyTags(SaEmailData emailData, ISbmUserContext_Core userContext)
public void ReplaceDynamicEmailBodyTags(SaEmailData emailData, ISbmUserOrganisationContext userContext)
{
// Replace core tags, eg. main stylesheet.
SaEmailConsole.ReplaceDynamicEmailTags(emailData);
@@ -0,0 +1,415 @@
using Sarand.BusinessMgr.Net.Standard.Base.App;
using Sarand.BusinessMgr.Net.Standard.Base.Bus;
using Sarand.Net.Standard.Accounts.QuickBooks.App;
using Sarand.Net.Standard.Accounts.Sage.App;
using Sarand.Net.Standard.Base.Bus;
using Sarand.Net.Standard.Base.Core;
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.Consoles
{
//=======================================================================
/// <summary>
/// Session Console - Transaction processing options/rules.
/// </summary>
partial class SbmSessionConsole
{
//-------------------------------------------------------------------
// Supported Transaction types.
public virtual bool AllowTransactionType(Sbm.TransactionType type)
{
switch (type)
{
// Transaction types that are allowed.
case Sbm.TransactionType.SalesQuote:
case Sbm.TransactionType.SalesOrder:
//case Sbm.TransactionType.PurchaseOrder:
return InstanceConfig.AllowTransactionType(type, true);
// Proforma types are only allowed if ther counterparts cannot be created.
case Sbm.TransactionType.ProformaPurchaseOrder:
return InstanceConfig.AllowTransactionType(type, AllowTransactionType(Sbm.TransactionType.PurchaseOrder) && !CanCreateTransactionLocally(Sbm.TransactionType.PurchaseOrder));
case Sbm.TransactionType.ProformaSalesOrder:
return InstanceConfig.AllowTransactionType(type, AllowTransactionType(Sbm.TransactionType.SalesOrder) && !CanCreateTransactionLocally(Sbm.TransactionType.SalesOrder));
case Sbm.TransactionType.ProformaSalesInvoice:
return InstanceConfig.AllowTransactionType(type, AllowTransactionType(Sbm.TransactionType.SalesInvoice) && !CanCreateTransactionLocally(Sbm.TransactionType.SalesInvoice));
}
return false;
}
//-------------------------------------------------------------------
// Create Transaction.
public virtual bool CanCreateTransactionLocally(Sbm.TransactionType type)
{
if (!AllowTransactionType(type)) return false;
// Refresh options.
if (dfnSageInt.AffiliateId_Owner != UserContext.OrganisationAffiliateId || dfnQBooksInt.AffiliateId_Owner != UserContext.OrganisationAffiliateId)
{
// Reset the accounts interface configurations.
dfnSageInt.ClearConfig();
dfnSageInt.AffiliateId_Owner = UserContext.OrganisationAffiliateId;
dfnQBooksInt.ClearConfig();
dfnQBooksInt.AffiliateId_Owner = UserContext.OrganisationAffiliateId;
// Identify the interfaces.
dfnSageInt.InterfaceId = Internals.AccountsDfn.GetAccountInterfaceId(Sbm.InterfaceType_Accounts.SageLine50);
dfnQBooksInt.InterfaceId = Internals.AccountsDfn.GetAccountInterfaceId(Sbm.InterfaceType_Accounts.QuickBooks);
// Sales and purchase orders/invoices can only be created locally if they are not imported from one of these interfaces.
if (SysId.IsValid(dfnSageInt.InterfaceId))
{
// Interpret interface options.
dfnSageInt.importPurchaseOrder = Internals.AccountsDfn.GetSageImportOption(Sage.ItemType.PurchaseOrder);
dfnSageInt.importSalesOrder = Internals.AccountsDfn.GetSageImportOption(Sage.ItemType.SalesOrder);
dfnSageInt.importProductInvoice = Internals.AccountsDfn.GetSageImportOption(Sage.ItemType.Invoice_Product);
dfnSageInt.importServiceInvoice = Internals.AccountsDfn.GetSageImportOption(Sage.ItemType.Invoice_Service);
dfnSageInt.importSalesOrderInvoice = Internals.AccountsDfn.GetSageImportOption(Sage.ItemType.Invoice_SalesOrder);
dfnSageInt.exportPurchaseOrder = Internals.AccountsDfn.GetSageExportOption(Sage.ItemType.PurchaseOrder);
dfnSageInt.exportSalesOrder = Internals.AccountsDfn.GetSageExportOption(Sage.ItemType.SalesOrder);
dfnSageInt.exportProductInvoice = Internals.AccountsDfn.GetSageExportOption(Sage.ItemType.Invoice_Product);
dfnSageInt.exportServiceInvoice = Internals.AccountsDfn.GetSageExportOption(Sage.ItemType.Invoice_Service);
dfnSageInt.exportSalesOrder = Internals.AccountsDfn.GetSageExportOption(Sage.ItemType.Invoice_SalesOrder);
}
if (SysId.IsValid(dfnQBooksInt.InterfaceId))
{
// Interpret interface options.
dfnQBooksInt.importPurchaseOrder = Internals.AccountsDfn.GetQuickBooksImportOption(Qbk.EntityType.PurchaseOrder);
dfnQBooksInt.importSalesOrder = Internals.AccountsDfn.GetQuickBooksImportOption(Qbk.EntityType.SalesOrder);
dfnQBooksInt.importProductInvoice = Internals.AccountsDfn.GetQuickBooksImportOption(Qbk.EntityType.Invoice_Product);
dfnQBooksInt.importServiceInvoice = Internals.AccountsDfn.GetQuickBooksImportOption(Qbk.EntityType.Invoice_Service);
dfnQBooksInt.importSalesOrderInvoice = false;
dfnQBooksInt.exportPurchaseOrder = Internals.AccountsDfn.GetQuickBooksExportOption(Qbk.EntityType.PurchaseOrder);
dfnQBooksInt.exportSalesOrder = Internals.AccountsDfn.GetQuickBooksExportOption(Qbk.EntityType.SalesOrder);
dfnQBooksInt.exportProductInvoice = Internals.AccountsDfn.GetQuickBooksExportOption(Qbk.EntityType.Invoice_Product);
dfnQBooksInt.exportServiceInvoice = Internals.AccountsDfn.GetQuickBooksExportOption(Qbk.EntityType.Invoice_Service);
dfnQBooksInt.bexport_SalesOrderInvoice = false;
}
// 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;
// Sales quotes are also imported from Sage Sales Orders.
createTransaction_SalesQuote = createTransaction_SalesOrder;
}
switch (type)
{
case Sbm.TransactionType.SalesQuote:
return createTransaction_SalesQuote;
case Sbm.TransactionType.SalesOrder:
return createTransaction_SalesOrder;
case Sbm.TransactionType.SalesInvoice:
return createTrans_SalesInvoice;
case Sbm.TransactionType.PurchaseOrder:
return createTransaction_PurchaseOrder;
}
return true;
}
//-------------------------------------------------------------------
// Transaction Creation options.
public enum AssignTransRefMethod
{
System, Manual, Option
}
public virtual AssignTransRefMethod TransactionAssignRefMethod(Sbm.TransactionType transTypes)
{
return AssignTransRefMethod.System;
}
public enum AssignTransRefSource
{
ByOwnerType, ByType
}
public virtual AssignTransRefSource TransactionAssignRefSource(Sbm.TransactionType transTypes)
{
return AssignTransRefSource.ByOwnerType;
}
// By default all types of transaction have their own Id sequence.
// Override this method to allow different types of transaction to share Id sequence.
public virtual Sbm.TransactionType GetTransactionTypeForNextId(Sbm.TransactionType transTypes)
{
return transTypes;
}
// NextId key value.
public virtual string GetTransactionNextIdKey(SysId AffiliateId_Owner, SysId idAssoc, Sbm.TransactionType eType)
{
idAssoc = new SysId();
Sbm.TransactionType transTypes = GetTransactionTypeForNextId(eType);
switch (TransactionAssignRefSource(eType))
{
case AssignTransRefSource.ByOwnerType:
// Next Id depends on both the transaction type and owner.
return "TransRef:" + transTypes.ToString() + ":" + AffiliateId_Owner.ToString();
default:
// Next Id only depends on the transaction type.
return "TransRef:" + transTypes.ToString();
}
}
// Set the minimum Id for transactions of the specified type.
public virtual bool SetMinTransactionId(SysId AffiliateId_Owner, SysId idAssoc, Sbm.TransactionType transTypes, long iId)
{
bool set = false;
if (SbmGlobals.Application.GetBusMgrDatabase(SessionContext) != null)
{
string nextIdKey = GetTransactionNextIdKey(AffiliateId_Owner, idAssoc, transTypes);
// ToDo set = SbmGlobals.Database.SetMinNextId(nextIdKey, iId, false);
}
return set;
}
// The implementation in this class will generate simple numeric values for the owner
// and global options that can be formatted (eg. to fixed length) by overwridden versions.
public virtual string GetTransactionCreateRef
(SysId AffiliateId_Owner, SysId idAssoc, Sbm.TransactionType transTypes)
{
string Ref = "";
if (SbmGlobals.Application.GetBusMgrDatabase(SessionContext) != null)
{
string NextIdKey = GetTransactionNextIdKey(AffiliateId_Owner, idAssoc, transTypes);
// ToDo long iRefNext = SbmGlobals.Database.GetNextId(NextIdKey, false);
// Ref = FormatTransactionCreateRef(AffiliateId_Owner, idAssoc, transTypes, iRefNext);
}
return Ref;
}
public virtual string FormatTransactionCreateRef
(SysId AffiliateId_Owner, SysId idAssoc, Sbm.TransactionType transTypes, long RefInt)
{
string Ref = "";
if (RefInt > 0)
{
// Retrieve and validate the sequence padding length.
int SeqLen = Math.Max(1, Math.Min(8, GetTransactionRefSeqLength(AffiliateId_Owner, idAssoc, transTypes)));
// Pad the sequence number.
//Ref = String(RefInt, SeqLen);
// Add the reference prefix (max 5 chars)
string prefix = GetTransactionRefPrefix(AffiliateId_Owner, idAssoc, transTypes);
Ref = prefix.Left(5) + Ref;
}
return Ref;
}
public virtual int GetTransactionRefSeqLength(SysId AffiliateId_Owner, SysId idAssoc, Sbm.TransactionType transTypes)
{
return 5;
}
//-------------------------------------------------------------------
/// <summary>Transaction reference prefix by type</summary>
public virtual string GetTransactionRefPrefix(SysId id, SysId idAssoc, Sbm.TransactionType transactionType)
{
return "";
}
//-------------------------------------------------------------------
// Raise Transaction.
public virtual bool CanRaiseTransaction(Sbm.TransactionType typeFrom, Sbm.TransactionType typeTo)
{
if (!AllowTransactionType(typeFrom) || !AllowTransactionType(typeTo)) return false;
if (!CanCreateTransactionLocally(typeTo)) return false;
if (typeFrom == Sbm.TransactionType.Project)
{
// Can raise another project from a project.
switch (typeTo)
{
case Sbm.TransactionType.Project:
return CanCreateTransactionLocally(typeTo);
}
}
else if (typeFrom == Sbm.TransactionType.SalesLead)
{
// Can raise sales quote or order from a lead.
switch (typeTo)
{
case Sbm.TransactionType.SalesQuote:
case Sbm.TransactionType.ProformaSalesOrder:
case Sbm.TransactionType.SalesOrder:
return CanCreateTransactionLocally(typeTo);
}
}
else if (typeFrom == Sbm.TransactionType.SalesQuote)
{
// Can raise sales lead or order from a sales quote.
switch (typeTo)
{
case Sbm.TransactionType.SalesLead:
case Sbm.TransactionType.SalesQuote:
case Sbm.TransactionType.ProformaSalesOrder:
case Sbm.TransactionType.SalesOrder:
case Sbm.TransactionType.ProformaSalesInvoice:
case Sbm.TransactionType.SalesInvoice:
return CanCreateTransactionLocally(typeTo);
}
}
else if (typeFrom == Sbm.TransactionType.SalesOrder || typeFrom == Sbm.TransactionType.ProformaSalesOrder)
{
// Can raise almost anything from a sales order.
switch (typeTo)
{
case Sbm.TransactionType.SalesLead:
case Sbm.TransactionType.SalesQuote:
case Sbm.TransactionType.ProformaSalesOrder:
case Sbm.TransactionType.SalesOrder:
case Sbm.TransactionType.SalesDispatch:
case Sbm.TransactionType.ProformaSalesInvoice:
case Sbm.TransactionType.SalesInvoice:
// Can also raise purchase quote or order from sales order:
case Sbm.TransactionType.PurchaseQuote:
case Sbm.TransactionType.ProformaPurchaseOrder:
case Sbm.TransactionType.PurchaseOrder:
return CanCreateTransactionLocally(typeTo);
}
}
else if (typeFrom == Sbm.TransactionType.SalesDispatch)
{
// Can raise a sales invoice from a dispatch note.
switch (typeTo)
{
case Sbm.TransactionType.ProformaSalesInvoice:
case Sbm.TransactionType.SalesInvoice:
return CanCreateTransactionLocally(typeTo);
}
}
else if (typeFrom == Sbm.TransactionType.PurchaseQuote)
{
// Can raise a purchase order from purchase quote.
switch (typeTo)
{
case Sbm.TransactionType.PurchaseQuote:
case Sbm.TransactionType.ProformaPurchaseOrder:
case Sbm.TransactionType.PurchaseOrder:
return CanCreateTransactionLocally(typeTo);
}
}
else if (typeFrom == Sbm.TransactionType.PurchaseOrder || typeFrom == Sbm.TransactionType.ProformaPurchaseOrder)
{
// Can raise a sales order or purchase quote from a purchase order.
switch (typeTo)
{
case Sbm.TransactionType.SalesQuote:
case Sbm.TransactionType.ProformaSalesOrder:
case Sbm.TransactionType.SalesOrder:
case Sbm.TransactionType.PurchaseQuote:
case Sbm.TransactionType.ProformaPurchaseOrder:
case Sbm.TransactionType.PurchaseOrder:
return CanCreateTransactionLocally(typeTo);
}
}
return false;
}
//-------------------------------------------------------------------
public virtual List<TypeCodeDesc> GetTransactionTypesForRaiseFrom(Sbm.TransactionType typeFrom)
{
// 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 ((Sbm.TransactionType)typeTo.iType == typeFrom) continue;
if (CanRaiseTransaction(typeFrom, (Sbm.TransactionType)transTypeTo.Type))
transTypes.Add(transTypeTo);
}
return transTypes;
}
//-------------------------------------------------------------------
public virtual List<TypeCodeDesc> GetTransactionTypesForRaiseTo(Sbm.TransactionType typeTo)
{
// 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);
//transTypes_Full.GotoStart();
foreach (TypeCodeDesc transTypeTo in transactionTypes_Full)
{
//TypeCodeDesc & typeTo = transTypes_Full.Index();
if ((Sbm.TransactionType)transTypeTo.Type == typeTo) continue;
if (CanRaiseTransaction((Sbm.TransactionType)transTypeTo.Type, typeTo))
transTypes.Add(transTypeTo);
}
return transTypes;
}
//-------------------------------------------------------------------
// Prepare Requirements Transaction. - Prepare copied list of requirements, eg. when raising from another transaction.
public virtual bool PrepareCopiedRequirements(SbmTransaction transSource, List<SbmRequirement> requireList, Sbm.TransactionType type)
{
type = new Sbm.TransactionType();
//transSource; requireList; type;
return false;
}
//-------------------------------------------------------------------
// Remove Transaction.- By default, not allowed if transaction has requirements.
public virtual bool CanRemoveTransactionWithRequirements(SbmTransaction transaction, int requirementCount)
{
if (transaction == null || !SysId.IsValid(transaction.Id)) return false;
return requirementCount < 1;
}
//-------------------------------------------------------------------
// Tax Effective Date. - TransTypes that should use the 'In Progress' date as tax point as opposed to the 'Raised' date.
public virtual bool UseInProgressTaxDateAsTaxPoint(Sbm.TransactionType transactionType)
{
switch (transactionType)
{
case Sbm.TransactionType.ProformaSalesOrder:
case Sbm.TransactionType.SalesDispatch:
case Sbm.TransactionType.ProformaPurchaseOrder:
case Sbm.TransactionType.PurchaseDelivery:
case Sbm.TransactionType.ProformaSalesInvoice:
return false;
}
return true;
}
//-------------------------------------------------------------------
// R e q u i r e m e n t O p t i o n s
//-------------------------------------------------------------------
// Requirement Actions.
public virtual bool SearchCommodityOnCreateRequirement(Sbm.TransactionType transactionType)
{
return false;
}
//-------------------------------------------------------------------
// Requirement Costing.
public virtual SbmRequirementCostingConfig GetRequirementCostingConfig()
{
SbmRequirementCostingConfig cfgRequirementCosting = new SbmRequirementCostingConfig();
return cfgRequirementCosting;
}
//-------------------------------------------------------------------
// Transaction Maintenance Dialogs.
/*
public SapDlgUpdateTransaction GetCreateTransactionDlg (ISbmUserContext userContext, SysId id, Sbm.TransactionType type)
{
return null;
}
public SapDlgUpdateTransaction GetUpdateTransactionDlg (ISbmUserContext userContext, Sbm.TransactionType type, bool readOnly)
{
return null;
}
*/
//-------------------------------------------------------------------
}
//=======================================================================
}
@@ -1,4 +1,5 @@
using Sarand.BusinessMgr.Net.Standard.Base.App;
using Org.BouncyCastle.Asn1.X509;
using Sarand.BusinessMgr.Net.Standard.Base.App;
using Sarand.BusinessMgr.Net.Standard.Base.Bus;
using Sarand.BusinessMgr.Net.Standard.Base.Core;
using Sarand.BusinessMgr.Net.Standard.Base.Procs;
@@ -12,6 +13,9 @@ using Sarand.Net.Standard.Base.ItemOptions;
using Sarand.Net.Standard.Base.Utils;
using System;
using System.Collections.Generic;
using static Sarand.BusinessMgr.Net.Standard.Base.App.Sbm;
using static Sarand.Net.Standard.Base.Core.StringPair;
using static Sarand.Net.Standard.Base.ItemOptions.SaItemOptionDfn;
namespace Sarand.BusinessMgr.Net.Standard.Base.Consoles
{
@@ -19,7 +23,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Consoles
/// <summary>
/// Application configuration associated with a specific session.
/// </summary>
public class SbmSessionConsole : SacsDisposable
public partial class SbmSessionConsole : SacsDisposable, ISbmOrganisationConfig
{
//-------------------------------------------------------------------
// Interface definition.
@@ -73,6 +77,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Consoles
private SbmInternals internals;
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;
@@ -80,7 +85,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Consoles
//-------------------------------------------------------------------
// Construction.
protected SbmSessionConsole(Sbm.SessionConfig sessionConfig, SbmVersion consoleVersion, ISbmUserContext_Core userContext)
protected SbmSessionConsole(Sbm.SessionConfig sessionConfig, SbmVersion consoleVersion, ISbmUserOrganisationContext userContext)
{
this.SessionConfig = sessionConfig;
this.AppVersion = new SbmVersion("BusinessMgr", Sbm.Version.GetFullVersion(), SacsSystem.AssemblyBuildAt);
@@ -98,20 +103,20 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Consoles
//-------------------------------------------------------------------
// Properties.
public Sbm.SessionConfig SessionConfig { get; }
public ISbmUserContext_Core UserContext { get; }
public ISbmUserOrganisationContext UserContext { get; }
public SbmSessionContext SessionContext { get { return UserContext.SessionContext; } }
public SbmVersion AppVersion { get; }
public SbmVersion ConsoleVersion { get; }
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; } }
private SbmInternals Internals { get { if (internals == null) internals = new SbmInternals(UserContext); return internals; } }
//-------------------------------------------------------------------
// C r e a t e C o n s o l e
//-------------------------------------------------------------------
public static SbmSessionConsole CreateConsole(ISbmUserContext_Core userContext)
public static SbmSessionConsole CreateConsole(ISbmUserOrganisationContext userContext)
{
SaLogger.Warn($"{SysUtil.Fn} Creating default configuration console.");
// Default console.
// Initialise console.
SbmVersion consoleVersion = new SbmVersion("Standard", Sbm.Version.GetFullVersion(), SacsSystem.AssemblyBuildAt);
return new SbmSessionConsole(Sbm.SessionConfig.Generic, consoleVersion, userContext);
}
@@ -120,7 +125,71 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Consoles
// Utilities.
//-------------------------------------------------------------------
// A p p l i c a t i o n
// Organisation configuration.
//-------------------------------------------------------------------
public String GetOrganisationOption(Sbm.OrganisationOption option, String context)
{
return OrganisationConfig.GetOrganisationOption(option, context);
}
public String GetOrganisationOption(String optionName, String context)
{
return OrganisationConfig.GetOrganisationOption(optionName, context);
}
public String GetOwnerOption_Value(Sbm.OrgOption_Value value)
{
return OrganisationConfig.GetOwnerOption_Value(value);
}
public String GetOwnerOption_Folder(Sbm.OrgOption_Folder folder)
{
return OrganisationConfig.GetOwnerOption_Folder(folder);
}
public bool GetOwnerOption_AllowOption(Sbm.OrgOption_AllowOption option)
{
return OrganisationConfig.GetOwnerOption_AllowOption(option);
}
public String GetOwnerOption_Caption(Sbm.OrgOption_Caption caption, String defaultValue)
{
return OrganisationConfig.GetOwnerOption_Caption(caption, defaultValue);
}
public bool GetOwnerOption_ShowField(SbmDbDfn.ColumnIdx column)
{
return OrganisationConfig.GetOwnerOption_ShowField(column);
}
public bool GetOwnerOption_ShowColumn(Sbm.OrgOption_ShowColumn column)
{
return OrganisationConfig.GetOwnerOption_ShowColumn(column);
}
public String GetOwnerOption_FieldLabel(SbmDbDfn.ColumnIdx column, String defautValue)
{
return OrganisationConfig.GetOwnerOption_FieldLabel(column, defautValue);
}
public int GetOwnerOption_Minutes(Sbm.OrgOption_Minutes limit, int defautValue)
{
return OrganisationConfig.GetOwnerOption_Minutes(limit, defautValue);
}
public int GetOwnerOption_UpdateLimit(Sbm.OrgOption_PeriodDays limit, int defautValue)
{
return OrganisationConfig.GetOwnerOption_UpdateLimit(limit, defautValue);
}
public int GetOwnerOption_UpdateLimit(Sbm.OrgOption_PeriodWeeks limit, int defautValue)
{
return OrganisationConfig.GetOwnerOption_UpdateLimit(limit, defautValue);
}
public int GetOwnerOption_NumericDecimals(Sbm.OrgOption_NumericDecimals decimals, int defautValue = 2)
{
return OrganisationConfig.GetOwnerOption_NumericDecimals(decimals, defautValue);
}
public Sbm.CommodityType GetOwnerOption_CommodityType(Sbm.OrgOption_CommodityType commodityType)
{
return OrganisationConfig.GetOwnerOption_CommodityType(commodityType);
}
public SysId GetOwnerOption_StockLocation(Sbm.OrgOption_StockLocation stockLocation)
{
return OrganisationConfig.GetOwnerOption_StockLocation(stockLocation);
}
//-------------------------------------------------------------------
// Application.
//-------------------------------------------------------------------
// Application Customisation.
public virtual string GetApplicationCaption(Sbm.CaptionType captionType)
@@ -160,20 +229,21 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Consoles
// Application.
case Sbm.ConfigOption.SystemMenu:
return InstanceConfig.AllowApplicationOption(option, SacsSystem.DebugMode);
case Sbm.ConfigOption.AllowConsoleView:
case Sbm.ConfigOption.AllowOrganisationUpdate:
case Sbm.ConfigOption.AllowContacts:
case Sbm.ConfigOption.AllowProcesses:
case Sbm.ConfigOption.AllowCommodities:
case Sbm.ConfigOption.AllowTransactions:
// Options allowed by default.
case Sbm.ConfigOption.ConsoleView:
case Sbm.ConfigOption.OrganisationUpdate:
case Sbm.ConfigOption.Contacts:
case Sbm.ConfigOption.Processes:
case Sbm.ConfigOption.Commodities:
case Sbm.ConfigOption.Transactions:
case Sbm.ConfigOption.DiaryView:
case Sbm.ConfigOption.AllowRequirementUpdateInline:
case Sbm.ConfigOption.RequirementUpdateInline:
return InstanceConfig.AllowApplicationOption(option, true);
// Commodities.
case Sbm.ConfigOption.CommodityPartialCodeFilter:
if (InstanceConfig.AllowApplicationOption(option, false))
return true;
return UserContext.GetOwnerOption_AllowOption(Sbm.OrgOption_AllowOption.Commodity_PartialCodeFilter);
return OrganisationConfig.GetOwnerOption_AllowOption(Sbm.OrgOption_AllowOption.Commodity_PartialCodeFilter);
// Order Pricing.
case Sbm.ConfigOption.CustomerPriceSet:
case Sbm.ConfigOption.CustomerDiscount:
@@ -189,8 +259,10 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Consoles
return true;
return Internals.AccountsDfn.IsUsingSageInterface() && Internals.AccountsDfn.IsAssociationTypeManagedByAccounts(Sbm.AssociationType.Supplier) && !Internals.AccountsDfn.UseLocalSupplierPricing();
}
default:
// Other options are not allowed by default.
return InstanceConfig.AllowApplicationOption(option, false);
}
return InstanceConfig.AllowApplicationOption(option, false);
}
//-------------------------------------------------------------------
@@ -334,24 +406,24 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Consoles
// I t e m s
//-------------------------------------------------------------------
// Item Data Interface.
public virtual bool CanUpdateItemData(ISbmUserContext_Core userContext, Sbm.ItemDataType itemDataType)
public virtual bool CanUpdateItemData(ISbmUserOrganisationContext userContext, Sbm.ItemDataType itemDataType)
{
return false;
}
public virtual bool DoUpdateItemData(ISbmUserContext_Core userContext, Sbm.ItemDataType itemDataType)
public virtual bool DoUpdateItemData(ISbmUserOrganisationContext userContext, Sbm.ItemDataType itemDataType)
{
return false;
}
public virtual bool CanRemoveItemData(ISbmUserContext_Core userContext, Sbm.ItemDataType itemDataType)
public virtual bool CanRemoveItemData(ISbmUserOrganisationContext userContext, Sbm.ItemDataType itemDataType)
{
return false;
}
//-------------------------------------------------------------------
// Update Log.
public virtual bool IsColumnChangeLogged(ISbmUserContext_Core userContext, SbmDbDfn.ColumnIdx column)
public virtual bool IsColumnChangeLogged(ISbmUserOrganisationContext userContext, SbmDbDfn.ColumnIdx column)
{
return false;
}
@@ -377,27 +449,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Consoles
{
return InstanceConfig.AllowAssociationType(type, true);
}
// Supported Transaction types.
public virtual bool AllowTransactionType(Sbm.TransactionType type)
{
switch (type)
{
// Transaction types that are allowed.
case Sbm.TransactionType.SalesQuote:
case Sbm.TransactionType.SalesOrder:
//case Sbm.TransactionType.PurchaseOrder:
return InstanceConfig.AllowTransactionType(type, true);
// Proforma types are only allowed if ther counterparts cannot be created.
case Sbm.TransactionType.ProformaPurchaseOrder:
return InstanceConfig.AllowTransactionType(type, AllowTransactionType(Sbm.TransactionType.PurchaseOrder) && !CanCreateTransactionLocally(Sbm.TransactionType.PurchaseOrder));
case Sbm.TransactionType.ProformaSalesOrder:
return InstanceConfig.AllowTransactionType(type, AllowTransactionType(Sbm.TransactionType.SalesOrder) && !CanCreateTransactionLocally(Sbm.TransactionType.SalesOrder));
case Sbm.TransactionType.ProformaSalesInvoice:
return InstanceConfig.AllowTransactionType(type, AllowTransactionType(Sbm.TransactionType.SalesInvoice) && !CanCreateTransactionLocally(Sbm.TransactionType.SalesInvoice));
}
return false;
}
//-------------------------------------------------------------------
// D a t a O p t i o n s
@@ -411,28 +462,28 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Consoles
// Commodity - specification.
case SbmDbDfn.ColumnIdx.Commodity_Weight:
case SbmDbDfn.ColumnIdx.Commodity_UomIdWeight:
return UserContext.GetOwnerOption_ShowField(SbmDbDfn.ColumnIdx.Commodity_Weight);
return OrganisationConfig.GetOwnerOption_ShowField(SbmDbDfn.ColumnIdx.Commodity_Weight);
case SbmDbDfn.ColumnIdx.Commodity_Length:
case SbmDbDfn.ColumnIdx.Commodity_UomIdLength:
return UserContext.GetOwnerOption_ShowField(SbmDbDfn.ColumnIdx.Commodity_Length);
return OrganisationConfig.GetOwnerOption_ShowField(SbmDbDfn.ColumnIdx.Commodity_Length);
case SbmDbDfn.ColumnIdx.Commodity_Volume:
case SbmDbDfn.ColumnIdx.Commodity_UomIdVolume:
return UserContext.GetOwnerOption_ShowField(SbmDbDfn.ColumnIdx.Commodity_Volume);
return OrganisationConfig.GetOwnerOption_ShowField(SbmDbDfn.ColumnIdx.Commodity_Volume);
case SbmDbDfn.ColumnIdx.Commodity_Density:
case SbmDbDfn.ColumnIdx.Commodity_UomIdDensity:
return UserContext.GetOwnerOption_ShowField(SbmDbDfn.ColumnIdx.Commodity_Density);
return OrganisationConfig.GetOwnerOption_ShowField(SbmDbDfn.ColumnIdx.Commodity_Density);
case SbmDbDfn.ColumnIdx.Commodity_BoxQuantity:
case SbmDbDfn.ColumnIdx.Commodity_UomIdBox:
return UserContext.GetOwnerOption_ShowField(SbmDbDfn.ColumnIdx.Commodity_BoxQuantity);
return OrganisationConfig.GetOwnerOption_ShowField(SbmDbDfn.ColumnIdx.Commodity_BoxQuantity);
case SbmDbDfn.ColumnIdx.Commodity_TimeProd:
case SbmDbDfn.ColumnIdx.Commodity_UomIdTimeProd:
return UserContext.GetOwnerOption_ShowField(SbmDbDfn.ColumnIdx.Commodity_TimeProd);
return OrganisationConfig.GetOwnerOption_ShowField(SbmDbDfn.ColumnIdx.Commodity_TimeProd);
case SbmDbDfn.ColumnIdx.Commodity_MaterialCost:
case SbmDbDfn.ColumnIdx.Commodity_CurrencyIdMaterial:
return UserContext.GetOwnerOption_ShowField(SbmDbDfn.ColumnIdx.Commodity_MaterialCost);
return OrganisationConfig.GetOwnerOption_ShowField(SbmDbDfn.ColumnIdx.Commodity_MaterialCost);
case SbmDbDfn.ColumnIdx.Commodity_ExWorksCost:
case SbmDbDfn.ColumnIdx.Commodity_CurrencyIdExWorks:
return UserContext.GetOwnerOption_ShowField(SbmDbDfn.ColumnIdx.Commodity_ExWorksCost);
return OrganisationConfig.GetOwnerOption_ShowField(SbmDbDfn.ColumnIdx.Commodity_ExWorksCost);
case SbmDbDfn.ColumnIdx.Commodity_CommodityIdSalesProj:
case SbmDbDfn.ColumnIdx.Commodity_SalesProjMonthlyProp:
case SbmDbDfn.ColumnIdx.Commodity_SalesProjMonth01:
@@ -447,9 +498,9 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Consoles
case SbmDbDfn.ColumnIdx.Commodity_SalesProjMonth10:
case SbmDbDfn.ColumnIdx.Commodity_SalesProjMonth11:
case SbmDbDfn.ColumnIdx.Commodity_SalesProjMonth12:
return UserContext.GetOwnerOption_ShowField(SbmDbDfn.ColumnIdx.Commodity_SalesProjAnnual);
return OrganisationConfig.GetOwnerOption_ShowField(SbmDbDfn.ColumnIdx.Commodity_SalesProjAnnual);
default:
return UserContext.GetOwnerOption_ShowField(column);
return OrganisationConfig.GetOwnerOption_ShowField(column);
}
}
@@ -460,388 +511,19 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Consoles
string Caption = "";
if (column != SbmDbDfn.ColumnIdx.Unknown)
{
Caption = UserContext.GetOwnerOption_FieldLabel(column, Default);
Caption = OrganisationConfig.GetOwnerOption_FieldLabel(column, Default);
}
if (Caption.IsEmpty()) Caption = Default;
return Caption;
}
//-------------------------------------------------------------------
// T r a n s a c t i o n O p t i o n s
//-------------------------------------------------------------------
// To do - move to InstanceConfig.
// Job Tracking Options.
public virtual string GetDefaultQuoteDescIntro()
{
return "";
}
//-------------------------------------------------------------------
// Transaction Maintenance Dialogs.
/*
public SapDlgUpdateTransaction GetCreateTransactionDlg (ISbmUserContext userContext, SysId id, Sbm.TransactionType type)
{
return null;
}
public SapDlgUpdateTransaction GetUpdateTransactionDlg (ISbmUserContext userContext, Sbm.TransactionType type, bool readOnly)
{
return null;
}
*/
//-------------------------------------------------------------------
// Create Transaction.
public virtual bool CanCreateTransactionLocally(Sbm.TransactionType type)
{
if (!AllowTransactionType(type)) return false;
// Refresh options.
if (dfnSageInt.AffiliateId_Owner != UserContext.OrganisationAffiliateId || dfnQBooksInt.AffiliateId_Owner != UserContext.OrganisationAffiliateId)
{
// Reset the accounts interface configurations.
dfnSageInt.ClearConfig();
dfnSageInt.AffiliateId_Owner = UserContext.OrganisationAffiliateId;
dfnQBooksInt.ClearConfig();
dfnQBooksInt.AffiliateId_Owner = UserContext.OrganisationAffiliateId;
// Identify the interfaces.
dfnSageInt.InterfaceId = Internals.AccountsDfn.GetAccountInterfaceId(Sbm.InterfaceType_Accounts.SageLine50);
dfnQBooksInt.InterfaceId = Internals.AccountsDfn.GetAccountInterfaceId(Sbm.InterfaceType_Accounts.QuickBooks);
// Sales and purchase orders/invoices can only be created locally if they are not imported from one of these interfaces.
if (SysId.IsValid(dfnSageInt.InterfaceId))
{
// Interpret interface options.
dfnSageInt.importPurchaseOrder = Internals.AccountsDfn.GetSageImportOption(Sage.ItemType.PurchaseOrder);
dfnSageInt.importSalesOrder = Internals.AccountsDfn.GetSageImportOption(Sage.ItemType.SalesOrder);
dfnSageInt.importProductInvoice = Internals.AccountsDfn.GetSageImportOption(Sage.ItemType.Invoice_Product);
dfnSageInt.importServiceInvoice = Internals.AccountsDfn.GetSageImportOption(Sage.ItemType.Invoice_Service);
dfnSageInt.importSalesOrderInvoice = Internals.AccountsDfn.GetSageImportOption(Sage.ItemType.Invoice_SalesOrder);
dfnSageInt.exportPurchaseOrder = Internals.AccountsDfn.GetSageExportOption(Sage.ItemType.PurchaseOrder);
dfnSageInt.exportSalesOrder = Internals.AccountsDfn.GetSageExportOption(Sage.ItemType.SalesOrder);
dfnSageInt.exportProductInvoice = Internals.AccountsDfn.GetSageExportOption(Sage.ItemType.Invoice_Product);
dfnSageInt.exportServiceInvoice = Internals.AccountsDfn.GetSageExportOption(Sage.ItemType.Invoice_Service);
dfnSageInt.exportSalesOrder = Internals.AccountsDfn.GetSageExportOption(Sage.ItemType.Invoice_SalesOrder);
}
if (SysId.IsValid(dfnQBooksInt.InterfaceId))
{
// Interpret interface options.
dfnQBooksInt.importPurchaseOrder = Internals.AccountsDfn.GetQuickBooksImportOption(Qbk.EntityType.PurchaseOrder);
dfnQBooksInt.importSalesOrder = Internals.AccountsDfn.GetQuickBooksImportOption(Qbk.EntityType.SalesOrder);
dfnQBooksInt.importProductInvoice = Internals.AccountsDfn.GetQuickBooksImportOption(Qbk.EntityType.Invoice_Product);
dfnQBooksInt.importServiceInvoice = Internals.AccountsDfn.GetQuickBooksImportOption(Qbk.EntityType.Invoice_Service);
dfnQBooksInt.importSalesOrderInvoice = false;
dfnQBooksInt.exportPurchaseOrder = Internals.AccountsDfn.GetQuickBooksExportOption(Qbk.EntityType.PurchaseOrder);
dfnQBooksInt.exportSalesOrder = Internals.AccountsDfn.GetQuickBooksExportOption(Qbk.EntityType.SalesOrder);
dfnQBooksInt.exportProductInvoice = Internals.AccountsDfn.GetQuickBooksExportOption(Qbk.EntityType.Invoice_Product);
dfnQBooksInt.exportServiceInvoice = Internals.AccountsDfn.GetQuickBooksExportOption(Qbk.EntityType.Invoice_Service);
dfnQBooksInt.bexport_SalesOrderInvoice = false;
}
// 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;
// Sales quotes are also imported from Sage Sales Orders.
createTransaction_SalesQuote = createTransaction_SalesOrder;
}
switch (type)
{
case Sbm.TransactionType.SalesQuote:
return createTransaction_SalesQuote;
case Sbm.TransactionType.SalesOrder:
return createTransaction_SalesOrder;
case Sbm.TransactionType.SalesInvoice:
return createTrans_SalesInvoice;
case Sbm.TransactionType.PurchaseOrder:
return createTransaction_PurchaseOrder;
}
return true;
}
//-------------------------------------------------------------------
// Transaction Creation options.
public enum AssignTransRefMethod
{
System, Manual, Option
}
public virtual AssignTransRefMethod TransactionAssignRefMethod(Sbm.TransactionType transTypes)
{
return AssignTransRefMethod.System;
}
public enum AssignTransRefSource
{
ByOwnerType, ByType
}
public virtual AssignTransRefSource TransactionAssignRefSource(Sbm.TransactionType transTypes)
{
return AssignTransRefSource.ByOwnerType;
}
// By default all types of transaction have their own Id sequence.
// Override this method to allow different types of transaction to share Id sequence.
public virtual Sbm.TransactionType GetTransactionTypeForNextId(Sbm.TransactionType transTypes)
{
return transTypes;
}
// NextId key value.
public virtual string GetTransactionNextIdKey(SysId AffiliateId_Owner, SysId idAssoc, Sbm.TransactionType eType)
{
idAssoc = new SysId();
Sbm.TransactionType transTypes = GetTransactionTypeForNextId(eType);
switch (TransactionAssignRefSource(eType))
{
case AssignTransRefSource.ByOwnerType:
// Next Id depends on both the transaction type and owner.
return "TransRef:" + transTypes.ToString() + ":" + AffiliateId_Owner.ToString();
default:
// Next Id only depends on the transaction type.
return "TransRef:" + transTypes.ToString();
}
}
// Set the minimum Id for transactions of the specified type.
public virtual bool SetMinTransactionId(SysId AffiliateId_Owner, SysId idAssoc, Sbm.TransactionType transTypes, long iId)
{
bool set = false;
if (SbmGlobals.Application.GetBusMgrDatabase(SessionContext) != null)
{
string nextIdKey = GetTransactionNextIdKey(AffiliateId_Owner, idAssoc, transTypes);
// ToDo set = SbmGlobals.Database.SetMinNextId(nextIdKey, iId, false);
}
return set;
}
// The implementation in this class will generate simple numeric values for the owner
// and global options that can be formatted (eg. to fixed length) by overwridden versions.
public virtual string GetTransactionCreateRef
(SysId AffiliateId_Owner, SysId idAssoc, Sbm.TransactionType transTypes)
{
string Ref = "";
if (SbmGlobals.Application.GetBusMgrDatabase(SessionContext) != null)
{
string NextIdKey = GetTransactionNextIdKey(AffiliateId_Owner, idAssoc, transTypes);
// ToDo long iRefNext = SbmGlobals.Database.GetNextId(NextIdKey, false);
// Ref = FormatTransactionCreateRef(AffiliateId_Owner, idAssoc, transTypes, iRefNext);
}
return Ref;
}
public virtual string FormatTransactionCreateRef
(SysId AffiliateId_Owner, SysId idAssoc, Sbm.TransactionType transTypes, long RefInt)
{
string Ref = "";
if (RefInt > 0)
{
// Retrieve and validate the sequence padding length.
int SeqLen = Math.Max(1, Math.Min(8, GetTransactionRefSeqLength(AffiliateId_Owner, idAssoc, transTypes)));
// Pad the sequence number.
//Ref = String(RefInt, SeqLen);
// Add the reference prefix (max 5 chars)
string prefix = GetTransactionRefPrefix(AffiliateId_Owner, idAssoc, transTypes);
Ref = prefix.Left(5) + Ref;
}
return Ref;
}
public virtual int GetTransactionRefSeqLength(SysId AffiliateId_Owner, SysId idAssoc, Sbm.TransactionType transTypes)
{
return 5;
}
//-------------------------------------------------------------------
/// <summary>Transaction reference prefix by type</summary>
public virtual string GetTransactionRefPrefix(SysId id, SysId idAssoc, Sbm.TransactionType transactionType)
{
return "";
}
//-------------------------------------------------------------------
// Raise Transaction.
public virtual bool CanRaiseTransaction(Sbm.TransactionType typeFrom, Sbm.TransactionType typeTo)
{
if (!AllowTransactionType(typeFrom) || !AllowTransactionType(typeTo)) return false;
if (!CanCreateTransactionLocally(typeTo)) return false;
if (typeFrom == Sbm.TransactionType.Project)
{
// Can raise another project from a project.
switch (typeTo)
{
case Sbm.TransactionType.Project:
return CanCreateTransactionLocally(typeTo);
}
}
else if (typeFrom == Sbm.TransactionType.SalesLead)
{
// Can raise sales quote or order from a lead.
switch (typeTo)
{
case Sbm.TransactionType.SalesQuote:
case Sbm.TransactionType.ProformaSalesOrder:
case Sbm.TransactionType.SalesOrder:
return CanCreateTransactionLocally(typeTo);
}
}
else if (typeFrom == Sbm.TransactionType.SalesQuote)
{
// Can raise sales lead or order from a sales quote.
switch (typeTo)
{
case Sbm.TransactionType.SalesLead:
case Sbm.TransactionType.SalesQuote:
case Sbm.TransactionType.ProformaSalesOrder:
case Sbm.TransactionType.SalesOrder:
case Sbm.TransactionType.ProformaSalesInvoice:
case Sbm.TransactionType.SalesInvoice:
return CanCreateTransactionLocally(typeTo);
}
}
else if (typeFrom == Sbm.TransactionType.SalesOrder || typeFrom == Sbm.TransactionType.ProformaSalesOrder)
{
// Can raise almost anything from a sales order.
switch (typeTo)
{
case Sbm.TransactionType.SalesLead:
case Sbm.TransactionType.SalesQuote:
case Sbm.TransactionType.ProformaSalesOrder:
case Sbm.TransactionType.SalesOrder:
case Sbm.TransactionType.SalesDispatch:
case Sbm.TransactionType.ProformaSalesInvoice:
case Sbm.TransactionType.SalesInvoice:
// Can also raise purchase quote or order from sales order:
case Sbm.TransactionType.PurchaseQuote:
case Sbm.TransactionType.ProformaPurchaseOrder:
case Sbm.TransactionType.PurchaseOrder:
return CanCreateTransactionLocally(typeTo);
}
}
else if (typeFrom == Sbm.TransactionType.SalesDispatch)
{
// Can raise a sales invoice from a dispatch note.
switch (typeTo)
{
case Sbm.TransactionType.ProformaSalesInvoice:
case Sbm.TransactionType.SalesInvoice:
return CanCreateTransactionLocally(typeTo);
}
}
else if (typeFrom == Sbm.TransactionType.PurchaseQuote)
{
// Can raise a purchase order from purchase quote.
switch (typeTo)
{
case Sbm.TransactionType.PurchaseQuote:
case Sbm.TransactionType.ProformaPurchaseOrder:
case Sbm.TransactionType.PurchaseOrder:
return CanCreateTransactionLocally(typeTo);
}
}
else if (typeFrom == Sbm.TransactionType.PurchaseOrder || typeFrom == Sbm.TransactionType.ProformaPurchaseOrder)
{
// Can raise a sales order or purchase quote from a purchase order.
switch (typeTo)
{
case Sbm.TransactionType.SalesQuote:
case Sbm.TransactionType.ProformaSalesOrder:
case Sbm.TransactionType.SalesOrder:
case Sbm.TransactionType.PurchaseQuote:
case Sbm.TransactionType.ProformaPurchaseOrder:
case Sbm.TransactionType.PurchaseOrder:
return CanCreateTransactionLocally(typeTo);
}
}
return false;
}
//-------------------------------------------------------------------
public virtual List<TypeCodeDesc> GetTransactionTypesForRaiseFrom(Sbm.TransactionType typeFrom)
{
// 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 = SbmSystem.GetCodesOfType(UserContext, Sbm.SystemCode.TransactionType);
foreach (TypeCodeDesc transTypeTo in transactionTypes_Full)
{
//if ((Sbm.TransactionType)typeTo.iType == typeFrom) continue;
if (CanRaiseTransaction(typeFrom, (Sbm.TransactionType)transTypeTo.Type))
transTypes.Add(transTypeTo);
}
return transTypes;
}
//-------------------------------------------------------------------
public virtual List<TypeCodeDesc> GetTransactionTypesForRaiseTo(Sbm.TransactionType typeTo)
{
// 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 = SbmSystem.GetCodesOfType(UserContext, Sbm.SystemCode.TransactionType);
//transTypes_Full.GotoStart();
foreach (TypeCodeDesc transTypeTo in transactionTypes_Full)
{
//TypeCodeDesc & typeTo = transTypes_Full.Index();
if ((Sbm.TransactionType)transTypeTo.Type == typeTo) continue;
if (CanRaiseTransaction((Sbm.TransactionType)transTypeTo.Type, typeTo))
transTypes.Add(transTypeTo);
}
return transTypes;
}
//-------------------------------------------------------------------
// Prepare Requirements Transaction. - Prepare copied list of requirements, eg. when raising from another transaction.
public virtual bool PrepareCopiedRequirements(SbmTransaction transSource, List<SbmRequirement> requireList, Sbm.TransactionType type)
{
type = new Sbm.TransactionType();
//transSource; requireList; type;
return false;
}
//-------------------------------------------------------------------
// Remove Transaction.- By default, not allowed if transaction has requirements.
public virtual bool CanRemoveTransactionWithRequirements(SbmTransaction transaction, int requirementCount)
{
if (transaction == null || !SysId.IsValid(transaction.Id)) return false;
return requirementCount < 1;
}
//-------------------------------------------------------------------
// Tax Effective Date. - TransTypes that should use the 'In Progress' date as tax point as opposed to the 'Raised' date.
public virtual bool UseInProgressTaxDateAsTaxPoint(Sbm.TransactionType transactionType)
{
switch (transactionType)
{
case Sbm.TransactionType.ProformaSalesOrder:
case Sbm.TransactionType.SalesDispatch:
case Sbm.TransactionType.ProformaPurchaseOrder:
case Sbm.TransactionType.PurchaseDelivery:
case Sbm.TransactionType.ProformaSalesInvoice:
return false;
}
return true;
}
//-------------------------------------------------------------------
// R e q u i r e m e n t O p t i o n s
//-------------------------------------------------------------------
// Requirement Actions.
public virtual bool SearchCommodityOnCreateRequirement(Sbm.TransactionType transactionType)
{
return false;
}
//-------------------------------------------------------------------
// Requirement Costing.
public virtual SbmRequirementCostingConfig GetRequirementCostingConfig()
{
SbmRequirementCostingConfig cfgRequirementCosting = new SbmRequirementCostingConfig();
return cfgRequirementCosting;
}
//-------------------------------------------------------------------
// C o m m o d i t y O p t i o n s
//-------------------------------------------------------------------
@@ -967,9 +649,9 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Consoles
{
case SaInterfaceCategory.Website:
case SaInterfaceCategory.File:
return true;
return InstanceConfig.AllowInterfaceCategory(interfaceCategory, true);
}
return false;
return InstanceConfig.AllowInterfaceCategory(interfaceCategory, false);
}
public virtual bool AllowInterface(SaInterfaceCategory interfaceCategory, short interfaceType)
@@ -1005,7 +687,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Consoles
// Sbm.InterfaceType_System.Hpi - Only allowed by derived console.
break;
case SaInterfaceCategory.File:
if (AllowOption(Sbm.ConfigOption.AllowTransactions))
if (AllowOption(Sbm.ConfigOption.Transactions))
{
if (interfaceType == (short)Sbm.InterfaceType_File.TransactionImport) return true;
if (interfaceType == (short)Sbm.InterfaceType_File.TransactionExport) return true;
@@ -1015,19 +697,19 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Consoles
if (interfaceType == (short)Sbm.InterfaceType_File.TransToWord_SalesInvoice) return AllowTransactionType(Sbm.TransactionType.ProformaSalesInvoice) || AllowTransactionType(Sbm.TransactionType.SalesInvoice);
if (interfaceType == (short)Sbm.InterfaceType_File.TransToWord_PurchaseOrder) return AllowTransactionType(Sbm.TransactionType.ProformaPurchaseOrder) || AllowTransactionType(Sbm.TransactionType.PurchaseOrder);
}
if (AllowOption(Sbm.ConfigOption.AllowContacts))
if (AllowOption(Sbm.ConfigOption.Contacts))
{
if (interfaceType == (short)Sbm.InterfaceType_File.AffiliateImport) return true;
if (interfaceType == (short)Sbm.InterfaceType_File.AffiliateExport) return true;
if (interfaceType == (short)Sbm.InterfaceType_File.AssociationImport) return true;
if (interfaceType == (short)Sbm.InterfaceType_File.AssociationExport) return true;
}
if (AllowOption(Sbm.ConfigOption.AllowCommodities))
if (AllowOption(Sbm.ConfigOption.Commodities))
{
if (interfaceType == (short)Sbm.InterfaceType_File.CommodityImport) return true;
if (interfaceType == (short)Sbm.InterfaceType_File.CommodityExport) return true;
}
if (interfaceType == (short)Sbm.InterfaceType_File.VehicleImport) return AllowOption(Sbm.ConfigOption.AllowVehicles);
if (interfaceType == (short)Sbm.InterfaceType_File.VehicleImport) return AllowOption(Sbm.ConfigOption.Vehicles);
if (interfaceType == (short)Sbm.InterfaceType_File.LeasewayInvoice)
//return SbmGlobals.Application.GetPropertyValue("Interface", "LeasewayInvoice").EqualsCI("Allow");
return false;