593 lines
32 KiB
C#
593 lines
32 KiB
C#
using Sarand.BusinessMgr.Net.Standard.Base.App;
|
|
using Sarand.BusinessMgr.Net.Standard.Base.Core;
|
|
using Sarand.Net.Standard.Accounts.Sage.App;
|
|
using Sarand.Net.Standard.Base.Bus;
|
|
using Sarand.Net.Standard.Base.CodeTypes;
|
|
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;
|
|
|
|
namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
|
|
{
|
|
//=======================================================================
|
|
// A c c o u n t s - S a g e
|
|
//=======================================================================
|
|
partial class SbmAccountsDfn
|
|
{
|
|
//-------------------------------------------------------------------
|
|
/// <summary>Sage Interface Item Options.</summary>
|
|
protected enum SageInterfaceOption
|
|
{
|
|
HostPc,
|
|
Flag,
|
|
Mode,
|
|
DataPath,
|
|
OdbcDsn,
|
|
User,
|
|
Pword,
|
|
ImportProcessItemType,
|
|
ExportProcessItemType,
|
|
TransactionImportMode,
|
|
UpdateLimitMonthsInPast,
|
|
PurchaseLedgerColumnSource,
|
|
SalesLedgerColumnSource,
|
|
StockCatAction,
|
|
StockColumnSource,
|
|
SalesOrderColumnSource,
|
|
DefaultSalesLocation,
|
|
TaxCodeColumn,
|
|
}
|
|
/// <summary>Interface configuration.</summary>
|
|
protected enum SageFlag
|
|
{
|
|
UseLocalCustomerPricing,
|
|
UseLocalSupplierPricing,
|
|
AllocateExportedOrders,
|
|
}
|
|
protected enum SageInterfaceDirection
|
|
{
|
|
Unknown = 0,
|
|
Import = 1,
|
|
Export,
|
|
}
|
|
protected enum SageInterfaceMode
|
|
{
|
|
Default = -1, // As defined by interface.
|
|
Unknown = 0,
|
|
Sage_Object = 1,
|
|
Odbc_Folder,
|
|
Odbc_Dsn,
|
|
File_Csv,
|
|
}
|
|
protected enum SageTransactionImportMode
|
|
{
|
|
Unknown = 0,
|
|
CreateNew = 1,
|
|
LoadOpen,
|
|
LoadOpenCreateComplete,
|
|
LoadOpenComplete,
|
|
Default = LoadOpen,
|
|
}
|
|
protected enum SagePurchaseLedgerColumnSource
|
|
{
|
|
Unknown = 0,
|
|
}
|
|
protected enum SageSalesLedgerColumnSource
|
|
{
|
|
Unknown = 0,
|
|
AccountManagerCode = SbmDbDfn.ColumnIdx.Association_AccountManagerCode,
|
|
AccountHandlerCode = SbmDbDfn.ColumnIdx.Association_AccountHandlerCode,
|
|
ContactAreaCode = SbmDbDfn.ColumnIdx.Association_ContactAreaCode,
|
|
ContactHandlerCode = SbmDbDfn.ColumnIdx.Association_ContactHandlerCode,
|
|
}
|
|
protected enum SageStockCategoryAction
|
|
{
|
|
Unknown = 0,
|
|
ObsoleteStatus = 10,
|
|
}
|
|
protected enum SageStockColumnSource
|
|
{
|
|
Unknown = 0,
|
|
Dimensions = SbmDbDfn.ColumnIdx.Commodity_Dimensions,
|
|
RetailPrice = SbmDbDfn.ColumnIdx.Commodity_RetailPrice,
|
|
Volume = SbmDbDfn.ColumnIdx.Commodity_Volume,
|
|
BoxQuantity = SbmDbDfn.ColumnIdx.Commodity_BoxQuantity,
|
|
}
|
|
protected enum SageSalesOrderColumnSource
|
|
{
|
|
Unknown = 0,
|
|
DeliveryAddress_ContactAreaCode = 10,
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
// Sage Line 50 accounts.
|
|
private class SageStatics
|
|
{
|
|
// Code lists.
|
|
public List<TypeCodeDesc> InterfaceOptions { get; } = new List<TypeCodeDesc>();
|
|
public List<TypeCodeDesc> OptionContexts_InterfaceDirection { get; } = new List<TypeCodeDesc>();
|
|
public List<TypeCodeDesc> OptionValues_Flag { get; } = new List<TypeCodeDesc>();
|
|
public List<TypeCodeDesc> OptionValues_InterfaceModes { get; } = new List<TypeCodeDesc>();
|
|
public List<TypeCodeDesc> TransactionImportModes { get; } = new List<TypeCodeDesc>();
|
|
public List<TypeCodeDesc> PurchaseLedgerColumnSources { get; } = new List<TypeCodeDesc>();
|
|
public List<TypeCodeDesc> SalesLedgerColumnSources { get; } = new List<TypeCodeDesc>();
|
|
public List<TypeCodeDesc> StockCategoryActions { get; } = new List<TypeCodeDesc>();
|
|
public List<TypeCodeDesc> StockColumnSources { get; } = new List<TypeCodeDesc>();
|
|
public List<TypeCodeDesc> SalesOrderColumnSources { get; } = new List<TypeCodeDesc>();
|
|
public SageStatics()
|
|
{
|
|
// Interface Options.
|
|
InterfaceOptions.Add(SageInterfaceOption.HostPc, "HostPC", "Host PC");
|
|
InterfaceOptions.Add(SageInterfaceOption.Flag, "Flag", "Flag");
|
|
InterfaceOptions.Add(SageInterfaceOption.Mode, "SageIntMode", "Interface mode");
|
|
InterfaceOptions.Add(SageInterfaceOption.DataPath, "SageData", "Data path (AccData)");
|
|
InterfaceOptions.Add(SageInterfaceOption.OdbcDsn, "SageDsn", "ODBC DSN");
|
|
InterfaceOptions.Add(SageInterfaceOption.User, "SageUser", "Sage user");
|
|
InterfaceOptions.Add(SageInterfaceOption.Pword, "SagePword", "Sage password");
|
|
InterfaceOptions.Add(SageInterfaceOption.ImportProcessItemType, "SageImportData", "Items to import");
|
|
InterfaceOptions.Add(SageInterfaceOption.ExportProcessItemType, "SageExportData", "Items to export");
|
|
InterfaceOptions.Add(SageInterfaceOption.TransactionImportMode, "SageTransImport", "Transaction import mode");
|
|
InterfaceOptions.Add(SageInterfaceOption.UpdateLimitMonthsInPast, "UpdMthsPast", "Update limit - months in past");
|
|
InterfaceOptions.Add(SageInterfaceOption.PurchaseLedgerColumnSource, "PurchaseLedgerColSource", "Purchase ledger column source");
|
|
InterfaceOptions.Add(SageInterfaceOption.SalesLedgerColumnSource, "SalesLedgerColSource", "Sales ledger column source");
|
|
InterfaceOptions.Add(SageInterfaceOption.StockCatAction, "SageStkCatAct", "Stock cagetory action");
|
|
InterfaceOptions.Add(SageInterfaceOption.StockColumnSource, "StockColSource", "Stock column source");
|
|
InterfaceOptions.Add(SageInterfaceOption.SalesOrderColumnSource, "SalesOrderColSource", "Sales order column source");
|
|
InterfaceOptions.Add(SageInterfaceOption.DefaultSalesLocation, "DefSalesLoc", "Default sales location");
|
|
InterfaceOptions.Add(SageInterfaceOption.TaxCodeColumn, "TaxCodeCol", "Equivalent tax code column", "To convert tax codes between systems.");
|
|
// Interface Directions.
|
|
OptionContexts_InterfaceDirection.Add(SageInterfaceDirection.Import, "Import", "Import from Sage");
|
|
OptionContexts_InterfaceDirection.Add(SageInterfaceDirection.Export, "Export", "Export to Sage");
|
|
// Flags.
|
|
OptionValues_Flag.Add(SageFlag.UseLocalCustomerPricing, "LocalCustPricing", "Use local customer pricing", "Do not import: Price sets; Customer price set and discount rates");
|
|
OptionValues_Flag.Add(SageFlag.UseLocalSupplierPricing, "LocalSuppPricing", "Use local supplier pricing", "Do not import: Price sets; supplier price set and discount rates");
|
|
OptionValues_Flag.Add(SageFlag.AllocateExportedOrders, "AllocExpOrders", "Automatically allocate exported orders");
|
|
// Sage Interface Mode.
|
|
OptionValues_InterfaceModes.Add(SageInterfaceMode.Sage_Object, "SageObject", "Sage - object");
|
|
OptionValues_InterfaceModes.Add(SageInterfaceMode.Odbc_Folder, "OdbcFolder", "ODBC - folder");
|
|
OptionValues_InterfaceModes.Add(SageInterfaceMode.Odbc_Dsn, "OdbcDsn", "ODBC - DSN");
|
|
OptionValues_InterfaceModes.Add(SageInterfaceMode.File_Csv, "FileCsv", "File - csv");
|
|
// Import Transaction.
|
|
TransactionImportModes.Add(SageTransactionImportMode.CreateNew, "CrNew", "Create new only");
|
|
TransactionImportModes.Add(SageTransactionImportMode.LoadOpen, "LdOpn", "Load open only");
|
|
TransactionImportModes.Add(SageTransactionImportMode.LoadOpenCreateComplete, "LdOpnCrCom", "Load open & create complete");
|
|
TransactionImportModes.Add(SageTransactionImportMode.LoadOpenComplete, "LcOpnCom", "Load open and complete");
|
|
// Purchase Ledger Column Source.
|
|
// Sales Ledger Column Source.
|
|
SalesLedgerColumnSources.Add(SageSalesLedgerColumnSource.AccountManagerCode, SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Association_AccountManagerCode, "", true), "Account manager");
|
|
SalesLedgerColumnSources.Add(SageSalesLedgerColumnSource.AccountHandlerCode, SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Association_AccountHandlerCode, "", true), "Account handler");
|
|
SalesLedgerColumnSources.Add(SageSalesLedgerColumnSource.ContactAreaCode, SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Association_ContactAreaCode, "", true), "Contact area");
|
|
SalesLedgerColumnSources.Add(SageSalesLedgerColumnSource.ContactHandlerCode, SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Association_ContactHandlerCode, "", true), "Contact handler");
|
|
// Stock Category Action.
|
|
StockCategoryActions.Add(SageStockCategoryAction.ObsoleteStatus, "StatObs", "Set status to 'obsolete'");
|
|
// Stock Column Source.
|
|
// NB Changes to this list should also be applied to SapAccountsDfn::GetSageColumn().
|
|
StockColumnSources.Add(SageStockColumnSource.Dimensions, SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Commodity_Dimensions, "", true), "Dimensions");
|
|
StockColumnSources.Add(SageStockColumnSource.RetailPrice, SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Commodity_RetailPrice, "", true), "Retail price");
|
|
StockColumnSources.Add(SageStockColumnSource.Volume, SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Commodity_Volume, "", true), "Volume");
|
|
StockColumnSources.Add(SageStockColumnSource.BoxQuantity, SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Commodity_BoxQuantity, "", true), "Box quantity");
|
|
// Sales Order Column Source.
|
|
SalesOrderColumnSources.Add(SageSalesOrderColumnSource.DeliveryAddress_ContactAreaCode, SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Address_ContactAreaCode, "", true), "Delivery area code");
|
|
}
|
|
}
|
|
private class SageParams
|
|
{
|
|
public SageParams(ISbmUserContext userContext, SbmInternals internals)
|
|
{
|
|
UserContext = userContext;
|
|
this.internals = internals;
|
|
// Data types.
|
|
// NB Don't change the codes - these are used on the database:
|
|
DataTypes.Add(Sage.ItemType.Customer, "CUST", "Customers");
|
|
DataTypes.Add(Sage.ItemType.Supplier, "SUPP", "Suppliers");
|
|
DataTypes.Add(Sage.ItemType.Product, "PROD", "Products");
|
|
DataTypes.Add(Sage.ItemType.PriceList, "PRCLST", "Pricing");
|
|
DataTypes.Add(Sage.ItemType.StockLevel, "STKLVL", "Stock levels");
|
|
DataTypes.Add(Sage.ItemType.StockTake, "STKTAK", "Stock takes");
|
|
DataTypes.Add(Sage.ItemType.StockBom, "STKBOM", "Stock BOM");
|
|
DataTypes.Add(Sage.ItemType.StockCategory, "STKCAT", "Stock categories");
|
|
DataTypes.Add(Sage.ItemType.StockTransfer, "STKTRA", "Stock transfers");
|
|
DataTypes.Add(Sage.ItemType.PurchaseOrder, "PURO", "Purchase orders");
|
|
DataTypes.Add(Sage.ItemType.PopItemAllocation, "PURALL", "POP allocations");
|
|
DataTypes.Add(Sage.ItemType.SalesOrder, "SALO", "Sales orders");
|
|
DataTypes.Add(Sage.ItemType.SopItemAllocation, "SALALL", "SOP allocations");
|
|
DataTypes.Add(Sage.ItemType.Invoice_Product, "INVPRD", "Product invoice");
|
|
DataTypes.Add(Sage.ItemType.Invoice_Product_Allocation, "PRIALL", "Product invoice allocation");
|
|
DataTypes.Add(Sage.ItemType.Invoice_SalesOrder, "INVSAL", "Sales order invoice");
|
|
DataTypes.Add(Sage.ItemType.Invoice_Service, "INVSRV", "Service invoice");
|
|
DataTypes.Add(Sage.ItemType.Invoice_Service_Allocation, "SRIALL", "Service invoice allocation");
|
|
DataTypes.Add(Sage.ItemType.InvoiceItem, "INVITM", "Invoice item");
|
|
// Item types - import.
|
|
Contexts_ImportItemType.Add(DataTypes.GetCodeDescForType(Sage.ItemType.Customer));
|
|
Contexts_ImportItemType.Add(DataTypes.GetCodeDescForType(Sage.ItemType.Supplier));
|
|
Contexts_ImportItemType.Add(DataTypes.GetCodeDescForType(Sage.ItemType.Product));
|
|
Contexts_ImportItemType.Add(DataTypes.GetCodeDescForType(Sage.ItemType.PriceList));
|
|
Contexts_ImportItemType.Add(DataTypes.GetCodeDescForType(Sage.ItemType.StockTake));
|
|
Contexts_ImportItemType.Add(DataTypes.GetCodeDescForType(Sage.ItemType.PurchaseOrder));
|
|
//Contexts_ImportItemType.Add(DataTypes.GetCodeDescForType(Sage.ItemType.PopItemAllocation));
|
|
Contexts_ImportItemType.Add(DataTypes.GetCodeDescForType(Sage.ItemType.SalesOrder));
|
|
Contexts_ImportItemType.Add(DataTypes.GetCodeDescForType(Sage.ItemType.SopItemAllocation));
|
|
Contexts_ImportItemType.Add(DataTypes.GetCodeDescForType(Sage.ItemType.Invoice_Product));
|
|
Contexts_ImportItemType.Add(DataTypes.GetCodeDescForType(Sage.ItemType.Invoice_Product_Allocation));
|
|
// Item types - export.
|
|
Contexts_ExportItemType.Add(DataTypes.GetCodeDescForType(Sage.ItemType.Product));
|
|
Contexts_ExportItemType.Add(DataTypes.GetCodeDescForType(Sage.ItemType.StockLevel));
|
|
Contexts_ExportItemType.Add(DataTypes.GetCodeDescForType(Sage.ItemType.PurchaseOrder));
|
|
Contexts_ExportItemType.Add(DataTypes.GetCodeDescForType(Sage.ItemType.SalesOrder));
|
|
Contexts_ExportItemType.Add(DataTypes.GetCodeDescForType(Sage.ItemType.Invoice_Product));
|
|
Contexts_ExportItemType.Add(DataTypes.GetCodeDescForType(Sage.ItemType.Invoice_Service));
|
|
Contexts_ExportItemType.Add(DataTypes.GetCodeDescForType(Sage.ItemType.Invoice_SalesOrder));
|
|
// Transaction types - import.
|
|
Contexts_ImportTransactionTypes.Add(DataTypes.GetCodeDescForType(Sage.ItemType.PurchaseOrder));
|
|
Contexts_ImportTransactionTypes.Add(DataTypes.GetCodeDescForType(Sage.ItemType.SalesOrder));
|
|
Contexts_ImportTransactionTypes.Add(DataTypes.GetCodeDescForType(Sage.ItemType.Invoice_Product));
|
|
// Update limit months past.
|
|
Contexts_UpdateLimitMonthsPast.Add(DataTypes.GetCodeDescForType(Sage.ItemType.StockTake));
|
|
Contexts_UpdateLimitMonthsPast.Add(DataTypes.GetCodeDescForType(Sage.ItemType.PurchaseOrder));
|
|
Contexts_UpdateLimitMonthsPast.Add(DataTypes.GetCodeDescForType(Sage.ItemType.SalesOrder));
|
|
Contexts_UpdateLimitMonthsPast.Add(DataTypes.GetCodeDescForType(Sage.ItemType.Invoice_Product));
|
|
// Purchase Ledger Column Sources.
|
|
PurchaseLedgerColumnSources.Add("", "");
|
|
PurchaseLedgerColumnSources.Add(SageDbDfn.GetColumnName(SageDbDfn.ColumnIdx.PurchaseLedger_Analysis1), "Analysis 1");
|
|
PurchaseLedgerColumnSources.Add(SageDbDfn.GetColumnName(SageDbDfn.ColumnIdx.PurchaseLedger_Analysis2), "Analysis 2");
|
|
PurchaseLedgerColumnSources.Add(SageDbDfn.GetColumnName(SageDbDfn.ColumnIdx.PurchaseLedger_Analysis3), "Analysis 3");
|
|
// Sales Ledger Column Sources.
|
|
SalesLedgerColumnSources.Add("", "");
|
|
SalesLedgerColumnSources.Add(SageDbDfn.GetColumnName(SageDbDfn.ColumnIdx.SalesLedger_Analysis1), "Analysis 1");
|
|
SalesLedgerColumnSources.Add(SageDbDfn.GetColumnName(SageDbDfn.ColumnIdx.SalesLedger_Analysis2), "Analysis 2");
|
|
SalesLedgerColumnSources.Add(SageDbDfn.GetColumnName(SageDbDfn.ColumnIdx.SalesLedger_Analysis3), "Analysis 3");
|
|
// Stock column sources.
|
|
StockColumnSources.Add("", "");
|
|
StockColumnSources.Add(SageDbDfn.GetColumnName(SageDbDfn.ColumnIdx.Stock_Location), "Location");
|
|
StockColumnSources.Add(SageDbDfn.GetColumnName(SageDbDfn.ColumnIdx.Stock_WebCategory1), "Web category 1");
|
|
StockColumnSources.Add(SageDbDfn.GetColumnName(SageDbDfn.ColumnIdx.Stock_WebCategory2), "Web category 2");
|
|
StockColumnSources.Add(SageDbDfn.GetColumnName(SageDbDfn.ColumnIdx.Stock_WebCategory3), "Web category 3");
|
|
// Sales Order column sources.
|
|
SalesOrderColumnSources.Add(SageDbDfn.GetColumnName(SageDbDfn.ColumnIdx.SalesOrder_Notes1), "Notes line 1");
|
|
}
|
|
//---------------------------------------------------------------
|
|
private ISbmUserContext UserContext { get; }
|
|
private readonly SbmInternals internals;
|
|
// Sage interface definitions.
|
|
public SaInterface.Data dfnInt_Sage { get; set; } = new SaInterface.Data();
|
|
public SysId InterfaceId { get { return dfnInt_Sage != null ? dfnInt_Sage.Id : new SysId(); } }
|
|
//public SaSageConsole SageCon { get; set; }
|
|
//public SaSageDataObjectConsole SageSdoCon { get; set; };
|
|
public List<SaItemOption> ItemOptions { get; } = new List<SaItemOption>();
|
|
public List<TypeCodeDesc> DataTypes { get; } = new List<TypeCodeDesc>();
|
|
/// <summary>Item Option Contexts - Item types - import.</summary>
|
|
public List<CodeDesc> Contexts_ImportItemType { get; } = new List<CodeDesc>();
|
|
/// <summary>Item Option Contexts - Item types - export.</summary>
|
|
public List<CodeDesc> Contexts_ExportItemType { get; } = new List<CodeDesc>();
|
|
/// <summary>Item Option Contexts - Transaction types - import.</summary>
|
|
public List<CodeDesc> Contexts_ImportTransactionTypes { get; } = new List<CodeDesc>();
|
|
/// <summary>Item Option Contexts - Update limit months past.</summary>
|
|
public List<CodeDesc> Contexts_UpdateLimitMonthsPast { get; } = new List<CodeDesc>();
|
|
// Purchase Ledger Column Sources.
|
|
public List<CodeDesc> PurchaseLedgerColumnSources { get; } = new List<CodeDesc>();
|
|
// Sales Ledger Column Sources.
|
|
public List<CodeDesc> SalesLedgerColumnSources { get; } = new List<CodeDesc>();
|
|
// Stock category actions.
|
|
private List<CodeDesc> codes_StockCategoryAction = null;
|
|
private List<CodeDesc> contexts_StockCategoryAction = null;
|
|
public List<CodeDesc> Contexts_StockCategoryAction
|
|
{
|
|
get
|
|
{
|
|
if (contexts_StockCategoryAction == null)
|
|
{
|
|
// Only populated when needed as reads Code Types from db.
|
|
contexts_StockCategoryAction = new List<CodeDesc>();
|
|
using (SaCodeTypeConsole codeTypeConsole = SbmGlobals.Application.CreateCodeTypeConsole(UserContext))
|
|
{
|
|
codes_StockCategoryAction = codeTypeConsole.GetCodeDescsForCodeType(SbmSystem.GetCodeTypeCode(Sbm.ApplCodeType.CommodityCategory));
|
|
foreach (CodeDesc commodityCategory in codes_StockCategoryAction)
|
|
{
|
|
// Ignore categories where code is same as description.
|
|
// We're only interested in the ones which have been given a description.
|
|
if (commodityCategory.Code.EqualsCI(commodityCategory.Desc)) continue;
|
|
contexts_StockCategoryAction.Add(commodityCategory);
|
|
}
|
|
}
|
|
}
|
|
return new List<CodeDesc>(contexts_StockCategoryAction);
|
|
}
|
|
}
|
|
// Stock column sources.
|
|
public List<CodeDesc> StockColumnSources { get; } = new List<CodeDesc>();
|
|
// Sales Order column sources.
|
|
public List<CodeDesc> SalesOrderColumnSources { get; } = new List<CodeDesc>();
|
|
// Sales Locations.
|
|
public List<CodeDesc> salesLocations = null;
|
|
public List<CodeDesc> SalesLocations
|
|
{
|
|
get
|
|
{
|
|
if (salesLocations == null)
|
|
{
|
|
// Populate locations - only done when needed to avoid db I/O.
|
|
salesLocations = new List<CodeDesc>();
|
|
SbmLocation.Params prmLocation = new SbmLocation.Params();
|
|
prmLocation.LocationCategory = Sbm.LocationCategory.Stock;
|
|
prmLocation.RestrictToSalesStock = true;
|
|
prmLocation.StatusCat = SbmLocation.StatusCat.ActiveOnly;
|
|
foreach (SbmLocation location in internals.StockMgr.GetLocationList(prmLocation))
|
|
salesLocations.Add(SysId.ToString(location.Id), location.Name);
|
|
}
|
|
return new List<CodeDesc>(salesLocations);
|
|
}
|
|
}
|
|
// Sage interface properties.
|
|
public String ImageFolder { get; set; } = "";
|
|
public bool ImageFolderVerified { get; set; } = false;
|
|
};
|
|
|
|
//-------------------------------------------------------------------
|
|
// Data members.
|
|
// Interfce item option contexts.
|
|
private static readonly SageStatics sageStatics = new SageStatics();
|
|
private readonly SageParams sageParams;
|
|
// ToDo Duplicate of SageParams.DataTypes
|
|
private static List<TypeCodeDesc> DataTypes_Sage { get; } = new List<TypeCodeDesc>();
|
|
|
|
//-------------------------------------------------------------------
|
|
// Static intiialisation.
|
|
private static void InitialiseStatics_SageLine50()
|
|
{
|
|
// Sage item types.
|
|
DataTypes_Sage.AddRange(SageConsole.ItemTypeCodes);
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
// O p t i o n s
|
|
//-------------------------------------------------------------------
|
|
public void InitSageInterfaceOptions()
|
|
{
|
|
if (sageParams.ItemOptions.Count == 0 && SysId.IsValid(sageParams.InterfaceId))
|
|
sageParams.ItemOptions.AddRange(ItemOptionConsole.GetItemOptionsForItem(new ItemId((short)Sbm.ItemType.Interface, sageParams.InterfaceId)));
|
|
}
|
|
protected String GetSageOptionValue(SageInterfaceOption option, String context)
|
|
{
|
|
return GetSageOptionValue(sageStatics.InterfaceOptions.GetCodeForType(option), context);
|
|
}
|
|
protected String GetSageOptionValue(String name, String context)
|
|
{
|
|
InitSageInterfaceOptions();
|
|
return sageParams.ItemOptions.GetOptionValue(name, context);
|
|
}
|
|
public bool GetSageImportOption(Sage.ItemType itemType)
|
|
{
|
|
return StringUtil.ToBool(GetSageOptionValue(SageInterfaceOption.ImportProcessItemType, SbmAccountsDfn.GetCodeForSageItemType(itemType)));
|
|
}
|
|
public bool GetSageExportOption(Sage.ItemType itemType)
|
|
{
|
|
return StringUtil.ToBool(GetSageOptionValue(SageInterfaceOption.ExportProcessItemType, SbmAccountsDfn.GetCodeForSageItemType(itemType)));
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
// I n t e r f a c e I t e m O p t i o n s
|
|
//-------------------------------------------------------------------
|
|
public List<SaItemOptionDfn> GetInterfaceItemOptionDfns_SageLine50()
|
|
{
|
|
List<SaItemOptionDfn> interfaceItemOptionDfns = new List<SaItemOptionDfn>();
|
|
SaItemOptionDfn itemOption = null;
|
|
|
|
// Host PC.
|
|
itemOption = new SaItemOptionDfn();
|
|
itemOption.DisplayOptions.Group = OptionGroup_Process;
|
|
itemOption.Name = sageStatics.InterfaceOptions.GetCodeForType(SageInterfaceOption.HostPc);
|
|
itemOption.DisplayOptions.Caption = sageStatics.InterfaceOptions.GetDescForType(SageInterfaceOption.HostPc);
|
|
interfaceItemOptionDfns.Add(itemOption);
|
|
|
|
// Flags.
|
|
itemOption = new SaItemOptionDfn();
|
|
itemOption.DisplayOptions.Group = OptionGroup_Data;
|
|
itemOption.Name = sageStatics.InterfaceOptions.GetCodeForType(SageInterfaceOption.Flag);
|
|
itemOption.DisplayOptions.Caption = sageStatics.InterfaceOptions.GetDescForType(SageInterfaceOption.Flag);
|
|
itemOption.DisplayOptions.Contexts.AddRange(sageStatics.OptionValues_Flag);
|
|
itemOption.DisplayOptions.Values.AddRange(Sbm.ValuesYesNo);
|
|
itemOption.DisplayOptions.RequiresContext = true;
|
|
itemOption.DisplayOptions.NonDisplayTemplate = true;
|
|
itemOption.DisplayOptions.CanAddOption = true;
|
|
itemOption.DisplayOptions.CanRemoveOption = true;
|
|
interfaceItemOptionDfns.Add(itemOption);
|
|
|
|
// Mode.
|
|
itemOption = new SaItemOptionDfn();
|
|
itemOption.DisplayOptions.Group = OptionGroup_Sage;
|
|
itemOption.Name = sageStatics.InterfaceOptions.GetCodeForType(SageInterfaceOption.Mode);
|
|
itemOption.DisplayOptions.Caption = sageStatics.InterfaceOptions.GetDescForType(SageInterfaceOption.Mode);
|
|
itemOption.DisplayOptions.Contexts.AddRange(sageStatics.OptionContexts_InterfaceDirection);
|
|
itemOption.DisplayOptions.Values.AddRange(sageStatics.OptionValues_InterfaceModes);
|
|
itemOption.DefaultValue = sageStatics.OptionValues_InterfaceModes.GetCodeForType(SageInterfaceMode.Odbc_Folder);
|
|
itemOption.DisplayOptions.RequiresContext = true;
|
|
itemOption.DisplayOptions.PopulateWithContext = true;
|
|
interfaceItemOptionDfns.Add(itemOption);
|
|
|
|
// Data Path.
|
|
itemOption = new SaItemOptionDfn();
|
|
itemOption.DisplayOptions.Group = OptionGroup_Sage;
|
|
itemOption.Name = sageStatics.InterfaceOptions.GetCodeForType(SageInterfaceOption.DataPath);
|
|
itemOption.DisplayOptions.Caption = sageStatics.InterfaceOptions.GetDescForType(SageInterfaceOption.DataPath);
|
|
interfaceItemOptionDfns.Add(itemOption);
|
|
|
|
// Odbc Dsn.
|
|
itemOption = new SaItemOptionDfn();
|
|
itemOption.DisplayOptions.Group = OptionGroup_Sage;
|
|
itemOption.Name = sageStatics.InterfaceOptions.GetCodeForType(SageInterfaceOption.OdbcDsn);
|
|
itemOption.DisplayOptions.Caption = sageStatics.InterfaceOptions.GetDescForType(SageInterfaceOption.OdbcDsn);
|
|
interfaceItemOptionDfns.Add(itemOption);
|
|
|
|
// User.
|
|
itemOption = new SaItemOptionDfn();
|
|
itemOption.DisplayOptions.Group = OptionGroup_Sage;
|
|
itemOption.Name = sageStatics.InterfaceOptions.GetCodeForType(SageInterfaceOption.User);
|
|
itemOption.DisplayOptions.Caption = sageStatics.InterfaceOptions.GetDescForType(SageInterfaceOption.User);
|
|
interfaceItemOptionDfns.Add(itemOption);
|
|
|
|
// Password.
|
|
itemOption = new SaItemOptionDfn();
|
|
itemOption.DisplayOptions.Group = OptionGroup_Sage;
|
|
itemOption.Name = sageStatics.InterfaceOptions.GetCodeForType(SageInterfaceOption.Pword);
|
|
itemOption.DisplayOptions.Caption = sageStatics.InterfaceOptions.GetDescForType(SageInterfaceOption.Pword);
|
|
itemOption.DisplayOptions.Password = true;
|
|
itemOption.DisplayOptions.Encrypted = true;
|
|
interfaceItemOptionDfns.Add(itemOption);
|
|
|
|
// Import Process Item Types.
|
|
itemOption = new SaItemOptionDfn();
|
|
itemOption.DisplayOptions.Group = OptionGroup_Data;
|
|
itemOption.Name = sageStatics.InterfaceOptions.GetCodeForType(SageInterfaceOption.ImportProcessItemType);
|
|
itemOption.DisplayOptions.Caption = sageStatics.InterfaceOptions.GetDescForType(SageInterfaceOption.ImportProcessItemType);
|
|
itemOption.DisplayOptions.Contexts.AddRange(sageParams.Contexts_ImportItemType);
|
|
itemOption.DisplayOptions.Values.AddRange(Sbm.ValuesYesNo);
|
|
itemOption.DefaultValue = Sbm.ValueNo;
|
|
itemOption.DisplayOptions.RequiresContext = true;
|
|
itemOption.DisplayOptions.NonDisplayTemplate = true;
|
|
itemOption.DisplayOptions.CanAddOption = true;
|
|
itemOption.DisplayOptions.CanRemoveOption = true;
|
|
interfaceItemOptionDfns.Add(itemOption);
|
|
|
|
// Export Process Item Types.
|
|
itemOption = new SaItemOptionDfn();
|
|
itemOption.DisplayOptions.Group = OptionGroup_Data;
|
|
itemOption.Name = sageStatics.InterfaceOptions.GetCodeForType(SageInterfaceOption.ExportProcessItemType);
|
|
itemOption.DisplayOptions.Caption = sageStatics.InterfaceOptions.GetDescForType(SageInterfaceOption.ExportProcessItemType);
|
|
itemOption.DisplayOptions.Contexts.AddRange(sageParams.Contexts_ExportItemType);
|
|
itemOption.DisplayOptions.Values.AddRange(Sbm.ValuesYesNo);
|
|
itemOption.DefaultValue = Sbm.ValueNo;
|
|
itemOption.DisplayOptions.RequiresContext = true;
|
|
itemOption.DisplayOptions.NonDisplayTemplate = true;
|
|
itemOption.DisplayOptions.CanAddOption = true;
|
|
itemOption.DisplayOptions.CanRemoveOption = true;
|
|
interfaceItemOptionDfns.Add(itemOption);
|
|
|
|
// Transaction import modes.
|
|
itemOption = new SaItemOptionDfn();
|
|
itemOption.DisplayOptions.Group = OptionGroup_Data;
|
|
itemOption.Name = sageStatics.InterfaceOptions.GetCodeForType(SageInterfaceOption.TransactionImportMode);
|
|
itemOption.DisplayOptions.Caption = sageStatics.InterfaceOptions.GetDescForType(SageInterfaceOption.TransactionImportMode);
|
|
itemOption.DisplayOptions.Contexts.AddRange(sageParams.Contexts_ImportTransactionTypes);
|
|
itemOption.DisplayOptions.Values.AddRange(sageStatics.TransactionImportModes);
|
|
itemOption.DefaultValue = sageStatics.TransactionImportModes.GetCodeForType(SageTransactionImportMode.Default);
|
|
itemOption.DefaultNotes = "Value is reset after each import";
|
|
itemOption.DisplayOptions.RequiresContext = true;
|
|
itemOption.DisplayOptions.PopulateWithContext = true;
|
|
//itemOption.DisplayOptions.NonDisplayTemplate = true;
|
|
//itemOption.DisplayOptions.CanAddOption = true;
|
|
//itemOption.DisplayOptions.CanRemoveOption = true;
|
|
interfaceItemOptionDfns.Add(itemOption);
|
|
|
|
// Update Limit Months In Past.
|
|
itemOption = new SaItemOptionDfn();
|
|
itemOption.DisplayOptions.Group = OptionGroup_Data;
|
|
itemOption.Name = sageStatics.InterfaceOptions.GetCodeForType(SageInterfaceOption.UpdateLimitMonthsInPast);
|
|
itemOption.DisplayOptions.Caption = sageStatics.InterfaceOptions.GetDescForType(SageInterfaceOption.UpdateLimitMonthsInPast);
|
|
itemOption.DisplayOptions.Contexts.AddRange(sageParams.Contexts_UpdateLimitMonthsPast);
|
|
itemOption.DefaultValue = "3";
|
|
itemOption.DisplayOptions.MinValue = 1.0m;
|
|
itemOption.DisplayOptions.MaxValue = 36.0m;
|
|
itemOption.DisplayOptions.Numeric = true;
|
|
itemOption.DisplayOptions.RequiresContext = true;
|
|
itemOption.DisplayOptions.PopulateWithContext = true;
|
|
//itemOption.DisplayOptions.NonDisplayTemplate = true;
|
|
//itemOption.DisplayOptions.CanAddOption = true;
|
|
//itemOption.DisplayOptions.CanRemoveOption = true;
|
|
interfaceItemOptionDfns.Add(itemOption);
|
|
|
|
// Purchase Ledger Column Source.
|
|
itemOption = new SaItemOptionDfn();
|
|
itemOption.DisplayOptions.Group = OptionGroup_Data;
|
|
itemOption.Name = sageStatics.InterfaceOptions.GetCodeForType(SageInterfaceOption.PurchaseLedgerColumnSource);
|
|
itemOption.DisplayOptions.Caption = sageStatics.InterfaceOptions.GetDescForType(SageInterfaceOption.PurchaseLedgerColumnSource);
|
|
itemOption.DisplayOptions.Contexts.AddRange(sageStatics.PurchaseLedgerColumnSources);
|
|
itemOption.DisplayOptions.Values.AddRange(sageParams.PurchaseLedgerColumnSources);
|
|
itemOption.DisplayOptions.RequiresContext = true;
|
|
itemOption.DisplayOptions.NonDisplayTemplate = true;
|
|
itemOption.DisplayOptions.CanAddOption = true;
|
|
itemOption.DisplayOptions.CanRemoveOption = true;
|
|
interfaceItemOptionDfns.Add(itemOption);
|
|
|
|
// Sales Ledger Column Source.
|
|
itemOption = new SaItemOptionDfn();
|
|
itemOption.DisplayOptions.Group = OptionGroup_Data;
|
|
itemOption.Name = sageStatics.InterfaceOptions.GetCodeForType(SageInterfaceOption.SalesLedgerColumnSource);
|
|
itemOption.DisplayOptions.Caption = sageStatics.InterfaceOptions.GetDescForType(SageInterfaceOption.SalesLedgerColumnSource);
|
|
itemOption.DisplayOptions.Contexts.AddRange(sageStatics.SalesLedgerColumnSources);
|
|
itemOption.DisplayOptions.Values.AddRange(sageParams.SalesLedgerColumnSources);
|
|
itemOption.DisplayOptions.RequiresContext = true;
|
|
itemOption.DisplayOptions.NonDisplayTemplate = true;
|
|
itemOption.DisplayOptions.CanAddOption = true;
|
|
itemOption.DisplayOptions.CanRemoveOption = true;
|
|
interfaceItemOptionDfns.Add(itemOption);
|
|
|
|
// Stock Cat Action.
|
|
itemOption = new SaItemOptionDfn();
|
|
itemOption.DisplayOptions.Group = OptionGroup_Stock;
|
|
itemOption.Name = sageStatics.InterfaceOptions.GetCodeForType(SageInterfaceOption.StockCatAction);
|
|
itemOption.DisplayOptions.Caption = sageStatics.InterfaceOptions.GetDescForType(SageInterfaceOption.StockCatAction);
|
|
itemOption.DisplayOptions.Contexts.AddRange(sageParams.Contexts_StockCategoryAction);
|
|
itemOption.DisplayOptions.Values.AddRange(sageStatics.StockCategoryActions);
|
|
itemOption.DisplayOptions.RequiresContext = true;
|
|
itemOption.DisplayOptions.NonDisplayTemplate = true;
|
|
itemOption.DisplayOptions.CanAddOption = true;
|
|
itemOption.DisplayOptions.CanRemoveOption = true;
|
|
interfaceItemOptionDfns.Add(itemOption);
|
|
|
|
// Stock Column Source.
|
|
itemOption = new SaItemOptionDfn();
|
|
itemOption.DisplayOptions.Group = OptionGroup_Stock;
|
|
itemOption.Name = sageStatics.InterfaceOptions.GetCodeForType(SageInterfaceOption.StockColumnSource);
|
|
itemOption.DisplayOptions.Caption = sageStatics.InterfaceOptions.GetDescForType(SageInterfaceOption.StockColumnSource);
|
|
itemOption.DisplayOptions.Contexts.AddRange(sageStatics.StockColumnSources);
|
|
itemOption.DisplayOptions.Values.AddRange(sageParams.StockColumnSources);
|
|
itemOption.DisplayOptions.RequiresContext = true;
|
|
itemOption.DisplayOptions.NonDisplayTemplate = true;
|
|
itemOption.DisplayOptions.CanAddOption = true;
|
|
itemOption.DisplayOptions.CanRemoveOption = true;
|
|
interfaceItemOptionDfns.Add(itemOption);
|
|
|
|
// Sales Order Column Source.
|
|
itemOption = new SaItemOptionDfn();
|
|
itemOption.DisplayOptions.Group = OptionGroup_Data;
|
|
itemOption.Name = sageStatics.InterfaceOptions.GetCodeForType(SageInterfaceOption.SalesOrderColumnSource);
|
|
itemOption.DisplayOptions.Caption = sageStatics.InterfaceOptions.GetDescForType(SageInterfaceOption.SalesOrderColumnSource);
|
|
itemOption.DisplayOptions.Contexts.AddRange(sageStatics.SalesOrderColumnSources);
|
|
itemOption.DisplayOptions.Values.AddRange(sageParams.SalesOrderColumnSources);
|
|
itemOption.DisplayOptions.RequiresContext = true;
|
|
itemOption.DisplayOptions.NonDisplayTemplate = true;
|
|
itemOption.DisplayOptions.CanAddOption = true;
|
|
itemOption.DisplayOptions.CanRemoveOption = true;
|
|
interfaceItemOptionDfns.Add(itemOption);
|
|
|
|
// Default Sales Location.
|
|
itemOption = new SaItemOptionDfn();
|
|
itemOption.DisplayOptions.Group = OptionGroup_Stock;
|
|
itemOption.Name = sageStatics.InterfaceOptions.GetCodeForType(SageInterfaceOption.DefaultSalesLocation);
|
|
itemOption.DisplayOptions.Caption = sageStatics.InterfaceOptions.GetDescForType(SageInterfaceOption.DefaultSalesLocation);
|
|
itemOption.DisplayOptions.Values.AddRange(sageParams.SalesLocations);
|
|
itemOption.DisplayOptions.NonDisplayTemplate = true;
|
|
itemOption.DisplayOptions.CanAddOption = true;
|
|
itemOption.DisplayOptions.CanRemoveOption = true;
|
|
interfaceItemOptionDfns.Add(itemOption);
|
|
|
|
// Tax Code Column
|
|
itemOption = new SaItemOptionDfn();
|
|
itemOption.DisplayOptions.Group = OptionGroup_Stock;
|
|
itemOption.Name = sageStatics.InterfaceOptions.GetCodeForType(SageInterfaceOption.TaxCodeColumn);
|
|
itemOption.DisplayOptions.Caption = sageStatics.InterfaceOptions.GetDescForType(SageInterfaceOption.TaxCodeColumn);
|
|
itemOption.DisplayOptions.Values.AddRange(SbmSystem.GetCodesOfType(UserContext, Sbm.SystemCode.OrgOption_TaxCodeColumn));
|
|
//itemOption.DefaultValue = SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.TaxCode_CodeAlt1);
|
|
interfaceItemOptionDfns.Add(itemOption);
|
|
|
|
return interfaceItemOptionDfns;
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
}
|
|
//=======================================================================
|
|
}
|