Skip to content

Commit

Permalink
added query criteria section for pricebook to sync preferences step (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
arnoldezeolisa authored Feb 15, 2023
1 parent 4edfe53 commit a03ccca
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 10 deletions.
8 changes: 5 additions & 3 deletions sfdx/force-app/main/default/classes/setupAssistant.cls
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,8 @@ public with sharing class setupAssistant {
List<String> filterFields = new List<String> {
'Product2',
'Order',
'Account'
'Account',
'PricebookEntry'
};

//gets filter fields and values for front end
Expand All @@ -573,13 +574,14 @@ public with sharing class setupAssistant {

//sends updated sync preference data to the ruby service and saves the values
@AuraEnabled
public static String saveFilterSettings(String productFilter, String orderFilter, String accountFiter) {
public static String saveFilterSettings(String productFilter, String orderFilter, String accountFiter, String priceBookFilter) {
responseData rd = new responseData();
try {
Map<String, String> queryFilterMap = new Map<String, String> {
'Product2' => productFilter,
'Order' => orderFilter,
'Account' => accountFiter
'Account' => accountFiter,
'PricebookEntry' => priceBookFilter
};

List<Map<String, Object>> validationErrorMapList = new List<Map<String, Object>> ();
Expand Down
4 changes: 2 additions & 2 deletions sfdx/force-app/main/default/classes/test_setupAssistant.cls
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ public with sharing class test_setupAssistant {

Test.startTest();
Test.setMock(HttpCalloutMock.class, new stripeConnectionSuccessMock());
String response = setupAssistant.saveFilterSettings('Id != null', 'Ids != null', '');
String response = setupAssistant.saveFilterSettings('Id != null', 'Ids != null', '', '');
Map<String, Object> responseMap = (Map<String, Object>)JSON.deserializeUntyped(response);
Test.stopTest();

Expand All @@ -491,7 +491,7 @@ public with sharing class test_setupAssistant {

Test.startTest();
Test.setMock(HttpCalloutMock.class, new stripeConnectionSuccessMock());
String response = setupAssistant.saveFilterSettings('Id != null', 'Id != null', 'Id != null');
String response = setupAssistant.saveFilterSettings('Id != null', 'Id != null', 'Id != null', 'Id != null');
Map<String, Object> responseMap = (Map<String, Object>)JSON.deserializeUntyped(response);
Test.stopTest();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,8 @@ <h4 class="slds-text-heading_small slds-m-bottom_xx-small">
Custom Product Sync Conditions
</h4>
<p>
If products or pricebooks are manually synced using the button below, all products are synced to Stripe. To customize which products are synced to Stripe, specify a SOQL <code>WHERE</code> clause here.
This custom query determines which products will be synchronized when the "Sync All Products" or "Sync All Pricebooks" button is pressed below. Products that do not meet the criteria defined here are excluded from the sync to Stripe.
If products are manually synced using the button below, all products are synced to Stripe. To customize which products are synced to Stripe, specify a SOQL <code>WHERE</code> clause here.
This custom query determines which products will be synchronized when the "Sync All Products" button is pressed below. Products that do not meet the criteria defined here are excluded from the sync to Stripe.
This conditional will <strong>not</strong> limit which products connected to an activated order are synced.
</p>
</div>
Expand All @@ -177,6 +177,24 @@ <h4 class="slds-text-heading_small slds-m-bottom_xx-small">
</div>
</div>
</div>
<div class="stripe-settings__item slds-grid">
<div class="slds-col_bump-right">
<h4 class="slds-text-heading_small slds-m-bottom_xx-small">
Custom PricebookEntry Sync Conditions
</h4>
<p>
If pricebooks are manually synced using the button below, all pricebooks are synced to Stripe. To customize which pricebooks are synced to Stripe, specify a SOQL <code>WHERE</code> clause here.
This custom query determines which pricebooks will be synchronized when the "Sync All Pricebooks" button is pressed below. PriceBooks that do not meet the criteria defined here are excluded from the sync to Stripe.
This conditional will <strong>not</strong> limit which pricebooks connected to an activated order are synced.
</p>
</div>
<div class="slds-col slds-p-left_xx-large slds-size_1-of-3">
<lightning-input label="Include PricebookEntry records where:" type="text" value={priceBookFilter} placeholder="Provide filter logic..." class={priceBookFilterClassList} onchange={updatePriceBookFilter}></lightning-input>
<div if:true={hasPriceBookFilterError} class="slds-form-element__help slds-text-color_error">
{priceBookFilterError}
</div>
</div>
</div>

<div if:true={isSandbox} class="stripe-settings__item slds-grid">
<div class="slds-col_bump-right">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export default class SyncPreferencesStep extends LightningElement {
@track orderFilter;
@track accountFilter;
@track productFilter;
@track priceBookFilter;
@track isSandbox;
@track syncProductsDisabled = false;
@track syncPricebooksDisabled = false;
Expand All @@ -43,7 +44,7 @@ export default class SyncPreferencesStep extends LightningElement {
accountFilterError = '';
orderFilterError = '';
productFilterError = '';

priceBookFilterError = '';

// DEV NOTE: Manual Translation additions: refactor or remove these //
manualTranslationValue = '';
Expand Down Expand Up @@ -167,6 +168,7 @@ export default class SyncPreferencesStep extends LightningElement {
this.orderFilter = filterSettingsResponseData.results.Order;
this.accountFilter = filterSettingsResponseData.results.Account;
this.productFilter = filterSettingsResponseData.results.Product2;
this.priceBookFilter = filterSettingsResponseData.results.PricebookEntry;

} catch (error) {
let errorMessage = getErrorMessage(error);
Expand Down Expand Up @@ -240,6 +242,11 @@ export default class SyncPreferencesStep extends LightningElement {
this.orderFilter = updatedValue;
}

updatePriceBookFilter(event) {
let updatedValue = this.valueChange(this.priceBookFilter, event.detail.value)
this.priceBookFilter = updatedValue;
}

valueChange(savedValue, updatedValue) {
if(savedValue !== updatedValue) {
this.dispatchEvent(new CustomEvent('valuechange'));
Expand Down Expand Up @@ -295,6 +302,10 @@ export default class SyncPreferencesStep extends LightningElement {
return this.productFilterError.length > 0;
}

get hasPriceBookFilterError () {
return this.priceBookFilterError.length > 0;
}

get accountFilterClassList() {
return (this.accountFilterError.length > 0? 'slds-has-error' : '');
}
Expand All @@ -307,6 +318,10 @@ export default class SyncPreferencesStep extends LightningElement {
return (this.productFilterError.length > 0 ? 'slds-has-error' : '');
}

get priceBookFilterClassList() {
return (this.priceBookFilterError.length > 0 ? 'slds-has-error' : '');
}

@api async saveModifiedSyncPreferences() {
let saveSuccess = false;
try {
Expand All @@ -325,10 +340,12 @@ export default class SyncPreferencesStep extends LightningElement {
this.accountFilterError = '';
this.productFilterError = '';
this.orderFilterError = '';
this.priceBookFilterError = '';
const updatedFilterSettings = await saveFilterSettings({
productFilter: this.productFilter,
orderFilter: this.orderFilter,
accountFiter: this.accountFilter
accountFiter: this.accountFilter,
priceBookFilter: this.priceBookFilter
});
const filterResponseData = JSON.parse(updatedFilterSettings);
if (filterResponseData.isSuccess ) {
Expand All @@ -350,7 +367,10 @@ export default class SyncPreferencesStep extends LightningElement {
} else if (objectWithError === 'Order') {
// Set order validation message
this.orderFilterError = exceptionThrown;
}
} else if (objectWithError === 'PricebookEntry') {
// Set pricebook validation message
this.priceBookFilterError = exceptionThrown;
}
}
return;
} else {
Expand Down

0 comments on commit a03ccca

Please sign in to comment.