File

projects/congarevenuecloud/ecommerce/src/lib/modules/order/services/quote.service.ts

Description

The quote represents a price breakdown for a given product configuration. Quotes are generally associated with an approval process and can be converted to a cart or an order.

Usage

Example :
import { QuoteService } from '@congarevenuecloud/ecommerce';

constructor(private quoteService: QuoteService) {}

// or

export class MyService extends AObjectService {
private quoteService: QuoteService = this.injector.get(QuoteService);
}

Extends

AObjectService

Index

Properties
Methods

Methods

abandonCart
abandonCart()

Method to abandon the cart in Draft status.

Example:

Example :
import { QuoteService } from '@congarevenuecloud/ecommerce';
import { Observable } from 'rxjs/Observable';

export class MyComponent implements OnInit{
result: boolean;

constructor(private quoteService: QuoteService){}

abandonCart(){
this.quoteService.abandonCart().subscribe(r => this.result = r);
}
}
Returns : Observable<boolean>

true if the operation was successful, false otherwise.

acceptQuote
acceptQuote(quoteId: string)

Method to accept the given quote.

Example:

Example :
import { QuoteService } from '@congarevenuecloud/ecommerce';
import { Observable } from 'rxjs/Observable';

export class MyComponent implements OnInit{
result: boolean;

constructor(private quoteService: QuoteService){}

acceptQuote(quoteId: string){
this.quoteService.acceptQuote(quoteId).subscribe(r => this.result = r);
}
}
Parameters :
Name Type Optional Description
quoteId string No

string identifier of the quote.

Returns : Observable<boolean>

true if the operation was successful, false otherwise.

convertCartToQuote
convertCartToQuote(quote: Quote, fieldList?: Array)

Method converts the current cart into a quote instance.

Example:

Example :
import { QuoteService, Quote } from '@congarevenuecloud/ecommerce';
import { Observable } from 'rxjs/Observable';

export class MyComponent implements OnInit{
quote: Quote;

constructor(private quoteService: QuoteService){}

ngOnInit(){
const q = new Quote();
q.Name = 'Sample Quote';
this.quoteService.convertCartToQuote(q).subscribe(
q => this.quote = q,
err => {...}
);
}
}
Parameters :
Name Type Optional Default value Description
quote Quote No new Quote()

quote instance to specify predefined parameters on the quote that gets created.

fieldList Array<Field> Yes

optional parameter specifying the fields to be passed in the payload for quote creation.

Returns : Observable<Quote>

an observable of the quote instance that was created from the cart.

convertQuoteToCart
convertQuoteToCart(quote: Quote)

Method creates new cart and clones the finalized cart linked to the quote, and sets the new cart as active.

Example:

Example :
import { QuoteService, Quote } from '@congarevenuecloud/ecommerce';
import { Observable } from 'rxjs/Observable';

export class MyComponent implements OnInit{
quote: Quote;

constructor(private quoteService: QuoteService){}

convertQuoteToCart(quoteId: string) {
this.quoteService.convertQuoteToCart(quoteId).subscribe(
c => c,
err => {...}
);
}
}
}
Parameters :
Name Type Optional Description
quote Quote No

an quote instance to specify predefined parameters on the quote that gets created.

Returns : Observable<Cart>

an observable of the cart instance.

createQuote
createQuote(quote: Quote)

This method is use to create a quote.

Example:

Example :
import { QuoteService } from '@congarevenuecloud/ecommerce';
import { Observable } from 'rxjs/Observable';
export class MyComponent implements OnInit{
result: Quote;
result$: Observable<Quote>;

constructor(private quoteService: QuoteService){}

createQuote(quote: Quote){
this.result$= this.quoteService.createQuote(quote);
//or
this.quoteService.createQuote(quote).subscribe(c=> this.result=c);
}
}
Parameters :
Name Type Optional Description
quote Quote No

holds the information of requested quote.

Returns : Observable<Quote>

observable instance of the created quote.

finalizeQuote
finalizeQuote(quoteId: string)

Method moves the quote status from Draft to Approved.

Example:

Example :
import { QuoteService } from '@congarevenuecloud/ecommerce';
import { Observable } from 'rxjs/Observable';
export class MyComponent implements OnInit{
result: boolean;
constructor(private quoteService: QuoteService){}
finalizeQuote(quoteId: string){
this.quoteService.finalizeQuote(quoteId).subscribe(r => this.result = r);
}
}

This method updates the status on quote from Draft to Approved. This method is a work in progress.

Parameters :
Name Type Optional Description
quoteId string No

string identifier of the quote.

Returns : Observable<boolean>

true if the operation was successful, false otherwise. This method is a work in progress.

getAllQuotes
getAllQuotes(days?: number, filters?: Array<FieldFilter>, relatedRecords: string, limit: number, pageNumber: number, orderBy: string, orderDirection: "ASC" | "DESC", showErrorToaster: boolean)

The method fetches the list of quotes based on the parameters passed.

Example:

Example :
import { QuoteService, Quote } from '@congarevenuecloud/ecommerce';
import { Observable } from 'rxjs/Observable';
export class MyComponent implements OnInit{
result: Array<Quote>
result$: Observable<Array<Quote>>;
constructor(private quoteService: QuoteService){}

getAllQuotes(days?: number, filters?: Array<FieldFilter>, relatedRecords: string = '', limit: number = 10, pageNumber: number = 1, orderBy: string = 'CreatedDate', orderDirection: 'ASC' | 'DESC' = 'DESC'): Observable<Array<Quote>> {
this.quoteService.getAllQuotes(7, [{ field: 'Id', value: null, filterOperator: FilterOperator.NOT_EQUAL }], 'items').subscribe(r => this.result = r);
// or
results$ = this.quoteService.getAllQuotes(7, [{ field: 'Id', value: null, filterOperator: FilterOperator.NOT_EQUAL }], 'items');
}
}
Parameters :
Name Type Optional Default value Description
days number Yes

optional parameter to filter the quotes created for the last 'x' number of days.

filters Array<FieldFilter> Yes

list of quote field filters to filter the quote records.

relatedRecords string No ''

related records(qupte line items, prices etc.) to be fetched for the quote(s). Takes in quote related fields as comma separated string.

limit number No 10

number representing the number of quote records to be fetched.

pageNumber number No 1

number representing the pagination.

orderBy string No 'CreatedDate'

string representing the sort field on the quote.

orderDirection "ASC" | "DESC" No 'DESC'

string representing the sort direction. Posible values are 'ASC' or 'DESC'.

showErrorToaster boolean No true

boolean indicates whether the underlying API exceptions should be shown as a toaster message in UI. Defaulted to true.

An observable containing the list of quotes matching the criteria with total quote count.

getGrandTotalByApprovalStage
getGrandTotalByApprovalStage()

Method to get the aggregate of quote total by approval stage

Example:

Example :
import { QuoteService, GenerateDocument } from '@congarevenuecloud/ecommerce';
import { Observable } from 'rxjs/Observable';

export class MyComponent implements OnInit{
result: string;

constructor(private quoteService: QuoteService){}

getGrandTotalByApprovalStage(){
this.quoteService.getGrandTotalByApprovalStage().subscribe(r => r);
}
}
}

This method is a work in progress.

Returns : Observable<object>

Aggregate of quote total object based on the Approval Stage. This method is a work in progress.

getMyQuote
getMyQuote()
Returns : Observable<Quote>

A hot observable containing the single quote instance.

getMyQuotes
getMyQuotes(days?: number, filters?: Array<FieldFilter>, relatedRecords: string, limit: number, pageNumber: number, orderBy: string, orderDirection: "ASC" | "DESC", showErrorToaster: boolean)

This method is work in progress, currently returning all quotes.</ The method fetches the list of my quotes based on the parameters passed.

Example:

Example :
import { QuoteService, Quote } from '@congarevenuecloud/ecommerce';
import { Observable } from 'rxjs/Observable';
export class MyComponent implements OnInit{
result: Array<Quote>
result$: Observable<Array<Quote>>;
constructor(private quoteService: QuoteService){}

getMyQuotes(days?: number, filters?: Array<FieldFilter>, relatedRecords: string = '', limit: number = 10, pageNumber: number = 1, orderBy: string = 'CreatedDate', orderDirection: 'ASC' | 'DESC' = 'DESC'): Observable<Array<Quote>> {
this.quoteService.getMyQuotes(7, [{ field: 'Id', value: null, filterOperator: FilterOperator.NOT_EQUAL }], 'items').subscribe(r => this.result = r);
// or
results$ = this.quoteService.getMyQuotes(7, [{ field: 'Id', value: null, filterOperator: FilterOperator.NOT_EQUAL }], 'items');
}
}
Parameters :
Name Type Optional Default value Description
days number Yes

optional parameter to filter the quotes created for the last 'x' number of days.

filters Array<FieldFilter> Yes

list of quote field filters to filter the quote records.

relatedRecords string No ''

related records(qupte line items, prices etc.) to be fetched for the quote(s). Takes in quote related fields as comma separated string.

limit number No 10

number representing the number of quote records to be fetched.

pageNumber number No 1

number representing the pagination.

orderBy string No 'CreatedDate'

string representing the sort field on the quote.

orderDirection "ASC" | "DESC" No 'DESC'

string representing the sort direction. Posible values are 'ASC' or 'DESC'.

showErrorToaster boolean No true

boolean indicates whether the underlying API exceptions should be shown as a toaster message in UI. Defaulted to true.

An observable containing the list of quotes matching the criteria with total quote count.

getQuote
getQuote(Id: string)

The method gets details of the Quote based on the quote Id passed.

Example:

Example :
import { QuoteService, Quote } from '@congarevenuecloud/ecommerce';
import { Observable } from 'rxjs/Observable';

export class MyComponent implements OnInit{
quote: Quote;

constructor(private quoteService: QuoteService){}

this.quoteService.getQuote(quoteId).subscribe(
c => c,
err => {...}
);
}
}
Parameters :
Name Type Optional Description
Id string No

string identifier representing the quote.

Returns : Observable<Quote>

an observable instance of the quote matching the quote id.

getQuoteAggregatesByApprovalStage
getQuoteAggregatesByApprovalStage(account?: string | Account, aggregateFields?: Array<AggregateFields>, queryFields: Array, groupByFields: Array, filterList: Array<FieldFilter>)

This method returns an aggregate result based on quote aggregate criteria.

Parameters :
Name Type Optional Default value Description
account string | Account Yes

instance of account object or a string identifier of the account.

aggregateFields Array<AggregateFields> Yes

used in query.

queryFields Array<string> No []

list of aobject fields to be part of the query response.

groupByFields Array<string> No []

list of aobject fields to be part of the group by clauses.

filterList Array<FieldFilter> No []

list of FieldFilter records to filter based on the condition.

observable containing aggregate response.

getQuoteById
getQuoteById(quoteId: string, includeLineItems: boolean)

This method returns the quote details based on given quote Id.

Example:

Example :
import { QuoteService, Quote } from '@congarevenuecloud/ecommerce';
import { Observable } from 'rxjs/Observable';
export class MyComponent implements OnInit{
result: Quote
result$: Observable<Quote>;
constructor(private quoteService: QuoteService){}
getQuoteById(quoteId: string){
this.quoteService.getQuoteById(quoteId).subscribe(r => this.result = r);
// or
results$ = this.quoteService.getQuoteById(quoteId);
}
}
Parameters :
Name Type Optional Default value Description
quoteId string No

string identifier of the quote.

includeLineItems boolean No true

boolean parameter that includes items in the quote instance when true.

Returns : Observable<Quote>

observable instance of the quote matching the quote Id.

getQuoteByName
getQuoteByName(name: string)

Method gets a quote by the name

Example:

Example :
import { QuoteService, Quote } from '@congarevenuecloud/ecommerce';
import { Observable } from 'rxjs/Observable';

export class MyComponent implements OnInit{
quote: Quote;

constructor(private quoteService: QuoteService){}

getQuoteByName(name: string){
this.quoteService.getQuoteByName(name).subscribe(q => this.quote = q);
}
}
Parameters :
Name Type Optional Description
name string No

string value representing name of the quote.

Returns : Observable<Quote>

an observable instance of the quote retrieved.

onInit
onInit()
Returns : void
Public publish
publish(quote: Quote)

The method is used to emit the state of the quote.

Parameters :
Name Type Optional Description
quote Quote No

instance of quote.

Returns : void
updateQuote
updateQuote(quoteId: string, payload: Quote)

This method updates the quote object based on the payload passed.

Parameters :
Name Type Optional Description
quoteId string No

string identifier of the quote record.

payload Quote No

quote data to be updated.

Returns : Observable<Quote>

observable containing the updated quote.

Properties

cartItemService
Default value : this.injector.get(CartItemService)
contactService
Default value : this.injector.get(ContactService)
Protected lineItemProductService
Type : LineItemProductService
Default value : this.injector.get(LineItemProductService)
Protected ngZone
Type : NgZone
Default value : this.injector.get(NgZone)
type
Default value : Quote

results matching ""

    No results matching ""