Show / Hide Table of Contents

Class QuoteConnectorBase

A base class with som typical quote functionality: Price calculations from the QuoteCalculation helper class.

Inheritance
Object
QuoteConnectorBase
Implements
IQuoteConnector
IDisposable
Inherited Members
Object.ToString()
Object.Equals(Object)
Object.Equals(Object, Object)
Object.ReferenceEquals(Object, Object)
Object.GetHashCode()
Object.GetType()
Object.MemberwiseClone()
Namespace: SuperOffice.CRM
Assembly: SuperOffice.Plugins.dll
Syntax
public abstract class QuoteConnectorBase : IQuoteConnector, IDisposable, IPlugin

Constructors

QuoteConnectorBase()

Declaration
protected QuoteConnectorBase()

Properties

CRMConnectionId

CRMConnectionId

Declaration
public int CRMConnectionId { get; set; }
Property Value
Type Description
Int32

Methods

CanProvideCapability(String)

CanProvideCapability(String)

Declaration
public abstract bool CanProvideCapability(string capabilityName)
Parameters
Type Name Description
String capabilityName

Name of the capability, see CRMQuoteConnectorCapabilities

Returns
Type Description
Boolean

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
Boolean

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()

Declaration
public virtual void Dispose()

FindProduct(QuoteAlternativeContextInfo, String, String, String)

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
Returns
Type Description
ProductInfo[]

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()

GetCapabilities()

Declaration
public virtual Dictionary<string, bool> GetCapabilities()
Returns
Type Description
Dictionary<String, Boolean>

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
CRMQuoteConnectorCapabilities

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
Int32

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
Int32

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)

Declaration
public abstract ProductInfo GetProduct(QuoteAlternativeContextInfo context, string erpProductKey)
Parameters
Type Name Description
QuoteAlternativeContextInfo context
String erpProductKey
Returns
Type Description
ProductInfo

GetProductImage(String, Int32)

Always return blank.

Declaration
public virtual string GetProductImage(string erpProductKey, int rank)
Parameters
Type Name Description
String erpProductKey
Int32 rank

Image number

Returns
Type Description
String

Empty string - no image.

GetProducts(QuoteAlternativeContextInfo, String[])

Declaration
public abstract ProductInfo[] GetProducts(QuoteAlternativeContextInfo context, string[] erpProductKeys)
Parameters
Type Name Description
QuoteAlternativeContextInfo context
String[] erpProductKeys
Returns
Type Description
ProductInfo[]

GetQuoteLinesFromProduct(QuoteAlternativeContextInfo, String)

Declaration
public abstract QuoteLineInfo[] GetQuoteLinesFromProduct(QuoteAlternativeContextInfo context, string erpProductKey)
Parameters
Type Name Description
QuoteAlternativeContextInfo context
String erpProductKey
Returns
Type Description
QuoteLineInfo[]

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, Boolean) 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

GetSearchableFields()

Always return no fields.

Declaration
public virtual FieldMetadataInfo[] GetSearchableFields()
Returns
Type Description
FieldMetadataInfo[]

Array of length 0

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

InitializeConnection(QuoteConnectionInfo, UserInfo, Boolean, 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

Boolean 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>, Int32, 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
Int32 rank
String caption
String description
Returns
Type Description
Int32

OnAfterSaveQuote(QuoteAlternativeContextInfo)

OnAfterSaveQuote(QuoteAlternativeContextInfo)

Declaration
public abstract void OnAfterSaveQuote(QuoteAlternativeContextInfo context)
Parameters
Type Name Description
QuoteAlternativeContextInfo context

The alternative

OnAfterSentQuoteVersion(QuoteVersionContextInfo)

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)

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)

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)

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)

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
Thus, you can change any of the 5: TotalPrice, DiscountAmount, DiscountPercent, EarningAmount and EarningPercent and calculate the other 4.

Independently, you can change Quantity, UnitListPrice and UnitCost.

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, Boolean) to check that the business rules are ok.

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
Thus, you can change any of the 5: TotalPrice, DiscountAmount, DiscountPercent, EarningAmount and EarningPercent and calculate the other 4.

Independently, you can change Quantity, UnitListPrice and UnitCost.

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, Boolean) 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, Boolean)

Check rules for the quote alternative and fill out the status and reason fields if there is a problem. Calls ValidateQuoteLine(QuoteAlternativeContextInfo, QuoteLineInfo, Boolean) for each quoteline in the alternative. Called from ValidateVersion(QuoteVersionContextInfo, QuoteAction, Boolean) 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

Boolean 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, Boolean)

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

Boolean 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, Boolean) 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, Boolean) to do the actual validation.

ValidateVersion(QuoteVersionContextInfo, QuoteAction, Boolean)

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, Boolean) 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
Boolean 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

Implements

IQuoteConnector
System.IDisposable

Extension Methods

EnumUtil.MapEnums<From, To>(From)
Converters.MapEnums<From, To>(From)
© SuperOffice. All rights reserved.
SuperOffice |  Community |  Release Notes |  Privacy |  Site feedback |  Search Docs |  About Docs |  Contribute |  Back to top