Knowledge Center

Knowledge Center > Commerce > Zuora for Salesforce Development Resources > Zuora for Salesforce Component Library > Zuora for Salesforce Global Classes > zCharge Class

zCharge Class

The zCharge class provides a number of values and variables relating to subscription charges.

zCharge Properties

The zCharge class includes the following properties.

Property Type Description
BILL_CYCLE_DAY String The day of the month customer is billed for the charge.
BILL_CYCLE_TYPE String

The billing day for the charge. 

You can override the value inherited from the Product Rate Plan Charge, but only when creating a new subscription or a New Product amendment.

The following values are supported:

  • DefaultFromCustomer
  • SpecificDayofMonth:
  • SubscriptionStartDay
  • ChargeTriggerDay
  • SpecificDayofWeek

The SpecificDayofWeek value is available in the version 7.43 or later.

If you set this field toSpecificDayofMonth , you must specify which day of the month as the billing day for the charge in the BILL_CYCLE_DAY field. 

If you set this field to SpecificDayofWeek, you must specify which day of the week as the billing day for the charge in the WEEKLY_BILL_CYCLE_DAY field. 

CHARGE_TYPE String

The type of the charge as defined in the product catalog.

chargeObject SObject Stores the QuoteCharge and QuoteRatePlanCharge field values.
chargeOverrideReferenceId String

The quote rate plan charge id of the initially added charge that is being updated by the current charge.

Read-only.

chargeTiersObjects List
<QuoteCharge_Tier__c>
A list of the custom tiers or default product catalog tiers based on the value of the hasCustomTiers property:
  • If hasCustomTiers is set to true, this property contains a list of the custom tiers.
  • If hasCustomTiers is set to false, this property contains the default tiers from the product catalog.

This property is available as of Zuora Quotes 6.0.

Use the populateCustomChargeTiers method to populate custom tiers.

customfieldNameValueMap MAP A map of the custom field name to the label
DISCOUNT String Discount
DISCOUNT_LEVEL String For the Discount type charge, the level at which the discount should apply to.
EFFECTIVE_PRICE String Effective price of the charge
END_DATE_CONDITION String Defines when the charge ends after the charge trigger date.
fieldsChangedInRulesEngine List < String > Defines all of the charge fields modified by the Rules Engine.
hasCustomTiers Boolean

A flag that you can get or set. Indicates if the current charge has custom tiers. Values:

  • true has custom tiers
  • false has no custom tiers

This property is available as of Zuora Quotes 6.0.

Id Id

If the charge is saved, it has a Salesforce record ID. Otherwise null.

Read-only.

INCLUDED_UNITS String

Included units in the charge

isDiscountEditable Boolean

Specifies whether the DISCOUNT is editable.

The condition is based on the combination of CHARGE_TYPE and MODEL.

Read-only.

isDiscountLevelEditable Boolean

Specifies whether DISCOUNT_LEVEL is editable.

The condition is based on the combination of CHARGE_TYPE and MODEL.

Read-only.

isEffectivePriceEditable Boolean

Specifies whether the EFFECTIVE_PRICE is editable.

The condition is based on the combination of CHARGE_TYPE and MODEL.

Read-only.

isEndDateConditionEditable Boolean

Specifies whether END_DATE_CONDITION is editable.

The condition is based on the combination of CHARGE_TYPE and MODEL.

Read-only.

isIncludedUnitsEditable Boolean

Specifies whether the INCLUDED_UNITS is editable.

The condition is based on the combination of CHARGE_TYPE and MODEL.d MODEL properties combination.

Read-only.

isListPriceBaseEditable Boolean Specifies whether the LIST_PRICE_BASE is editable. 

The condition is based on the combination of CHARGE_TYPE and MODEL.

Read-only.

isPeriodEditable Boolean

Specifies whether PERIOD is editable. 

The condition is based on the combination of CHARGE_TYPE and MODEL.

Read-only.

isQuantityEditable Boolean

Specifies whether the QUANTITY is editable.

The condition is based on the combination of CHARGE_TYPE and MODEL.

Read-only.

isSpecificBillingPeriodEditable Boolean

Specifies whether SPECIFIC_BILLING_PERIOD is editable.

The condition is based on the combination of CHARGE_TYPE, PERIOD, and MODEL.

Read-only.

isSpecificEndDateEditable Boolean

Specifies whether SPECIFIC_BILLING_PERIOD is editable.

The condition is based on the combination of CHARGE_TYPE, END_DATE_CONDITION, and MODEL.

Read-only.

isTotalEditable Boolean

Specifies whether the TOTAL is editable.

The condition is based on the combination of CHARGE_TYPE and MODEL.

Read-only.

isUpToPeriodsEditable Boolean

Specifies whether UPTO_PERIODS is editable.

The condition is based on the combination of CHARGE_TYPE, END_DATE_CONDITION, and MODEL.

Read-only.

isUpToPeriodsTypeEditable Boolean

Specifies whether UPTO_PERIODS_TYPE is editable.

The condition is based on the combination of CHARGE_TYPE, END_DATE_CONDITION, and MODEL.

Read-only.

LIST_PRICE String

The list price of the charge as defined in the product catalog.

Read-only.

LIST_PRICE_BASE String

The term a recurring list price charge is based on.

LIST_TOTAL String

The total list price of the charge as defined in the product catalog.

Read-only.

MODEL String

The charge model as defined in the product catalog.

Read-only.

NAME String

The charge name as defined in the product catalog.

Read-only.

PERIOD String

The recurring period of the charge as defined in the product catalog.

PRODUCT_RATE_PLAN_CHARGE_SFDC_ID String

Used for binding records of Quote Rate Plan Charges to the Product Rate Plan Charge object in the product catalog.

Read-only.

PRODUCT_RATE_PLAN_CHARGE_ZUORA_ID String

Used for binding records of Quote Rate Plan Charges to the Zuora Product Rate Plan Charge.

Read-only.

QUANTITY String Quantity of the charge
SPECIFIC_BILLING_PERIOD String Customizes the number of months or weeks for the billing period of the charge.
SPECIFIC_END_DATE String The specific date on which the charge ends.
SUBSCRIPTION_RATE_PLAN_CHARGE_ID String Used for binding records of Quote Rate Plan Charge to the Zuora Subscription Rate Plan Charge.
TOTAL String Total
UNIT_OF_MEASURE String

The unit of measure used for this charge as defined in the product catalog.

Read-only.

UPTO_PERIODS String Specifies the length of the period during which the charge is active.
UPTO_PERIODS_TYPE String The period type used to define when the charge ends.
WEEKLY_BILL_CYCLE_DAY String

The day of the week as the bill cycle day for the charge.

This field is supported in the version 7.43 or later of Zuora Quotes.

The following values are accepted:

  • Sunday
  • Monday
  • Tuesday
  • Wednesday
  • Thursday
  • Friday
  • Saturday

zCharge Global Methods

The zCharge class includes the following global methods.

Method Return Type Description
getQuoteRatePlanChargeZuoraId string Gets the quote rate plan charge Zuora ID
overrideListPrice
(Decimal newValue)
void

Changes the LIST_PRICE to the specified newValue.
This method does not perform recalculations on other other values on zCharge. See the zQuoteUtil Class methods for  recalculating charges based on pricing fields.

Supported Versions: 7.0+

populateCustomChargeTiers
(List<QuoteCharge_Tier__c> tiers)
void

Populates the custom tiers for required for calculations.

This method is available as of Zuora Quotes 6.0.

Sample Codes

The following sample code sets custom tiers of a volume pricing charge by updating an existing tier and by adding a new tier:

String quoteId = 'a0Ei000000810ZWEAY'; //a0Ei000000810ZWEAY
List<zqu.zChargeGroup> chargeGroups = zqu.zQuoteUtil.getChargeGroups(quoteId);
List<zqu.zChargeGroup> chargeGroupsToUpdate = new List<zqu.zChargeGroup>();
List<zqu__QuoteCharge_Tier__c> customTiers = new List<zqu__QuoteCharge_Tier__c>();
//Get the first charge group which should at least contain one Recurring Volume Pricing Charge.
zqu.zChargeGroup chargeGroup = chargeGroups[0];
for ( zqu.zCharge charge : chargeGroup.zCharges ) {
  if( charge.CHARGE_TYPE == 'Recurring' && charge.MODEL == 'Volume Pricing' ) {
    System.debug( 'custom charge:'+ charge.Id);

    //Specific custom tiers for current volume pricing charge
    charge.hasCustomTiers = true;

    //Get the default tiers from Product Catalog
    List<zqu__QuoteCharge_Tier__c> tiers = charge.chargeTiersObjects;

    //Update last tier through giving it 50% discount
    tiers.get( tiers.size() - 1 ).zqu__Effective_Price__c = 
      tiers.get( tiers.size() - 1 ).zqu__Price__c * 0.5;

    //Please note the discount should be '50', not '0.5'
    tiers.get( tiers.size() - 1 ).zqu__Discount__c = 50;

    //Reset the 'EndingUnit__c' for last tier
    tiers.get( tiers.size() - 1 ).zqu__EndingUnit__c = 30;

    zqu__QuoteCharge_Tier__c tier = new zqu__QuoteCharge_Tier__c();
    tier.name = String.valueOf( tiers.size() + 1 );
    tier.zqu__Tier__c = tiers.size() + 1;

    //Please set 'StartingUnit__c' correctly based on UOM precision.
    tier.zqu__StartingUnit__c = 30 + 1;
    tier.zqu__EndingUnit__c = 40;
    tier.zqu__Effective_Price__c = 5;
    tier.zqu__Price__c = 10;
    //Please note the discount should be '50', not '0.5'
    tier.zqu__Discount__c = 50;
    tier.zqu__PriceFormat__c = 'Per Unit';

    //Add a new tier into the default tiers
    tiers.add( tier );

    //We should make sure we pass all tiers for current charge.
    charge.populateCustomChargeTiers( tiers );

    break;
  }
}
// Persist the updates together with custom tiers
chargeGroupsToUpdate = zqu.zQuoteUtil.updateChargeGroups(chargeGroups);
zqu.zChargeGroup updatedChargeGroups = chargeGroupsToUpdate[0];
for ( zqu.zCharge charge : updatedChargeGroups.zCharges ) {
  if( charge.hasCustomTiers == true ) {
    System.debug('Charge Name: ' + charge.Name + ' has custom tiers:' + charge.chargeTiersObjects);
  }
}
The following sample code shows how to set and retrieve custom field values on the Quote Rate Plan Charge through the zCharge class. See GlobalCustomFieldDefinition Class for more information about custom fields in Zuora for Salesforce development.
// Define custom field definitions before getting charge groups. 
zqu.GlobalCustomFieldDefinition.CHARGE_FIELDS = 
  new Set<String>{ 'My_Custom_Field_1__c', 'My_Custom_Field_2__c' };

chargeGroupsToUpdate = zqu.zQuoteUtil.getChargeGroups(chargeGroups);
zqu.zChargeGroup updatedChargeGroups = chargeGroupsToUpdate[0];
for ( zqu.zCharge charge : updatedChargeGroups.zCharges ) {
  // Read a custom field on zCharge
  charge.chargeObject.get('My_Custom_Field_1__c');

  // Update a custom field on zCharg
  charge.chargeObject.put('My_Custom_Field_1__c', new-value-to-assign);
}
zqu.zQuoteUtil.updateChargeGroups(chargeGroups);
Last modified
13:19, 20 Mar 2017

Tags

This page has no custom tags.

Classifications

(not set)