@pliancy/salesforce-cpq-sdk 1.3.0 → 1.5.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.
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { QuoteLine } from './quote-lines/quote-line.types';
|
|
2
|
+
import { QueryCondition, Schema, SObjectUpdateRecord } from 'jsforce';
|
|
2
3
|
export interface Quote {
|
|
3
4
|
Id: string;
|
|
4
5
|
OwnerId: string;
|
|
@@ -13,6 +14,7 @@ export interface Quote {
|
|
|
13
14
|
LastActivityDate?: string;
|
|
14
15
|
LastViewedDate: string;
|
|
15
16
|
LastReferencedDate: string;
|
|
17
|
+
ApprovalStatus__c: ApprovalStatus;
|
|
16
18
|
SBQQ__Account__c: string;
|
|
17
19
|
SBQQ__BillingCity__c: string;
|
|
18
20
|
SBQQ__BillingCountry__c: string;
|
|
@@ -97,3 +99,6 @@ export type QuoteWithLineItems = Quote & {
|
|
|
97
99
|
};
|
|
98
100
|
export type UpdateQuoteLine = Pick<QuoteLine, 'Id' | 'SBQQ__Quantity__c'>;
|
|
99
101
|
export type UpdateQuoteLinesRequest = UpdateQuoteLine[];
|
|
102
|
+
export type ApprovalStatus = 'Approved' | 'Rejected' | 'Pending' | 'Approval Not Required' | 'Required : Not Sent for Approval';
|
|
103
|
+
export type QuoteQuery = QueryCondition<Schema, 'SBQQ__Quote__c'>;
|
|
104
|
+
export type UpdateQuoteQuery = SObjectUpdateRecord<Schema, 'SBQQ__Quote__c'>;
|
|
@@ -1,13 +1,16 @@
|
|
|
1
|
-
import { Connection, SaveResult
|
|
2
|
-
import { QuoteWithLineItems,
|
|
1
|
+
import { Connection, SaveResult } from 'jsforce';
|
|
2
|
+
import { Quote, QuoteQuery, QuoteWithLineItems, UpdateQuoteLine, UpdateQuoteQuery } from './quote.types';
|
|
3
3
|
export declare class Quotes {
|
|
4
4
|
private readonly connection;
|
|
5
5
|
private readonly client;
|
|
6
6
|
private readonly items;
|
|
7
7
|
constructor(connection: Connection);
|
|
8
|
+
getAll(options?: QuoteQuery): Promise<QuoteWithLineItems[]>;
|
|
8
9
|
getById(id: string): Promise<QuoteWithLineItems | null>;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
updateLineItemQuantities(lineItems:
|
|
12
|
-
order(quoteId: string): Promise<SaveResult>;
|
|
10
|
+
getByAccountId(accountId: string, options?: QuoteQuery): Promise<QuoteWithLineItems[]>;
|
|
11
|
+
update(quoteId: string, query: Partial<Omit<Quote, 'Id'>>): Promise<SaveResult>;
|
|
12
|
+
updateLineItemQuantities(lineItems: UpdateQuoteLine[]): Promise<SaveResult[]>;
|
|
13
|
+
order(quoteId: string, options?: UpdateQuoteQuery): Promise<SaveResult>;
|
|
14
|
+
approve(quoteId: string): Promise<SaveResult>;
|
|
15
|
+
private buildQuery;
|
|
13
16
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Quotes = void 0;
|
|
4
|
-
const jsforce_1 = require("jsforce");
|
|
5
4
|
const quote_lines_1 = require("./quote-lines/quote-lines");
|
|
6
5
|
class Quotes {
|
|
7
6
|
constructor(connection) {
|
|
@@ -9,6 +8,16 @@ class Quotes {
|
|
|
9
8
|
this.client = this.connection.sobject('SBQQ__Quote__c');
|
|
10
9
|
this.items = new quote_lines_1.QuoteLines(this.connection);
|
|
11
10
|
}
|
|
11
|
+
async getAll(options) {
|
|
12
|
+
const query = this.buildQuery({}, options);
|
|
13
|
+
const quotes = (await this.client.find(query));
|
|
14
|
+
if (!(quotes && quotes.length))
|
|
15
|
+
return [];
|
|
16
|
+
for (const quote of quotes) {
|
|
17
|
+
quote.lineItems = await this.items.getByQuoteId(quote.Id);
|
|
18
|
+
}
|
|
19
|
+
return quotes;
|
|
20
|
+
}
|
|
12
21
|
async getById(id) {
|
|
13
22
|
const quote = (await this.client.findOne({ Id: id }));
|
|
14
23
|
if (!quote)
|
|
@@ -16,23 +25,8 @@ class Quotes {
|
|
|
16
25
|
quote.lineItems = await this.items.getByQuoteId(quote.Id);
|
|
17
26
|
return quote;
|
|
18
27
|
}
|
|
19
|
-
async
|
|
20
|
-
const query = { SBQQ__Account__c: accountId };
|
|
21
|
-
if (options)
|
|
22
|
-
Object.assign(query, options);
|
|
23
|
-
const quote = (await this.client.findOne(query));
|
|
24
|
-
if (!quote)
|
|
25
|
-
return null;
|
|
26
|
-
quote.lineItems = await this.items.getByQuoteId(quote.Id);
|
|
27
|
-
return quote;
|
|
28
|
-
}
|
|
29
|
-
async getQuotesForBillingPeriod(startDate, endDate, options) {
|
|
30
|
-
const query = {
|
|
31
|
-
SBQQ__StartDate__c: { $eq: new jsforce_1.SfDate(startDate) },
|
|
32
|
-
SBQQ__EndDate__c: { $eq: new jsforce_1.SfDate(endDate) },
|
|
33
|
-
};
|
|
34
|
-
if (options)
|
|
35
|
-
Object.assign(query, options);
|
|
28
|
+
async getByAccountId(accountId, options) {
|
|
29
|
+
const query = this.buildQuery({ SBQQ__Account__c: accountId }, options);
|
|
36
30
|
const quotes = (await this.client.find(query));
|
|
37
31
|
if (!(quotes && quotes.length))
|
|
38
32
|
return [];
|
|
@@ -41,11 +35,25 @@ class Quotes {
|
|
|
41
35
|
}
|
|
42
36
|
return quotes;
|
|
43
37
|
}
|
|
38
|
+
async update(quoteId, query) {
|
|
39
|
+
return this.client.update({ Id: quoteId, ...query });
|
|
40
|
+
}
|
|
44
41
|
async updateLineItemQuantities(lineItems) {
|
|
45
42
|
return this.items.update(lineItems);
|
|
46
43
|
}
|
|
47
|
-
async order(quoteId) {
|
|
48
|
-
|
|
44
|
+
async order(quoteId, options) {
|
|
45
|
+
const query = this.buildQuery({ Id: quoteId, SBQQ__Ordered__c: true }, options);
|
|
46
|
+
return this.client.update(query);
|
|
47
|
+
}
|
|
48
|
+
async approve(quoteId) {
|
|
49
|
+
await this.connection.process.approval.submit(quoteId);
|
|
50
|
+
return this.client.update({ Id: quoteId, ApprovalStatus__c: 'Approved' });
|
|
51
|
+
}
|
|
52
|
+
buildQuery(base, options) {
|
|
53
|
+
const query = { ...base };
|
|
54
|
+
if (options)
|
|
55
|
+
Object.assign(query, options);
|
|
56
|
+
return query;
|
|
49
57
|
}
|
|
50
58
|
}
|
|
51
59
|
exports.Quotes = Quotes;
|