@pliancy/salesforce-cpq-sdk 3.14.0 → 3.16.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.
package/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { SaveResult, SaveError } from 'jsforce';
1
2
  export { Cpq } from './lib/cpq';
2
3
  export * from './lib/accounts/accounts';
3
4
  export * from './lib/accounts/account.types';
@@ -16,3 +17,4 @@ export * from './lib/orders/order.types';
16
17
  export * from './lib/orders/order-items/order-items';
17
18
  export * from './lib/orders/order-items/order-item.types';
18
19
  export * from './lib/custom/custom';
20
+ export { SaveResult, SaveError };
@@ -1,4 +1,8 @@
1
1
  import { Address, QueryCondition, Schema } from 'jsforce';
2
+ import { Quote } from '../quotes/quote.types';
3
+ import { Product } from '../products/product.types';
4
+ import { PriceBookEntry } from '../price-books/entries/price-book-entries.types';
5
+ import { QuoteLine } from '../quotes/quote-lines/quote-line.types';
2
6
  export interface Contract {
3
7
  [index: string]: any;
4
8
  Id: string;
@@ -84,6 +88,61 @@ export interface Contract {
84
88
  SBQQ__ActiveContract__c: number;
85
89
  SBQQ__OpportunityPricebookId__c: string;
86
90
  }
91
+ export interface NestedContractAmendmentResponseObject {
92
+ attributes: {
93
+ type: 'Account' | 'User' | 'Pricebook2' | 'Opportunity';
94
+ url: string;
95
+ };
96
+ Id: string;
97
+ }
98
+ export interface AmendmentQuoteLine {
99
+ record: QuoteLine & {
100
+ SBQQ__Product__c: string;
101
+ SBQQ__Product__r: Product & {
102
+ PricebookEntries: {
103
+ records: PriceBookEntry[];
104
+ };
105
+ }[];
106
+ };
107
+ }
108
+ export interface ContractAmendmentResponse {
109
+ record: Quote & {
110
+ SBQQ__Account__r: NestedContractAmendmentResponseObject & {
111
+ Name: string;
112
+ SBQQ__RenewalModel__c: string;
113
+ SBQQ__RenewalPricingMethod__c: string;
114
+ };
115
+ SBQQ__MasterEvergreenContract__r: NestedContractAmendmentResponseObject & {
116
+ ContractNumber: string;
117
+ };
118
+ SBQQ__SalesRep__r: NestedContractAmendmentResponseObject & {
119
+ Name: string;
120
+ };
121
+ SBQQ__PriceBook__r: NestedContractAmendmentResponseObject & {
122
+ Name: string;
123
+ };
124
+ SBQQ__Opportunity2__r: NestedContractAmendmentResponseObject & {
125
+ SBQQ__PrimaryQuote__c: string;
126
+ Pricebook2Id: string;
127
+ AccountId: string;
128
+ };
129
+ };
130
+ lineItems: AmendmentQuoteLine[];
131
+ lineItemGroups: string[];
132
+ isPartial: boolean;
133
+ hasMultiSegmentLines: boolean;
134
+ channelDiscountsOffList: boolean;
135
+ calculationRequired: boolean;
136
+ applyPartnerDiscountFirst: boolean;
137
+ applyAdditionalDiscountLast: boolean;
138
+ }
139
+ export interface AmendmentQuote extends Quote {
140
+ lineItems: (QuoteLine & {
141
+ PricebookEntries: {
142
+ records: PriceBookEntry[];
143
+ };
144
+ })[];
145
+ }
87
146
  export type ContractStatus = 'Draft' | 'Activated' | 'In Approval Process';
88
147
  export declare const ContractsCollection = "Contract";
89
148
  export type ContractEntity = typeof ContractsCollection;
@@ -1,5 +1,5 @@
1
1
  import { Connection } from 'jsforce';
2
- import { Contract, ContractQuery, ContractEntity } from './contract.types';
2
+ import { Contract, ContractQuery, ContractEntity, AmendmentQuote } from './contract.types';
3
3
  import { Base } from '../base/base';
4
4
  export declare class Contracts extends Base<ContractEntity> {
5
5
  private readonly connection;
@@ -8,4 +8,7 @@ export declare class Contracts extends Base<ContractEntity> {
8
8
  getById(id: string): Promise<Contract | null>;
9
9
  getLatestActivatedByAccountId(id: string, options?: ContractQuery): Promise<Contract | undefined>;
10
10
  getDraftsByBillingPeriod(accountId: string, start: string, end: string): Promise<Contract[]>;
11
+ createAmendmentQuote(contractId: string, body?: Object, options?: {
12
+ headers?: any;
13
+ }): Promise<AmendmentQuote>;
11
14
  }
@@ -37,5 +37,20 @@ class Contracts extends base_1.Base {
37
37
  EndDate: { $lte: new jsforce_1.SfDate(end) },
38
38
  });
39
39
  }
40
+ async createAmendmentQuote(contractId, body = {}, options = {}) {
41
+ const res = await this.connection.apex.patch(`/SBQQ/ServiceRouter?loader=SBQQ.ContractManipulationAPI.ContractAmender&uid=${contractId}`, body, options);
42
+ // return normalized AmendmentQuote
43
+ return {
44
+ ...res.record,
45
+ lineItems: res.record.lineItems.map((l) => ({
46
+ ...l.record,
47
+ SBQQ__Product__r: {
48
+ PricebookEntries: l.record.SBQQ__Product__r.PricebookEntries.records.map((r) => ({
49
+ ...r.record,
50
+ })),
51
+ },
52
+ })),
53
+ };
54
+ }
40
55
  }
41
56
  exports.Contracts = Contracts;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pliancy/salesforce-cpq-sdk",
3
- "version": "3.14.0",
3
+ "version": "3.16.0",
4
4
  "main": "dist/index.js",
5
5
  "license": "MIT",
6
6
  "description": "Salesforce CPQ SDK for Node.js",