@pliancy/salesforce-cpq-sdk 1.5.0 → 1.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -8,6 +8,7 @@ export declare class Quotes {
|
|
|
8
8
|
getAll(options?: QuoteQuery): Promise<QuoteWithLineItems[]>;
|
|
9
9
|
getById(id: string): Promise<QuoteWithLineItems | null>;
|
|
10
10
|
getByAccountId(accountId: string, options?: QuoteQuery): Promise<QuoteWithLineItems[]>;
|
|
11
|
+
getOriginal(accountId: string): Promise<Quote | undefined>;
|
|
11
12
|
update(quoteId: string, query: Partial<Omit<Quote, 'Id'>>): Promise<SaveResult>;
|
|
12
13
|
updateLineItemQuantities(lineItems: UpdateQuoteLine[]): Promise<SaveResult[]>;
|
|
13
14
|
order(quoteId: string, options?: UpdateQuoteQuery): Promise<SaveResult>;
|
|
@@ -35,6 +35,26 @@ class Quotes {
|
|
|
35
35
|
}
|
|
36
36
|
return quotes;
|
|
37
37
|
}
|
|
38
|
+
async getOriginal(accountId) {
|
|
39
|
+
const quotes = (await this.client.find({
|
|
40
|
+
SBQQ__Account__c: accountId,
|
|
41
|
+
Approval_Status_R__c: 'Approved',
|
|
42
|
+
SBQQ__Type__c: 'Quote',
|
|
43
|
+
}));
|
|
44
|
+
if (!(quotes && quotes.length))
|
|
45
|
+
return undefined;
|
|
46
|
+
// If there's only one quote, return it
|
|
47
|
+
if (quotes.length === 1)
|
|
48
|
+
return quotes.shift();
|
|
49
|
+
// Sort by StartDate with oldest quote first
|
|
50
|
+
quotes.sort((a, b) => {
|
|
51
|
+
const aTime = new Date(a.SBQQ__StartDate__c).getTime();
|
|
52
|
+
const bTime = new Date(b.SBQQ__StartDate__c).getTime();
|
|
53
|
+
return aTime - bTime;
|
|
54
|
+
});
|
|
55
|
+
// Return the first in the array
|
|
56
|
+
return quotes.shift();
|
|
57
|
+
}
|
|
38
58
|
async update(quoteId, query) {
|
|
39
59
|
return this.client.update({ Id: quoteId, ...query });
|
|
40
60
|
}
|