Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Features/products standard pricebook #87

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ If you want to use a scratch org to play with Snowfakery, you may want to instal
- Optional for EDA orgs: **Install Advisor Link** Run `cci flow run sal:install_base --org dev`
- **Install NPSP** Run `cci flow run npsp:install_prod --org dev`

#### OSC Collaboration
**MembershipSchemaAndBenefits**
- **Create memberhisp cci org definition** Run `cci org scratch dev membership --days 30`
- **Install OSC MembershipSchemaAndBenefits** Run `cci flow run osc_memberships:dev_org --org membership`
- **Load OSC MembershipSchemaAndBenefits Snofakery Generated Data** Run `cci flow run osc_memberships_project --org membership`

### Instructions for the Collaborators

There are several open issues suggesting new recipes we need and fixes to existing recipes. We also welcome contributions of new recipes we haven't though of yet.
Expand Down
10 changes: 6 additions & 4 deletions cumulusci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ sources:
github: https://github.com/SalesforceFoundation/NPSP
sal:
github: https://github.com/SalesforceFoundation/SAL-CumulusCI
osc_memberships:
github: https://github.com/SFDO-Community-Sprints/MembershipSchemaAndBenefits

tasks:
robot:
Expand Down Expand Up @@ -65,10 +67,10 @@ flows:
task: load_membership_products
3:
task: load_membership_opportunities
npsp_settings:
class_path: cumulusci.tasks.bulkdata.generate_and_load_data_from_yaml.GenerateAndLoadDataFromYaml
options:
generator_yaml: snowfakery_samples/npsp/NPSP_Settings.recipe.yml
# npsp_settings:
# class_path: cumulusci.tasks.bulkdata.generate_and_load_data_from_yaml.GenerateAndLoadDataFromYaml
# options:
# generator_yaml: snowfakery_samples/npsp/NPSP_Settings.recipe.yml

# cci flow run npsp_scratch -o npsp_settings__num_records 2 would set a particular option for the subflow
npsp_scratch:
Expand Down
106 changes: 54 additions & 52 deletions snowfakery_samples/OSC/MembershipSchemaAndBenefits_basic.recipe.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,73 +22,75 @@

### ----------- [ CLI RUN ]---------- ###

# cci task run generate_and_load_from_yaml --generator_yaml snowfakery_samples/OSC/MembershipSchemaAndBenefits_basic.recipe.yml --num_records 1 --num_records_tablename Opportunity --org dev
# snowfakery --output-format json --output-file src/foo.json snowfakery_samples/OSC/MembershipSchemaAndBenefits_basic.recipe.yml --plugin-option org_name dev
# cci task run snowfakery --recipe snowfakery_samples/OSC/MembershipSchemaAndBenefits_basic.recipe.yml --drop_missing_schema True --org membership
# snowfakery --output-format json --output-file foo.json snowfakery_samples/OSC/MembershipSchemaAndBenefits_basic.recipe.yml --plugin-option org_name membership

### ----------- [ Recipe Starts ]---------- ###

- plugin: snowfakery.standard_plugins.Salesforce.SOQLDataset

- object: Opportunity
count: 1
- object: temp
fields:
Type: Membership
CloseDate:
__oppDate:
date_between:
start_date: -1y
end_date: today

- object: Contact
fields:
# MembershipSchemaAndBenefits custom fields -- expected to be handled by Apex
Last_Membership_Start_Date__c: ${{temp.__oppDate}}
First_Membership_Start_Date__c: ${{temp.__oppDate}}
Membership_End_Date__c: ${{temp.__oppDate+relativedelta(months=12)}}
Membership_Status__c:
random_choice:
- Former
- Lapsed
- Renewal
- Current
Membership_Type__c:
random_choice:
- Individual
- Household
- Corporate
FirstName: ${{fake.firstname}}
LastName: ${{fake.lastname}}
Email: ${{fake.email}}
AccountId:
- object: Account
fields:
Name:
if:
- choice:
when: ${{Contact.Membership_Type__c == 'Individual'}}
pick: ${{Contact.FirstName}} ${{Contact.LastName}} Household
- choice:
when: ${{Contact.Membership_Type__c == 'Household'}}
pick: ${{Contact.FirstName}} ${{Contact.LastName}} Household
- choice:
when: ${{Contact.Membership_Type__c == 'Corporate'}}
pick: ${{fake.company}}

# MembershipSchemaAndBenefits custom fields -- expected to be handled by Apex
First_Membership_Start_Date__c: ${{temp.__oppDate}}
Membership_End_Date__c: ${{temp.__oppDate+relativedelta(months=12)}}
Membership_Status__c: ${{Contact.Membership_Status__c}}
Membership_Type__c: ${{Contact.Membership_Type__c}}

# Primary_Membership__c: # Apex automated
# reference: Membership__c

- object: Opportunity
count: 1
fields:
Type: Membership
CloseDate: ${{temp.__oppDate}}
Description:
fake.text:
max_nb_chars: 100

StageName: Closed Won
# Contact

ContactId:
- object: Contact
fields:
# MembershipSchemaAndBenefits custom fields -- expected to be handled by Apex
Last_Membership_Start_Date__c: ${{Opportunity.CloseDate}}
First_Membership_Start_Date__c: ${{Opportunity.CloseDate}}
Membership_End_Date__c: ${{date(Opportunity.CloseDate)+relativedelta(months=12)}}
Membership_Status__c:
random_choice:
- Former
- Lapsed
- Renewal
- Current
Membership_Type__c:
random_choice:
- Individual
- Household
- Corporate
FirstName: ${{fake.firstname}}
LastName: ${{fake.lastname}}
Email: ${{fake.email}}
AccountId:
- object: Account
fields:
Name:
if:
- choice:
when: ${{Contact.Membership_Type__c == 'Individual'}}
pick: ${{Contact.FirstName}} ${{Contact.LastName}} Household
- choice:
when: ${{Contact.Membership_Type__c == 'Household'}}
pick: ${{Contact.FirstName}} ${{Contact.LastName}} Household
- choice:
when: ${{Contact.Membership_Type__c == 'Corporate'}}
pick: ${{fake.company}}

# MembershipSchemaAndBenefits custom fields -- expected to be handled by Apex
First_Membership_Start_Date__c: ${{Opportunity.CloseDate}}
Membership_End_Date__c: ${{Opportunity.CloseDate+relativedelta(months=12)}}
Membership_Status__c: ${{Contact.Membership_Status__c}}
Membership_Type__c: ${{Contact.Membership_Type__c}}

# Primary_Membership__c: # Apex automated
# reference: Membership__c

Name: ${{Account.Name}}-${{Type}}-${{(CloseDate).year}}
AccountId:
reference: Account
Expand Down
56 changes: 56 additions & 0 deletions snowfakery_samples/npsp/Products_Standard_npsp.recipe.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
### ------------- [ ORDER OF INSERT ]------------ ###
# 1-0. Product2 [1/3]
# 1-1. PricebookEntry [1/3]

### ----------- [ Products_Standard_npsp.recipe.yml Summary ]---------- ###
# This recipe creates [1] product among three choices: "Individual Membership", "Houshold Membership", "Corporate Membership"
# Creates 1 Pricebook entry to the standard price book
# This recipe queries into a connected cci org to retrieve Standard Pricebook Id

### ----------- [ CLI RUN ]---------- ###

# cci task run generate_and_load_from_yaml --generator_yaml snowfakery_samples/npsp/Products_Standard_npsp.recipe.yml --org dev
# snowfakery snowfakery_samples/npsp/Products_Standard_npsp.recipe.yml --output-format json --output-file snowfakery_samples/temp/output.json --plugin-option org_name dev

### ----------- [ Recipe Starts ]---------- ###

- plugin: snowfakery.standard_plugins.Salesforce.SOQLDataset

- object: Product2
nickname: p1
fields:
Name:
random_choice:
- Individual Membership
- Household Membership
- Corporate Membership
ProductCode:
if:
- choice:
when: ${{Name == 'Individual Membership'}}
pick: INDVDL-MEMBER-ANNUAL
- choice:
when: ${{Name == 'Household Membership'}}
pick: HSHLD-MEMBER-ANNUAL
- choice:
when: ${{Name == 'Corporate Membership'}}
pick: CRPRT-MEMBER-ANNUAL

Description:
fake.text:
max_nb_chars: 50
StockKeepingUnit: #sku
Family: Annual Membership

- object: PricebookEntry
fields:
IsActive: true
UnitPrice: 250
Product2Id:
reference: p1
__pricebook_from_salesforce:
SOQLDataset.shuffle:
fields: Id
from: Pricebook2
Pricebook2Id: ${{__pricebook_from_salesforce.Id}}