Class QuoteConnectorBase
A base class with som typical quote functionality: Price calculations from the QuoteCalculation helper class.
Inherited Members
Namespace: SuperOffice.CRM
Assembly: SuperOffice.Plugins.dll
Syntax
public abstract class QuoteConnectorBase : IQuoteConnector2, IQuoteConnector, IDisposable
Constructors
QuoteConnectorBase()
A base class with som typical quote functionality: Price calculations from the QuoteCalculation helper class.
Declaration
protected QuoteConnectorBase()
Properties
CRMConnectionId
Declaration
public int CRMConnectionId { get; set; }
Property Value
Type | Description |
---|---|
int |
Methods
CanProvideCapability(string)
Declaration
public abstract bool CanProvideCapability(string capabilityName)
Parameters
Type | Name | Description |
---|---|---|
string | capabilityName | Name of the capability, see CRMQuoteConnectorCapabilities |
Returns
Type | Description |
---|---|
bool | True if the connector can provide the requested function. |
CanUserWriteToField(string, QuoteLineInfo, HashSet<string>)
Check if the given quoteline field is writeable by the user. This method first checks the Rights field of the quoteline, then the quoteline configuration fields from the database.
Declaration
public bool CanUserWriteToField(string fieldName, QuoteLineInfo quoteLineInfo, HashSet<string> writeableFields)
Parameters
Type | Name | Description |
---|---|---|
string | fieldName | The fieldname to check |
QuoteLineInfo | quoteLineInfo | QuoteLineInfo object with fieldrights |
HashSet<string> | writeableFields | Collection of fields writeable by the user. This is the settings from the database. |
Returns
Type | Description |
---|---|
bool | true if the field is writeable. |
CleanOutStatusAndReason(QuoteVersionContextInfo)
Sets status to OK, and reason to string.Empty in all levels (Version, Alternatives, QuoteLines).
Declaration
public virtual QuoteVersionContextInfo CleanOutStatusAndReason(QuoteVersionContextInfo context)
Parameters
Type | Name | Description |
---|---|---|
QuoteVersionContextInfo | context | The version |
Returns
Type | Description |
---|---|
QuoteVersionContextInfo | The same version, with all quotelines in all alternatives and the version status + reason fields blanked. |
Dispose()
A base class with som typical quote functionality: Price calculations from the QuoteCalculation helper class.
Declaration
public virtual void Dispose()
FindProduct(QuoteAlternativeContextInfo, string, string, string)
The connector should treat this as a freetext search, the user might want to enter several words and expect the system to search for through several fields like name, description, product code, extrafields, etc.
Since the return list is a potentially large return value, the connector or the ERP system should limit the number of matches returned to a few hundred. The dropdown fast searcher calls this function to populate the dropdown list.Declaration
public abstract ProductInfo[] FindProduct(QuoteAlternativeContextInfo context, string currencyCode, string userinput, string priceListKey)
Parameters
Type | Name | Description |
---|---|---|
QuoteAlternativeContextInfo | context | |
string | currencyCode | |
string | userinput | |
string | priceListKey | If the pricelist is empty, the function will search in all active pricelists. |
Returns
Type | Description |
---|---|
ProductInfo[] | An array of products matching the search words |
GetActivePriceLists(string)
Always return empty list (array of length 0).
Declaration
public virtual PriceListInfo[] GetActivePriceLists(string isoCurrencyCode)
Parameters
Type | Name | Description |
---|---|---|
string | isoCurrencyCode |
Returns
Type | Description |
---|---|
PriceListInfo[] | Array of length 0 |
GetAddresses(QuoteAlternativeContextInfo)
Always returns null.
Declaration
public virtual AddressInfo[] GetAddresses(QuoteAlternativeContextInfo context)
Parameters
Type | Name | Description |
---|---|---|
QuoteAlternativeContextInfo | context |
Returns
Type | Description |
---|---|
AddressInfo[] | NULL |
GetAllPriceLists(string)
Always return empty list (array of length 0).
Declaration
public virtual PriceListInfo[] GetAllPriceLists(string isoCurrencyCode)
Parameters
Type | Name | Description |
---|---|---|
string | isoCurrencyCode |
Returns
Type | Description |
---|---|
PriceListInfo[] | Array of length 0 |
GetCapabilities()
Declaration
public virtual Dictionary<string, bool> GetCapabilities()
Returns
Type | Description |
---|---|
Dictionary<string, bool> | All capability responses |
GetCapabilityNames()
All the known names for capabilities.
Declaration
public static string[] GetCapabilityNames()
Returns
Type | Description |
---|---|
string[] | Array of strings with capabilites |
See Also
GetConfigurationFields()
Returns no configuration fields
Declaration
public virtual Dictionary<string, FieldMetadataInfo> GetConfigurationFields()
Returns
Type | Description |
---|---|
Dictionary<string, FieldMetadataInfo> | Empty dictionary. Override if you need configuration fields. |
GetNumberOfActivePriceLists(string)
Always return 0
Declaration
public virtual int GetNumberOfActivePriceLists(string isoCurrencyCode)
Parameters
Type | Name | Description |
---|---|---|
string | isoCurrencyCode |
Returns
Type | Description |
---|---|
int | Zero |
GetNumberOfProductImages(string)
Always returns 0. Override if you want to have images.
Declaration
public virtual int GetNumberOfProductImages(string erpProductKey)
Parameters
Type | Name | Description |
---|---|---|
string | erpProductKey |
Returns
Type | Description |
---|---|
int | Zero |
GetOrderState(QuoteAlternativeContextInfo)
Always returns NULL.
Declaration
public virtual OrderResponseInfo GetOrderState(QuoteAlternativeContextInfo context)
Parameters
Type | Name | Description |
---|---|---|
QuoteAlternativeContextInfo | context |
Returns
Type | Description |
---|---|
OrderResponseInfo | NULL |
GetProduct(QuoteAlternativeContextInfo, string)
Gets a product based on erpProductKey
Declaration
public abstract ProductInfo GetProduct(QuoteAlternativeContextInfo context, string erpProductKey)
Parameters
Type | Name | Description |
---|---|---|
QuoteAlternativeContextInfo | context | |
string | erpProductKey |
Returns
Type | Description |
---|---|
ProductInfo | Returns the product with the specified key. |
Exceptions
Type | Condition |
---|---|
ArgumentException | If the argument is null or empty , the function will throw an ArgumentException. |
Exception | If the product is not found , the function will throw an Exception. |
GetProductImage(string, int)
Always return blank.
Declaration
public virtual string GetProductImage(string erpProductKey, int rank)
Parameters
Type | Name | Description |
---|---|---|
string | erpProductKey | |
int | rank | Image number |
Returns
Type | Description |
---|---|
string | Empty string - no image. |
GetProducts(QuoteAlternativeContextInfo, string[])
See GetProduct for details
Declaration
public abstract ProductInfo[] GetProducts(QuoteAlternativeContextInfo context, string[] erpProductKeys)
Parameters
Type | Name | Description |
---|---|---|
QuoteAlternativeContextInfo | context | |
string[] | erpProductKeys |
Returns
Type | Description |
---|---|
ProductInfo[] | Return products based on an array of unique ERP keys; handy when you’ve found products through archiveproviders or other mechanisms that leave you holding an ERPKey |
GetQuoteLinesFromProduct(QuoteAlternativeContextInfo, string)
Given a product ERP Key, return one or more quote lines with the product data filled in, and some default values , typically quantity set to 1 (but not necessarily!) The quoteLineId will be provided by SuperOffice later.
Declaration
public abstract QuoteLineInfo[] GetQuoteLinesFromProduct(QuoteAlternativeContextInfo context, string erpProductKey)
Parameters
Type | Name | Description |
---|---|---|
QuoteAlternativeContextInfo | context | |
string | erpProductKey |
Returns
Type | Description |
---|---|
QuoteLineInfo[] | Return the QuoteLine(-s) with the product info filled in. |
Exceptions
Type | Condition |
---|---|
ArgumentException | If the erpProductKey is null or empty , the function will throw an ArgumentException. |
Exception | If the product is not found , the function will throw an Exception. |
GetQuoteList(string)
Always return an empty list (array of length 0).
Declaration
public virtual ListItemInfo[] GetQuoteList(string quoteListType)
Parameters
Type | Name | Description |
---|---|---|
string | quoteListType |
Returns
Type | Description |
---|---|
ListItemInfo[] | Array of length 0 |
GetQuoteStatusInfo(string)
Return the status that should be given for a given type of situation. Called from ValidateQuoteLine(QuoteAlternativeContextInfo, QuoteLineInfo, bool) to determine how to handle various situations.
i.e. should the situation BelowCost be flagged as a Warning or an Error?Declaration
protected virtual QuoteStatusInfo GetQuoteStatusInfo(string key)
Parameters
Type | Name | Description |
---|---|---|
string | key | The kind of list price situation (belowminimumprice, negative). QuoteConnectorBase.ConfigNames for values used. |
Returns
Type | Description |
---|---|
QuoteStatusInfo | OkWithInfo - override this method to supply your own logic |
GetSearchResults(SearchRestrictionInfo[])
Always return empty result.
Declaration
public virtual ProductInfo[] GetSearchResults(SearchRestrictionInfo[] restrictions)
Parameters
Type | Name | Description |
---|---|---|
SearchRestrictionInfo[] | restrictions |
Returns
Type | Description |
---|---|
ProductInfo[] | Array of length 0 |
GetSearchableFields()
Always return no fields.
Declaration
public virtual FieldMetadataInfo[] GetSearchableFields()
Returns
Type | Description |
---|---|
FieldMetadataInfo[] | Array of length 0 |
InitializeConnection(QuoteConnectionInfo, UserInfo, bool, Dictionary<string, string>, IProductRegisterCache)
cref="IQuoteConnector.InitializeConnection"/>
Declaration
public abstract PluginResponseInfo InitializeConnection(QuoteConnectionInfo connectionData, UserInfo user, bool isOnTravel, Dictionary<string, string> connectionConfigFields, IProductRegisterCache productRegister)
Parameters
Type | Name | Description |
---|---|---|
QuoteConnectionInfo | connectionData | Information about the connection |
UserInfo | user | Information about the current user |
bool | isOnTravel | True if we are currently on travel |
Dictionary<string, string> | connectionConfigFields | Configuration parameters |
IProductRegisterCache | productRegister | Interface to call if a product register cache is desired |
Returns
Type | Description |
---|---|
PluginResponseInfo | Ok if connection to ERP system established. Error if connection is not usable. |
InsertCaption(Dictionary<string, FieldMetadataInfo>, int, string, string)
Inserts a blank line and a caption line
Declaration
public static int InsertCaption(Dictionary<string, FieldMetadataInfo> dic, int rank, string caption, string description = "")
Parameters
Type | Name | Description |
---|---|---|
Dictionary<string, FieldMetadataInfo> | dic | |
int | rank | |
string | caption | |
string | description |
Returns
Type | Description |
---|---|
int |
OnAfterSaveQuote(QuoteAlternativeContextInfo)
Declaration
public abstract void OnAfterSaveQuote(QuoteAlternativeContextInfo context)
Parameters
Type | Name | Description |
---|---|---|
QuoteAlternativeContextInfo | context | The alternative |
OnAfterSentQuoteVersion(QuoteVersionContextInfo)
Declaration
public virtual QuoteSentResponseInfo OnAfterSentQuoteVersion(QuoteVersionContextInfo context)
Parameters
Type | Name | Description |
---|---|---|
QuoteVersionContextInfo | context | The version that was sent |
Returns
Type | Description |
---|---|
QuoteSentResponseInfo |
OnBeforeCreateQuote(QuoteAlternativeContextInfo)
Declaration
public virtual QuoteResponseInfo OnBeforeCreateQuote(QuoteAlternativeContextInfo context)
Parameters
Type | Name | Description |
---|---|---|
QuoteAlternativeContextInfo | context | The alternative |
Returns
Type | Description |
---|---|
QuoteResponseInfo | Changed values. Null means no change |
OnBeforeCreateQuoteAlternative(QuoteAlternativeContextInfo)
Declaration
public virtual QuoteAlternativeResponseInfo OnBeforeCreateQuoteAlternative(QuoteAlternativeContextInfo context)
Parameters
Type | Name | Description |
---|---|---|
QuoteAlternativeContextInfo | context | The alternative |
Returns
Type | Description |
---|---|
QuoteAlternativeResponseInfo | Changed values. Null means no change |
OnBeforeCreateQuoteVersion(QuoteVersionContextInfo)
Declaration
public virtual QuoteVersionResponseInfo OnBeforeCreateQuoteVersion(QuoteVersionContextInfo context)
Parameters
Type | Name | Description |
---|---|---|
QuoteVersionContextInfo | context | The alternative |
Returns
Type | Description |
---|---|
QuoteVersionResponseInfo | Changed values. Null means no change |
OnBeforeDeleteQuote(QuoteInfo, ISaleInfo, IContactInfo)
Declaration
public abstract void OnBeforeDeleteQuote(QuoteInfo quote, ISaleInfo sale, IContactInfo contact)
Parameters
Type | Name | Description |
---|---|---|
QuoteInfo | quote | Quote that will be deleted |
ISaleInfo | sale | Sale the quote belongs to |
IContactInfo | contact | Contact the sale belongs to |
OnQuoteLineChanged(QuoteAlternativeContextInfo, QuoteLineInfo, string[])
Some formulaes:
- SubTotal = Quantity * UnitListPrice
- TotalCost = Quantity * UnitCost
- TotalPrice = SubTotal - DiscountAmount
- TotalPrice = TotalCost + EarningAmount
- DiscountAmount = DiscountPercent * SubTotal / 100
- DiscountPercent = DiscountAmount * 100 / SubTotal
- EarningAmount = EarningPercent * TotalCost / 100
- EarningPercent = EarningAmount * 100 / TotalPrice
Declaration
public virtual QuoteLineInfo OnQuoteLineChanged(QuoteAlternativeContextInfo context, QuoteLineInfo ql, string[] changedFields)
Parameters
Type | Name | Description |
---|---|---|
QuoteAlternativeContextInfo | context | The alternative containing the quote line |
QuoteLineInfo | ql | The QuoteLine to calculate |
string[] | changedFields | not used |
Returns
Type | Description |
---|---|
QuoteLineInfo | The QuoteLine, with modifications, after validation |
Remarks
Calls ValidateQuoteLine(QuoteAlternativeContextInfo, QuoteLineInfo, bool) to check that the business rules are ok.
OnQuoteVersionApproved(QuoteVersionContextInfo)
Returns quote version unchanged.
Declaration
public virtual QuoteVersionResponseInfo OnQuoteVersionApproved(QuoteVersionContextInfo context)
Parameters
Type | Name | Description |
---|---|---|
QuoteVersionContextInfo | context | Quote version |
Returns
Type | Description |
---|---|
QuoteVersionResponseInfo | Unchanged quote version |
OnQuoteVersionRejected(QuoteVersionContextInfo)
Returns quote version unchanged.
Declaration
public virtual QuoteVersionResponseInfo OnQuoteVersionRejected(QuoteVersionContextInfo context)
Parameters
Type | Name | Description |
---|---|---|
QuoteVersionContextInfo | context | Quote version |
Returns
Type | Description |
---|---|
QuoteVersionResponseInfo | Unchanged quote version |
OnQuoteVersionRequestApproval(QuoteVersionContextInfo)
Returns quote version unchanged.
Declaration
public virtual QuoteVersionResponseInfo OnQuoteVersionRequestApproval(QuoteVersionContextInfo context)
Parameters
Type | Name | Description |
---|---|---|
QuoteVersionContextInfo | context | Quote version |
Returns
Type | Description |
---|---|
QuoteVersionResponseInfo | Unchanged quote version |
PlaceOrder(QuoteAlternativeContextInfo)
Always return Ok.
Declaration
public virtual PlaceOrderResponseInfo PlaceOrder(QuoteAlternativeContextInfo context)
Parameters
Type | Name | Description |
---|---|---|
QuoteAlternativeContextInfo | context |
Returns
Type | Description |
---|---|
PlaceOrderResponseInfo | Ok. |
RecalculateQuoteAlternative(QuoteAlternativeContextInfo)
Some formulaes:
- SubTotal = Quantity * UnitListPrice
- TotalCost = Quantity * UnitCost
- TotalPrice = SubTotal - DiscountAmount
- TotalPrice = TotalCost + EarningAmount
- DiscountAmount = DiscountPercent * SubTotal / 100
- DiscountPercent = DiscountAmount * 100 / SubTotal
- EarningAmount = EarningPercent * TotalCost / 100
- EarningPercent = EarningAmount * 100 / TotalPrice
Declaration
public virtual QuoteAlternativeWithLinesInfo RecalculateQuoteAlternative(QuoteAlternativeContextInfo inContext)
Parameters
Type | Name | Description |
---|---|---|
QuoteAlternativeContextInfo | inContext | The alternative |
Returns
Type | Description |
---|---|
QuoteAlternativeWithLinesInfo |
Remarks
Sets the QuoteVersion.State to Calculated if the state was NotCalculated.
Calls ValidateAlternative(QuoteAlternativeContextInfo, bool) to check the alternative after calling CalculateQuoteAlternativeWithLines(QuoteAlternativeWithLinesInfo) to sum all the quotelines together.TestConnection(Dictionary<string, string>)
Test the connection. Base implementation Always returns IsOk - Ok
Declaration
public virtual PluginResponseInfo TestConnection(Dictionary<string, string> connectionData)
Parameters
Type | Name | Description |
---|---|---|
Dictionary<string, string> | connectionData | Configuration fields |
Returns
Type | Description |
---|---|
PluginResponseInfo | Always returns OK - override with a better implementation. |
UpdateQuoteVersionPrices(QuoteVersionContextInfo, HashSet<string>)
Should loop thru and update all the alternatives with new prices from the pricelists. This implementation does nothing.
Declaration
public virtual QuoteVersionResponseInfo UpdateQuoteVersionPrices(QuoteVersionContextInfo context, HashSet<string> writeableFields)
Parameters
Type | Name | Description |
---|---|---|
QuoteVersionContextInfo | context | Current quote version |
HashSet<string> | writeableFields | Names of writable fields |
Returns
Type | Description |
---|---|
QuoteVersionResponseInfo | Updated quote version |
ValidateAlternative(QuoteAlternativeContextInfo, bool)
Check rules for the quote alternative and fill out the status and reason fields if there is a problem. Calls ValidateQuoteLine(QuoteAlternativeContextInfo, QuoteLineInfo, bool) for each quoteline in the alternative. Called from ValidateVersion(QuoteVersionContextInfo, QuoteAction, bool) for each alternative in the quote version.
Declaration
public virtual QuoteAlternativeWithLinesInfo ValidateAlternative(QuoteAlternativeContextInfo context, bool clearOldValues = false)
Parameters
Type | Name | Description |
---|---|---|
QuoteAlternativeContextInfo | context | The alternative to validate |
bool | clearOldValues | Should the function clear out old values for status and reason? |
Returns
Type | Description |
---|---|
QuoteAlternativeWithLinesInfo | Updated quote alternative and quote lines. |
Remarks
Enforces basic checks on the alternative's total price against the Zero/Negative values, and the total Cost and Minimum price values. Implement your own GetQuoteStatusInfo(string) method to define responses to these standard checks.
ValidateQuoteLine(QuoteAlternativeContextInfo, QuoteLineInfo, bool)
Check rules for the quoteline and fill out the status and reason fields if there is a problem.
Declaration
public virtual QuoteLineInfo ValidateQuoteLine(QuoteAlternativeContextInfo context, QuoteLineInfo ql, bool clearOldValues = false)
Parameters
Type | Name | Description |
---|---|---|
QuoteAlternativeContextInfo | context | The Alternative that this quoteline belongs to. |
QuoteLineInfo | ql | The original quoteline |
bool | clearOldValues | Should the function clear out old values for status and reason? |
Returns
Type | Description |
---|---|
QuoteLineInfo | A potentially changed quoteline |
Remarks
Called from the ValidateAlternative(QuoteAlternativeContextInfo, bool) and OnQuoteLineChanged(QuoteAlternativeContextInfo, QuoteLineInfo, string[]) .
Calls the GetQuoteStatusInfo(string) function to determine what the status on the quoteline should be. i.e. Should a Negative TotalPrice be flagged as an error or a warning?ValidateQuoteVersion(QuoteVersionContextInfo, QuoteAction)
Will loop thru and validate all the alternatives and then validate the version state.
Declaration
public virtual QuoteResponseInfo ValidateQuoteVersion(QuoteVersionContextInfo context, QuoteAction action)
Parameters
Type | Name | Description |
---|---|---|
QuoteVersionContextInfo | context | The current quote version |
QuoteAction | action | The action that started this call; the context it is called in, like place order or send quote |
Returns
Type | Description |
---|---|
QuoteResponseInfo | Updated quote version, with state and status set. |
Remarks
Calls CalculateVersionWithAlternatives(QuoteVersionContextInfo) and ValidateVersion(QuoteVersionContextInfo, QuoteAction, bool) to do the actual validation.
ValidateVersion(QuoteVersionContextInfo, QuoteAction, bool)
Validates the version, looks for problems. Will typically change the Status and Reason fields. Basically validates the alternatives and then concaternates the problems. Calls ValidateAlternative(QuoteAlternativeContextInfo, bool) to validate each alternative. Called from ValidateQuoteVersion(QuoteVersionContextInfo, QuoteAction).
Declaration
public virtual QuoteResponseInfo ValidateVersion(QuoteVersionContextInfo context, QuoteAction action, bool clearOldValues = false)
Parameters
Type | Name | Description |
---|---|---|
QuoteVersionContextInfo | context | |
QuoteAction | action | |
bool | clearOldValues | Should the function clear out old values for status and reason? |
Returns
Type | Description |
---|---|
QuoteResponseInfo | A potentially changed context, with Status and Reason filled in |