Use Billing module Java API
- Former user (Deleted)
Owned by Former user (Deleted)
 Add subscription service usage
Example
... @EJB private CRMBOSubscriptionBean subscriptionBean; @EJB private CRMBOSubscriptionServiceBean subscriptionServiceBean; @EJB private CRMBOProductBean productBean; @EJB private CRMBOUsageServiceCatalogBean usageServiceCatalogBean; @EJB private CRMProcessServiceUsageAdditionBean processServiceUsageAdditionBean; ... Â public CRMDOSubscriptionAction addSubscriptionServiceUsage(String subscriptionNumber, String productCode, String subscriptionServiceID, BigDecimal usageAmount, BillingDirectiveState billingDirective, String uscName){ ArrayList<String> associations = new ArrayList<String>(); associations.add("accountReceivable"); associations.add("accountReceivable.billToAddress"); associations.add("type"); CRMDOSubscription subscription = subscriptionBean.loadByNumber(subscriptionNumber); Â //Load product ArrayList<String> productAssociations = new ArrayList<String>(); productAssociations.add("type"); productAssociations.add("type.udrType"); productAssociations.add("type.udrType.udrTypeUOM"); CRMDOProduct product = productBean.loadByCode(productCode); //Load subscription service CRMDOSubscriptionService subscriptionService =subscriptionServiceBean.load(subscriptionServiceID); Â //Load usage service catalog CRMDOUsageServiceCatalog usageServiceCatalog = usageServiceCatalogBean.loadByName(uscName); Â //Create a set of UDRs Set<CRMDOUdr> udrs = new HashSet<CRMDOUdr>(); Â //Construct UDR(s) CRMDOUdr udr = udrBean.construct(subscription, subscriptionService, product); udr.setUsageAmount(usageAmount); udr.setBillingDirective(billingDirective); if(billingDirective.equals(BillingDirectiveState.NOT_TO_BE_BILLED)) { udr.setRatingState(UdrRatingState.COMPLETED); } udr.setUsageServiceCatalog(usageServiceCatalog); Â //Add UDR to UDRS set udrs.add(udr); Â //Construct service usage addition ServiceUsageAddition serviceUsageAddition = processServiceUsageAdditionBean.constructServiceUsageAddition(subscription); serviceUsageAddition.setUdrsToBeProcessed(udrs); Â CRMDOSubscriptionAction subscriptionAction = processServiceUsageAdditionBean.submit(serviceUsageAddition); Â return subscriptionAction ; }
 Bill Subscriber
Example
... @EJB private CRMBOSubscriptionBean subscriptionBean; @EJB private CRMProcessSubscriptionBillBean processSubscriptionBillBean; @EJB private CRMBOAccountReceivableBean accountBean; @EJB private CRMBOContactInformationBean contactInformationBean; ... Â public CRMDOSubscriptionAction billSubscription(String subscriptionNumber, Date asOfDate){ CRMDOSubscription subscription = subscriptionBean.loadByNumber(subscriptionNumber); Â if(subscription.getRatingState() != null && subscription.getRatingState().equals(SubscriptionRatingState.COMPLETED)) { throw new InvalidValueException(getCRMSession(), "subscription. Subscription is already billed"); } Â SubscriptionBill subscriptionBill = processSubscriptionBillBean.constructSubscriptionBill(subscription); Â CRMDOAccountReceivable account = (CRMDOAccountReceivable)accountBean.load(subscription.getAccountReceivable().getId()); account.setContactInformation((CRMDOContactInformation)contactInformationBean.load(subscription.getAccountReceivable().getContactInformation().getId())); subscriptionBill.getSubscription().setAccountReceivable(account); BillType billtype = subscription.getEffectiveBillingTerm().getBillingTermScheme().getBillingType(); if (billtype!=null && billtype.equals(BillType.NORMAL)) { if (asOfDate!=null) { processSubscriptionBillBean.setBillAsOfDate(subscriptionBill, BillAsOfDateOption.SPECIFIC_DATE, asOfDate); } else { //as of date is the current date processSubscriptionBillBean.setBillAsOfDate(subscriptionBill, BillAsOfDateOption.SCHEDULED_DATE, null); } } else //if it's PREPAID { Date asOfDate = subscriptionBean.getNextLatestRatedToDate(subscription); if(asOfDate!=null && asOfDate.after(getCurrentDate())) { processSubscriptionBillBean.setBillAsOfDate(subscriptionBill, BillAsOfDateOption.SPECIFIC_DATE, asOfDate); } else { //as of date is the current date processSubscriptionBillBean.setBillAsOfDate(subscriptionBill, BillAsOfDateOption.SCHEDULED_DATE, null); } } Â CRMDOSubscriptionAction subscriptionAction = processSubscriptionBillBean.submit(subscriptionBill); return subscriptionAction; }
Â
Â