File

projects/congacommerce/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 '@congacommerce/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 '@congacommerce/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 '@congacommerce/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

the id of quote

Returns : Observable<boolean>

true if the operation was successful, false otherwise

convertCartToQuote
convertCartToQuote(quote: Quote)

Method converts the current cart into a quote instance. Sets the business object on the cart to 'Proposal'

Example:

Example :
import { QuoteService, Quote } from '@congacommerce/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()

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

Returns : Observable<Quote>

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

convertQuoteToCart
convertQuoteToCart(quoteId: string)

Method creates new cart and clones the finalized cart linked to the quote Id passed as argument to the new cart and set the new cart as active

Example:

Example :
import { QuoteService, Quote } from '@congacommerce/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
quoteId string No
Returns : Observable<Cart>

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

createCart
createCart(quoteId: string)

Method to create a new cart for quote

Example:

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

export class MyComponent implements OnInit{
result: string;

constructor(private quoteService: QuoteService){}

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

the id of quote

Returns : Observable<string>

the id of new cart for given quote

finalizeQuote
finalizeQuote(quoteId: string)

Method moves the quote status from Draft to Approved.

Example:

Example :
import { QuoteService } from '@congacommerce/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.

Parameters :
Name Type Optional Description
quoteId string No

string identifier of the quote.

Returns : Observable<boolean>

true if the operation was successful, false otherwise.

generateDocument
generateDocument(generateDocumentRequest: GenerateDocument)

Method to generate the document for a custom object

Example:

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

export class MyComponent implements OnInit{
result: string;

constructor(private quoteService: QuoteService){}

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

a request for generating the document for a custom object

Returns : Observable<string>

Id of generated document

getGrandTotalByApprovalStage
getGrandTotalByApprovalStage()

Method to get the aggregate of quote total by approval stage

Example:

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

export class MyComponent implements OnInit{
result: string;

constructor(private quoteService: QuoteService){}

getGrandTotalByApprovalStage(){
this.quoteService.getGrandTotalByApprovalStage().subscribe(r => r);
}
}
}
Returns : Observable<object>

Aggregate of quote total object based on the Approval Stage.

getMyQuotes
getMyQuotes(days?: number, limit: number, pageNumber: number, orderBy: string, orderDirection: "ASC" | "DESC")

Returns a list of quotes for the given user.

Example:

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

export class MyComponent implements OnInit{
quoteList: Array<Quote>;
quoteList$: Observable<Array<Quote>>;

constructor(private quoteService: QuoteService){}

ngOnInit(){
this.quoteService.getMyQuotes().subscribe(q => this.quoteList = q);
// or
this.quoteList$ = this.quoteService.getMyQuotes();
}
}
Parameters :
Name Type Optional Default value Description
days number Yes

the number of days in the past from now with which to retrieve quotes.

limit number No 10

the total number of records to return

pageNumber number No 0
orderBy string No 'CreatedDate'

the field by which to order the records

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

the direction in which to sort the records

a an observable array of quote instances for the current user

getQuoteByName
getQuoteByName(name: string)

Method gets a quote by the name

Example:

Example :
import { QuoteService, Quote } from '@congacommerce/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
name string No
Returns : Observable<Quote>

an empty observable when the process completes

onInit
onInit()
Returns : void

Properties

cartItemService
Default value : this.injector.get(CartItemService)
contactService
Default value : this.injector.get(ContactService)
noteService
Default value : this.injector.get(NoteService)
type
Default value : Quote

results matching ""

    No results matching ""