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
IQuoteConnector2
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 : 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

CRMConnectionId

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

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

FindProductAsync(QuoteAlternativeContextInfo, string, string, string, CancellationToken)

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 Task<ProductInfo[]> FindProductAsync(QuoteAlternativeContextInfo context, string currencyCode, string userinput, string priceListKey, CancellationToken cancellationToken = default)
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.

CancellationToken cancellationToken
Returns
Type Description
Task<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()

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
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
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.

GetQuoteListAsync(string, CancellationToken)

Always return an empty list (array of length 0).

Declaration
public virtual Task<ListItemInfo[]> GetQuoteListAsync(string quoteListType, CancellationToken cancellationToken = default)
Parameters
Type Name Description
string quoteListType
CancellationToken cancellationToken
Returns
Type Description
Task<ListItemInfo[]>

Array of length 0

GetQuoteStatusInfo(string)

Return the status that should be given for a given type of situation. Called from ValidateQuoteLineAsync(QuoteAlternativeContextInfo, QuoteLineInfo, bool, CancellationToken) 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

GetSearchResultsAsync(SearchRestrictionInfo[], CancellationToken)

Always return empty result.

Declaration
public virtual IAsyncEnumerable<ProductInfo> GetSearchResultsAsync(SearchRestrictionInfo[] restrictions, CancellationToken cancellationToken = default)
Parameters
Type Name Description
SearchRestrictionInfo[] restrictions
CancellationToken cancellationToken
Returns
Type Description
IAsyncEnumerable<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)

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

OnQuoteLineChangedAsync(QuoteAlternativeContextInfo, QuoteLineInfo, string[], CancellationToken)

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 Task<QuoteLineInfo> OnQuoteLineChangedAsync(QuoteAlternativeContextInfo context, QuoteLineInfo ql, string[] changedFields, CancellationToken cancellationToken = default)
Parameters
Type Name Description
QuoteAlternativeContextInfo context

The alternative containing the quote line

QuoteLineInfo ql

The QuoteLine to calculate

string[] changedFields

not used

CancellationToken cancellationToken
Returns
Type Description
Task<QuoteLineInfo>

The QuoteLine, with modifications, after validation

Remarks

Calls ValidateQuoteLineAsync(QuoteAlternativeContextInfo, QuoteLineInfo, bool, CancellationToken) 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.

RecalculateQuoteAlternativeAsync(QuoteAlternativeContextInfo, CancellationToken)

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 Task<QuoteAlternativeWithLinesInfo> RecalculateQuoteAlternativeAsync(QuoteAlternativeContextInfo inContext, CancellationToken cancellationToken = default)
Parameters
Type Name Description
QuoteAlternativeContextInfo inContext

The alternative

CancellationToken cancellationToken
Returns
Type Description
Task<QuoteAlternativeWithLinesInfo>
Remarks

Sets the QuoteVersion.State to Calculated if the state was NotCalculated.

Calls ValidateAlternativeAsync(QuoteAlternativeContextInfo, bool, CancellationToken) 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.

UpdateQuoteVersionPricesAsync(QuoteVersionContextInfo, HashSet<string>)

Should loop thru and update all the alternatives with new prices from the pricelists. This implementation does nothing.

Declaration
public virtual Task<QuoteVersionResponseInfo> UpdateQuoteVersionPricesAsync(QuoteVersionContextInfo context, HashSet<string> writeableFields)
Parameters
Type Name Description
QuoteVersionContextInfo context

Current quote version

HashSet<string> writeableFields

Names of writable fields

Returns
Type Description
Task<QuoteVersionResponseInfo>

Updated quote version

ValidateAlternativeAsync(QuoteAlternativeContextInfo, bool, CancellationToken)

Check rules for the quote alternative and fill out the status and reason fields if there is a problem. Calls ValidateQuoteLineAsync(QuoteAlternativeContextInfo, QuoteLineInfo, bool, CancellationToken) for each quoteline in the alternative. Called from ValidateVersionAsync(QuoteVersionContextInfo, QuoteAction, bool, CancellationToken) for each alternative in the quote version.

Declaration
public virtual Task<QuoteAlternativeWithLinesInfo> ValidateAlternativeAsync(QuoteAlternativeContextInfo context, bool clearOldValues = false, CancellationToken cancellationToken = default)
Parameters
Type Name Description
QuoteAlternativeContextInfo context

The alternative to validate

bool clearOldValues

Should the function clear out old values for status and reason?

CancellationToken cancellationToken
Returns
Type Description
Task<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.

ValidateQuoteLineAsync(QuoteAlternativeContextInfo, QuoteLineInfo, bool, CancellationToken)

Check rules for the quoteline and fill out the status and reason fields if there is a problem.

Declaration
public virtual Task<QuoteLineInfo> ValidateQuoteLineAsync(QuoteAlternativeContextInfo context, QuoteLineInfo ql, bool clearOldValues = false, CancellationToken cancellationToken = default)
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?

CancellationToken cancellationToken
Returns
Type Description
Task<QuoteLineInfo>

A potentially changed quoteline

Remarks

Called from the ValidateAlternativeAsync(QuoteAlternativeContextInfo, bool, CancellationToken) and OnQuoteLineChangedAsync(QuoteAlternativeContextInfo, QuoteLineInfo, string[], CancellationToken) .

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?

ValidateQuoteVersionAsync(QuoteVersionContextInfo, QuoteAction, CancellationToken)

Will loop thru and validate all the alternatives and then validate the version state.

Declaration
public virtual Task<QuoteResponseInfo> ValidateQuoteVersionAsync(QuoteVersionContextInfo context, QuoteAction action, CancellationToken cancellationToken = default)
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

CancellationToken cancellationToken
Returns
Type Description
Task<QuoteResponseInfo>

Updated quote version, with state and status set.

Remarks

Calls CalculateVersionWithAlternatives(QuoteVersionContextInfo) and ValidateVersionAsync(QuoteVersionContextInfo, QuoteAction, bool, CancellationToken) to do the actual validation.

ValidateVersionAsync(QuoteVersionContextInfo, QuoteAction, bool, CancellationToken)

Validates the version, looks for problems. Will typically change the Status and Reason fields. Basically validates the alternatives and then concaternates the problems. Calls ValidateAlternativeAsync(QuoteAlternativeContextInfo, bool, CancellationToken) to validate each alternative. Called from ValidateQuoteVersionAsync(QuoteVersionContextInfo, QuoteAction, CancellationToken).

Declaration
public virtual Task<QuoteResponseInfo> ValidateVersionAsync(QuoteVersionContextInfo context, QuoteAction action, bool clearOldValues = false, CancellationToken cancellationToken = default)
Parameters
Type Name Description
QuoteVersionContextInfo context
QuoteAction action
bool clearOldValues

Should the function clear out old values for status and reason?

CancellationToken cancellationToken
Returns
Type Description
Task<QuoteResponseInfo>

A potentially changed context, with Status and Reason filled in

Implements

IQuoteConnector2
IQuoteConnector
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