740 lines
29 KiB
C#
740 lines
29 KiB
C#
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;
|
|
using Sarand.Net.Standard.Accounts.QuickBooks.App;
|
|
using Sarand.Net.Standard.Accounts.Sage.App;
|
|
using Sarand.Net.Standard.Base.App;
|
|
using Sarand.Net.Standard.Base.Bus;
|
|
using Sarand.Net.Standard.Base.Core;
|
|
using Sarand.Net.Standard.Base.Interfaces;
|
|
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
|
|
{
|
|
//=======================================================================
|
|
/// <summary>
|
|
/// Application configuration associated with a specific session.
|
|
/// </summary>
|
|
public partial class SbmSessionConsole : SacsDisposable, ISbmOrganisationConfig
|
|
{
|
|
//-------------------------------------------------------------------
|
|
// Interface definition.
|
|
public class InterfaceDfn
|
|
{
|
|
public InterfaceDfn()
|
|
{
|
|
}
|
|
public SysId InterfaceId { get; } = new SysId();
|
|
public string Context { get; } = "";
|
|
public SaInterfaceCategory InterfaceCategory { get; } = SaInterfaceCategory.Unknown;
|
|
public short InterfaceType { get; }
|
|
public string Code { get; } = "";
|
|
public string Caption { get; } = "";
|
|
public bool Active { get; }
|
|
}
|
|
// Sage/Quickbooks interface definition.
|
|
public class AccountsInterfaceDfn
|
|
{
|
|
public SysId AffiliateId_Owner { get; set; } = new SysId(); // Owner for Sage Interface definition.
|
|
public SysId InterfaceId { get; set; } = new SysId();
|
|
public bool importPurchaseOrder, importSalesOrder, importProductInvoice, importServiceInvoice, importSalesOrderInvoice;
|
|
public bool exportPurchaseOrder, exportSalesOrder, exportProductInvoice, exportServiceInvoice, bexport_SalesOrderInvoice;
|
|
public AccountsInterfaceDfn()
|
|
{
|
|
Reset();
|
|
}
|
|
public void Reset()
|
|
{
|
|
AffiliateId_Owner = new SysId();
|
|
InterfaceId = new SysId();
|
|
ClearConfig();
|
|
}
|
|
public void ClearConfig()
|
|
{
|
|
importPurchaseOrder = false;
|
|
importSalesOrder = false;
|
|
importProductInvoice = false;
|
|
importServiceInvoice = false;
|
|
importSalesOrderInvoice = false;
|
|
exportPurchaseOrder = false;
|
|
exportSalesOrder = false;
|
|
exportProductInvoice = false;
|
|
exportServiceInvoice = false;
|
|
bexport_SalesOrderInvoice = false;
|
|
}
|
|
};
|
|
|
|
//-------------------------------------------------------------------
|
|
// Data members.
|
|
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;
|
|
private bool productionControl;
|
|
|
|
//-------------------------------------------------------------------
|
|
// Construction.
|
|
protected SbmSessionConsole(Sbm.SessionConfig sessionConfig, SbmVersion consoleVersion, ISbmUserOrganisationContext userContext)
|
|
{
|
|
this.SessionConfig = sessionConfig;
|
|
this.AppVersion = new SbmVersion("BusinessMgr", Sbm.Version.GetFullVersion(), SacsSystem.AssemblyBuildAt);
|
|
this.ConsoleVersion = consoleVersion;
|
|
this.UserContext = userContext;
|
|
}
|
|
protected override void Dispose(bool disposing)
|
|
{
|
|
if (disposing)
|
|
{
|
|
if (internals != null) internals.Dispose(); internals = null;
|
|
}
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
// Properties.
|
|
public Sbm.SessionConfig SessionConfig { 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(ISbmUserOrganisationContext userContext)
|
|
{
|
|
// Initialise console.
|
|
SbmVersion consoleVersion = new SbmVersion("Standard", Sbm.Version.GetFullVersion(), SacsSystem.AssemblyBuildAt);
|
|
return new SbmSessionConsole(Sbm.SessionConfig.Generic, consoleVersion, userContext);
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
// Utilities.
|
|
|
|
//-------------------------------------------------------------------
|
|
// 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)
|
|
{
|
|
return "BusinessMgr";
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
// Additional menu options.
|
|
public virtual List<CodeDesc> GetAdditionalMenuOptions(Sbm.MenuSection menuSection)
|
|
{
|
|
return new List<CodeDesc>();
|
|
}
|
|
|
|
public virtual bool DoAdditionalMenuOption(Sbm.MenuSection menuSection, string str)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
// Console view.
|
|
public virtual SbmConsoleViewDfn GetConsoleViewDfn()
|
|
{
|
|
return new SbmConsoleViewDfn();
|
|
}
|
|
public virtual bool InitialiseConsoleView()
|
|
{
|
|
return false;
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
// Application Configuration. - AllowOption.
|
|
public virtual bool AllowOption(Sbm.ConfigOption option)
|
|
{
|
|
switch (option)
|
|
{
|
|
// Application.
|
|
case Sbm.ConfigOption.SystemMenu:
|
|
return InstanceConfig.AllowApplicationOption(option, SacsSystem.DebugMode);
|
|
// 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.RequirementUpdateInline:
|
|
return InstanceConfig.AllowApplicationOption(option, true);
|
|
// Commodities.
|
|
case Sbm.ConfigOption.CommodityPartialCodeFilter:
|
|
if (InstanceConfig.AllowApplicationOption(option, false))
|
|
return true;
|
|
return OrganisationConfig.GetOwnerOption_AllowOption(Sbm.OrgOption_AllowOption.Commodity_PartialCodeFilter);
|
|
// Order Pricing.
|
|
case Sbm.ConfigOption.CustomerPriceSet:
|
|
case Sbm.ConfigOption.CustomerDiscount:
|
|
{
|
|
if (InstanceConfig.AllowApplicationOption(option, false))
|
|
return true;
|
|
return Internals.AccountsDfn.IsUsingSageInterface() && Internals.AccountsDfn.IsAssociationTypeManagedByAccounts(Sbm.AssociationType.Customer) && !Internals.AccountsDfn.UseLocalCustomerPricing();
|
|
}
|
|
case Sbm.ConfigOption.SupplierPriceSet:
|
|
case Sbm.ConfigOption.SupplierDiscount:
|
|
{
|
|
if (InstanceConfig.AllowApplicationOption(option, false))
|
|
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);
|
|
}
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
// Application events.
|
|
public virtual void OnOpenDatabase()
|
|
{
|
|
SaLogger.Trace($"{SysUtil.Fn}");
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
// O r g a n i s a t i o n
|
|
//-------------------------------------------------------------------
|
|
// Allows validation of organisation name if required. Default: true.
|
|
public virtual bool OwnerIsValid()
|
|
{
|
|
return true;
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
// Organisation Options.
|
|
public virtual List<SaItemOptionDfn> GetAdditionalOrganisationOptions()
|
|
{
|
|
return new List<SaItemOptionDfn>();
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
// C o d e T y p e s
|
|
//-------------------------------------------------------------------
|
|
// Application Code Types.
|
|
public virtual List<CodeDesc> GetDefaultCodesOfType(Sbm.ApplCodeType type)
|
|
{
|
|
List<CodeDesc> codes = new List<CodeDesc>();
|
|
switch (type)
|
|
{
|
|
case Sbm.ApplCodeType.ContactTitle:
|
|
codes.Add("Mr", "Mr");
|
|
codes.Add("Mrs", "Mrs");
|
|
codes.Add("Ms", "Ms");
|
|
codes.Add("Miss", "Miss");
|
|
codes.Add("Mx", "Mx");
|
|
codes.Add("Dr", "Dr");
|
|
break;
|
|
case Sbm.ApplCodeType.VehicleCategory:
|
|
/*
|
|
codes.Add("10", "Mini");
|
|
codes.Add("11", "Economy");
|
|
codes.Add("12", "Compact");
|
|
codes.Add("20", "Hatchback");
|
|
codes.Add("21", "Saloon");
|
|
codes.Add("22", "Estate");
|
|
codes.Add("30", "Executive");
|
|
codes.Add("50", "Intermediate");
|
|
codes.Add("51", "Standard");
|
|
codes.Add("52", "Full Size");
|
|
*/
|
|
break;
|
|
case Sbm.ApplCodeType.VehicleMake:
|
|
/*
|
|
codes.Add("ACUR", "Acura");
|
|
codes.Add("ALFA", "Alfa Romeo");
|
|
codes.Add("ASTO", "Aston Martin");
|
|
codes.Add("AUDI", "Audi");
|
|
codes.Add("BMW", "BMW");
|
|
codes.Add("BENT", "Bentley");
|
|
codes.Add("BUIC", "Buick");
|
|
codes.Add("CADI", "Cadillac");
|
|
codes.Add("CATE", "Caterham");
|
|
codes.Add("CHEV", "Chevrolet");
|
|
codes.Add("CHRY", "Chrysler");
|
|
codes.Add("CITR", "Citroen");
|
|
codes.Add("DAEW", "Daewoo");
|
|
codes.Add("DAF", "DAF");
|
|
codes.Add("DAIH", "Daihatsu");
|
|
codes.Add("DODG", "Dodge");
|
|
codes.Add("FERR", "Ferrari");
|
|
codes.Add("FIAT", "Fiat");
|
|
codes.Add("FORD", "Ford");
|
|
codes.Add("GENE", "General Motors");
|
|
codes.Add("GEO", "Geo");
|
|
codes.Add("GIBB", "Gibbs");
|
|
codes.Add("HOND", "Honda");
|
|
codes.Add("HYUN", "Hyundai");
|
|
codes.Add("INFI", "Infiniti");
|
|
codes.Add("ISUZ", "Isuzu");
|
|
codes.Add("JAGU", "Jaguar");
|
|
codes.Add("JEEP", "Jeep");
|
|
codes.Add("JENS", "Jensen");
|
|
codes.Add("KIA", "Kia");
|
|
codes.Add("LDV", "LDV");
|
|
codes.Add("LAND", "Land Rover");
|
|
codes.Add("LEXU", "Lexus");
|
|
codes.Add("LINC", "Lincoln");
|
|
codes.Add("LOTU", "Lotus");
|
|
codes.Add("MG R", "MG Rover");
|
|
codes.Add("MAZD", "Mazda");
|
|
codes.Add("MERB", "Mercedes");
|
|
codes.Add("MERC", "Mercury");
|
|
codes.Add("MINI", "Mini");
|
|
codes.Add("MITS", "Mitsubishi");
|
|
codes.Add("MORG", "Morgan");
|
|
codes.Add("NISS", "Nissan");
|
|
codes.Add("OLDS", "Oldsmobile");
|
|
codes.Add("OPEL", "Opel");
|
|
codes.Add("PEUG", "Peugeot");
|
|
codes.Add("PLYM", "Plymouth");
|
|
codes.Add("PONT", "Pontiac");
|
|
codes.Add("PORS", "Porsche");
|
|
codes.Add("RENA", "Renault");
|
|
codes.Add("ROLL", "Rolls Royce");
|
|
codes.Add("ROVE", "Rover");
|
|
codes.Add("SAAB", "Saab");
|
|
codes.Add("SATU", "Saturn");
|
|
codes.Add("SEAT", "Seat");
|
|
codes.Add("SKOD", "Skoda");
|
|
codes.Add("SMAR", "Smart");
|
|
codes.Add("SMIT", "Smith Electric Vehicles");
|
|
codes.Add("SSAN", "SsangYong (Syuk Cars)");
|
|
codes.Add("SUBA", "Subaru");
|
|
codes.Add("SUZU", "Suzuki");
|
|
codes.Add("TVR", "TVR");
|
|
codes.Add("TATA", "Tata");
|
|
codes.Add("TOYO", "Toyota");
|
|
codes.Add("VAUX", "Vauxhall");
|
|
codes.Add("VOLK", "Volkswagen");
|
|
codes.Add("VOLV", "Volvo");
|
|
*/
|
|
break;
|
|
case Sbm.ApplCodeType.VehicleServiceHistory:
|
|
/*
|
|
codes.Add("FMDSH", "Full main dealer service history");
|
|
codes.Add("FSH", "Full service history");
|
|
*/
|
|
break;
|
|
case Sbm.ApplCodeType.VehicleInsurance:
|
|
break;
|
|
}
|
|
return codes;
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
// I t e m s
|
|
//-------------------------------------------------------------------
|
|
// Item Data Interface.
|
|
public virtual bool CanUpdateItemData(ISbmUserOrganisationContext userContext, Sbm.ItemDataType itemDataType)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
public virtual bool DoUpdateItemData(ISbmUserOrganisationContext userContext, Sbm.ItemDataType itemDataType)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
public virtual bool CanRemoveItemData(ISbmUserOrganisationContext userContext, Sbm.ItemDataType itemDataType)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
// Update Log.
|
|
public virtual bool IsColumnChangeLogged(ISbmUserOrganisationContext userContext, SbmDbDfn.ColumnIdx column)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
// Item Events.
|
|
public virtual bool OnItemEvent(Sbm.ItemEvent itemEvent, Sbm.ItemType itemType, SysId id)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
// Allowed data component types.
|
|
//-------------------------------------------------------------------
|
|
// Supported Data Item Types.
|
|
// Supported affiliate types (all allowed by default).
|
|
public virtual bool AllowAffiliateType(Sbm.AffiliateType type)
|
|
{
|
|
return InstanceConfig.AllowAffiliateType(type, true);
|
|
}
|
|
// Supported Association types (all allowed by default).
|
|
public virtual bool AllowAssociationType(Sbm.AssociationType type)
|
|
{
|
|
return InstanceConfig.AllowAssociationType(type, true);
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
// D a t a O p t i o n s
|
|
//-------------------------------------------------------------------
|
|
// Application Configuration. - Display and caption for data attributes.
|
|
public virtual bool DisplayAttribute(SbmDbDfn.ColumnIdx column)
|
|
{
|
|
// Only need to intercept fields that are partnered with other fields to determine display.
|
|
switch (column)
|
|
{
|
|
// Commodity - specification.
|
|
case SbmDbDfn.ColumnIdx.Commodity_Weight:
|
|
case SbmDbDfn.ColumnIdx.Commodity_UomIdWeight:
|
|
return OrganisationConfig.GetOwnerOption_ShowField(SbmDbDfn.ColumnIdx.Commodity_Weight);
|
|
case SbmDbDfn.ColumnIdx.Commodity_Length:
|
|
case SbmDbDfn.ColumnIdx.Commodity_UomIdLength:
|
|
return OrganisationConfig.GetOwnerOption_ShowField(SbmDbDfn.ColumnIdx.Commodity_Length);
|
|
case SbmDbDfn.ColumnIdx.Commodity_Volume:
|
|
case SbmDbDfn.ColumnIdx.Commodity_UomIdVolume:
|
|
return OrganisationConfig.GetOwnerOption_ShowField(SbmDbDfn.ColumnIdx.Commodity_Volume);
|
|
case SbmDbDfn.ColumnIdx.Commodity_Density:
|
|
case SbmDbDfn.ColumnIdx.Commodity_UomIdDensity:
|
|
return OrganisationConfig.GetOwnerOption_ShowField(SbmDbDfn.ColumnIdx.Commodity_Density);
|
|
case SbmDbDfn.ColumnIdx.Commodity_BoxQuantity:
|
|
case SbmDbDfn.ColumnIdx.Commodity_UomIdBox:
|
|
return OrganisationConfig.GetOwnerOption_ShowField(SbmDbDfn.ColumnIdx.Commodity_BoxQuantity);
|
|
case SbmDbDfn.ColumnIdx.Commodity_TimeProd:
|
|
case SbmDbDfn.ColumnIdx.Commodity_UomIdTimeProd:
|
|
return OrganisationConfig.GetOwnerOption_ShowField(SbmDbDfn.ColumnIdx.Commodity_TimeProd);
|
|
case SbmDbDfn.ColumnIdx.Commodity_MaterialCost:
|
|
case SbmDbDfn.ColumnIdx.Commodity_CurrencyIdMaterial:
|
|
return OrganisationConfig.GetOwnerOption_ShowField(SbmDbDfn.ColumnIdx.Commodity_MaterialCost);
|
|
case SbmDbDfn.ColumnIdx.Commodity_ExWorksCost:
|
|
case SbmDbDfn.ColumnIdx.Commodity_CurrencyIdExWorks:
|
|
return OrganisationConfig.GetOwnerOption_ShowField(SbmDbDfn.ColumnIdx.Commodity_ExWorksCost);
|
|
case SbmDbDfn.ColumnIdx.Commodity_CommodityIdSalesProj:
|
|
case SbmDbDfn.ColumnIdx.Commodity_SalesProjMonthlyProp:
|
|
case SbmDbDfn.ColumnIdx.Commodity_SalesProjMonth01:
|
|
case SbmDbDfn.ColumnIdx.Commodity_SalesProjMonth02:
|
|
case SbmDbDfn.ColumnIdx.Commodity_SalesProjMonth03:
|
|
case SbmDbDfn.ColumnIdx.Commodity_SalesProjMonth04:
|
|
case SbmDbDfn.ColumnIdx.Commodity_SalesProjMonth05:
|
|
case SbmDbDfn.ColumnIdx.Commodity_SalesProjMonth06:
|
|
case SbmDbDfn.ColumnIdx.Commodity_SalesProjMonth07:
|
|
case SbmDbDfn.ColumnIdx.Commodity_SalesProjMonth08:
|
|
case SbmDbDfn.ColumnIdx.Commodity_SalesProjMonth09:
|
|
case SbmDbDfn.ColumnIdx.Commodity_SalesProjMonth10:
|
|
case SbmDbDfn.ColumnIdx.Commodity_SalesProjMonth11:
|
|
case SbmDbDfn.ColumnIdx.Commodity_SalesProjMonth12:
|
|
return OrganisationConfig.GetOwnerOption_ShowField(SbmDbDfn.ColumnIdx.Commodity_SalesProjAnnual);
|
|
default:
|
|
return OrganisationConfig.GetOwnerOption_ShowField(column);
|
|
}
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
// Alternative data value captions.
|
|
public virtual string GetAttributeCaption(SbmDbDfn.ColumnIdx column, string Default)
|
|
{
|
|
string Caption = "";
|
|
if (column != SbmDbDfn.ColumnIdx.Unknown)
|
|
{
|
|
Caption = OrganisationConfig.GetOwnerOption_FieldLabel(column, Default);
|
|
}
|
|
if (Caption.IsEmpty()) Caption = Default;
|
|
return Caption;
|
|
}
|
|
|
|
// To do - move to InstanceConfig.
|
|
// Job Tracking Options.
|
|
public virtual string GetDefaultQuoteDescIntro()
|
|
{
|
|
return "";
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
// C o m m o d i t y O p t i o n s
|
|
//-------------------------------------------------------------------
|
|
// Commodity Management.
|
|
public virtual Sbm.CommodityType GetCommodityTypeDefault(Sbm.OrgOption_CommodityType commodityType)
|
|
{
|
|
// Default = 'Stock'.
|
|
return Sbm.CommodityType.Stock;
|
|
}
|
|
|
|
// Clean-up imported data (default no action).
|
|
public virtual bool CleanupImportedCommodity(SbmCommodity commodity)
|
|
{
|
|
return true;
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
// Stock Control
|
|
public virtual SbmStockControlConfig GetStockControlConfig()
|
|
{
|
|
SbmStockControlConfig cfgStockControl = new SbmStockControlConfig();
|
|
return cfgStockControl;
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
// R e p o r t i n g
|
|
//-------------------------------------------------------------------
|
|
// Available reports (over and above standard).
|
|
public virtual List<SbmReport_Base> GetReports(Sbm.View view)
|
|
{
|
|
return new List<SbmReport_Base>();
|
|
}
|
|
public virtual bool ItemHasDiaryReports(ItemId itemId)
|
|
{
|
|
return false;
|
|
}
|
|
/*
|
|
public virtual List<SbmReport_Base> GetDiaryReports(ISbmUserContext userContext, SaDiaryReport_Params &)
|
|
{
|
|
return null;
|
|
}
|
|
public virtual List<SbmReport_Base> GetDiaryReportsForItem(ISbmUserContext userContext, ItemId itemId)
|
|
{
|
|
return null;
|
|
}
|
|
*/
|
|
|
|
//-------------------------------------------------------------------
|
|
// P r o c e s s e s
|
|
//-------------------------------------------------------------------
|
|
/// <summary>Processing parameters.</summary>
|
|
public enum ProcessParam
|
|
{
|
|
/// <summary>Dispatch Note report horizontal lines [Bool]</summary>
|
|
RptDispatchNoteHorizontalLines = 110,
|
|
/// <summary>Sales Invoice report horizontal lines [Bool]</summary>
|
|
RptSalesInvoiceHorizontalLines = 111,
|
|
}
|
|
public virtual DataValue GetDefaultProcessParam(ProcessParam prm)
|
|
{
|
|
switch (prm)
|
|
{
|
|
case ProcessParam.RptDispatchNoteHorizontalLines:
|
|
case ProcessParam.RptSalesInvoiceHorizontalLines:
|
|
return new DataValue(false);
|
|
}
|
|
return new DataValue();
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
// Automated processes.
|
|
public virtual bool PerformProcess(Sbm.ProcessType type)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
// Available data import/export processes (over and above standard).
|
|
public virtual List<ISbmProcess_DataImport> GetImportProcesses(Sbm.InterfaceDataType dataType, List<SysId> itemIds)
|
|
{
|
|
return new List<ISbmProcess_DataImport>();
|
|
}
|
|
|
|
public virtual List<ISbmProcess_DataExport> GetExportProcesses(Sbm.InterfaceDataType dataType, List<SysId> itemIds)
|
|
{
|
|
return new List<ISbmProcess_DataExport>();
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
// Data export Enhancements. eg. for export to accounts.
|
|
public class DataExportItemDetails
|
|
{
|
|
internal DataExportItemDetails(string itemCode, string itemDesc, string itemText)
|
|
{
|
|
ItemCode = itemCode;
|
|
ItemDesc = itemDesc;
|
|
ItemText = itemText;
|
|
}
|
|
public string ItemCode { get; }
|
|
public string ItemDesc { get; }
|
|
public string ItemText { get; }
|
|
};
|
|
public virtual DataExportItemDetails GetDataExportInvoiceItemDetails(SbmRequirement requirement)
|
|
{
|
|
return null;
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
// I n t e r f a c e O p t i o n s
|
|
//-------------------------------------------------------------------
|
|
public virtual bool AllowInterfaces()
|
|
{
|
|
if (AllowInterfaceCategory(SaInterfaceCategory.Website)) return true;
|
|
if (AllowInterfaceCategory(SaInterfaceCategory.Accounts)) return true;
|
|
if (AllowInterfaceCategory(SaInterfaceCategory.System)) return true;
|
|
if (AllowInterfaceCategory(SaInterfaceCategory.File)) return true;
|
|
return false;
|
|
}
|
|
|
|
public virtual bool AllowInterfaceCategory(SaInterfaceCategory interfaceCategory)
|
|
{
|
|
// By default, only website and file interfaces are allowed.
|
|
switch (interfaceCategory)
|
|
{
|
|
case SaInterfaceCategory.Website:
|
|
case SaInterfaceCategory.File:
|
|
return InstanceConfig.AllowInterfaceCategory(interfaceCategory, true);
|
|
}
|
|
return InstanceConfig.AllowInterfaceCategory(interfaceCategory, false);
|
|
}
|
|
|
|
public virtual bool AllowInterface(SaInterfaceCategory interfaceCategory, short interfaceType)
|
|
{
|
|
if (!AllowInterfaceCategory(interfaceCategory)) return false;
|
|
switch (interfaceCategory)
|
|
{
|
|
case SaInterfaceCategory.Website:
|
|
if (interfaceType == (short)Sbm.InterfaceType_Website.WebStore) return true;
|
|
if (interfaceType == (short)Sbm.InterfaceType_Website.JoomlaVirtueMart)
|
|
//return (SbmGlobals.Application.GetPropertyValue("Interface", "JoomlaVirtueMart").EqualsCI("Allow"));
|
|
return false;
|
|
break;
|
|
// Sbm.InterfaceType_Website.MiMoWeb - Only allowed by derived console.
|
|
case SaInterfaceCategory.Accounts:
|
|
if (interfaceType == (short)Sbm.InterfaceType_Accounts.SageLine50) return true;
|
|
// eSapInterfaceType_Accounts_QuickBooks - Only allowed by derived console.
|
|
break;
|
|
case SaInterfaceCategory.System:
|
|
if (interfaceType == (short)Sbm.InterfaceType_System.MSOutlook)
|
|
//return SbmGlobals.Application.GetPropertyValue("Interface", "MSOutlook").EqualsCI("Allow");
|
|
return false;
|
|
if (interfaceType == (short)Sbm.InterfaceType_System.PostcodeAnywhere)
|
|
//return SbmGlobals.Application.GetPropertyValue("Interface", "PostcodeAnywhere").EqualsCI("Allow");
|
|
return false;
|
|
if (interfaceType == (short)Sbm.InterfaceType_System.Bac)
|
|
//return SbmGlobals.Application.GetPropertyValue("Interface", "BacSystem").EqualsCI("Allow");
|
|
return false;
|
|
if (interfaceType == (short)Sbm.InterfaceType_System.Pvh)
|
|
//return SbmGlobals.Application.GetPropertyValue("Interface", "PracticalVanHireSystem").EqualsCI("Allow");
|
|
return false;
|
|
// Sbm.InterfaceType_System.Cap - Only allowed by derived console.
|
|
// Sbm.InterfaceType_System.Hpi - Only allowed by derived console.
|
|
break;
|
|
case SaInterfaceCategory.File:
|
|
if (AllowOption(Sbm.ConfigOption.Transactions))
|
|
{
|
|
if (interfaceType == (short)Sbm.InterfaceType_File.TransactionImport) return true;
|
|
if (interfaceType == (short)Sbm.InterfaceType_File.TransactionExport) return true;
|
|
if (interfaceType == (short)Sbm.InterfaceType_File.TransToWord_SalesQuote) return AllowTransactionType(Sbm.TransactionType.SalesQuote);
|
|
if (interfaceType == (short)Sbm.InterfaceType_File.TransToWord_SalesOrder) return AllowTransactionType(Sbm.TransactionType.ProformaSalesOrder) || AllowTransactionType(Sbm.TransactionType.SalesOrder);
|
|
if (interfaceType == (short)Sbm.InterfaceType_File.TransToWord_SalesDispatch) return AllowTransactionType(Sbm.TransactionType.SalesDispatch);
|
|
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.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.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.Vehicles);
|
|
if (interfaceType == (short)Sbm.InterfaceType_File.LeasewayInvoice)
|
|
//return SbmGlobals.Application.GetPropertyValue("Interface", "LeasewayInvoice").EqualsCI("Allow");
|
|
return false;
|
|
break;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
// Interface options.
|
|
public virtual List<SaItemOption> GetDefaultInterfaceOptions(InterfaceDfn interfaceDfn)
|
|
{
|
|
List<SaItemOption> options = new List<SaItemOption>();
|
|
//if (SbmGlobals.System != null) options = SbmGlobals.System.GetDefaultInterfaceOptions(interfaceDfn);
|
|
return options;
|
|
}
|
|
|
|
public virtual bool ProcessInterface(SaInterface saInterface)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
}
|
|
//=======================================================================
|
|
|
|
}
|