|
| 1 | +package com.intuit.developer.sampleapp.crud.entities.billpayment; |
| 2 | + |
| 3 | +import java.text.ParseException; |
| 4 | +import java.util.List; |
| 5 | + |
| 6 | +import com.intuit.developer.sampleapp.crud.helper.BillHelper; |
| 7 | +import com.intuit.developer.sampleapp.crud.qbo.DataServiceFactory; |
| 8 | +import com.intuit.ipp.data.Error; |
| 9 | +import com.intuit.ipp.data.BillPayment; |
| 10 | +import com.intuit.ipp.exception.FMSException; |
| 11 | +import com.intuit.ipp.services.DataService; |
| 12 | +import com.intuit.ipp.util.Logger; |
| 13 | + |
| 14 | +/** |
| 15 | + * Demonstrates methods to void billPayment |
| 16 | + * Note: We'll create an entity first and then void the same |
| 17 | + * |
| 18 | + * @author dderose |
| 19 | + * |
| 20 | + */ |
| 21 | +public class BillPaymentVoid { |
| 22 | + |
| 23 | + private static final org.slf4j.Logger LOG = Logger.getLogger(); |
| 24 | + |
| 25 | + public static void main(String[] args) { |
| 26 | + try { |
| 27 | + voidBillPayment(); |
| 28 | + } catch (Exception e) { |
| 29 | + LOG.error("Error during CRUD", e.getCause()); |
| 30 | + } |
| 31 | + } |
| 32 | + |
| 33 | + public static void voidBillPayment() throws FMSException, ParseException { |
| 34 | + |
| 35 | + try { |
| 36 | + DataService service = DataServiceFactory.getDataService(); |
| 37 | + |
| 38 | + // create billPayment |
| 39 | + BillPayment billPayment = BillHelper.getBillPaymentFields(service); |
| 40 | + BillPayment addBillPayment = service.add(billPayment); |
| 41 | + LOG.info("BillPayment added : " + addBillPayment.getId()); |
| 42 | + |
| 43 | + // void billPayment |
| 44 | + BillPayment voidedBillPayment = service.voidRequest(addBillPayment); |
| 45 | + LOG.info("BillPayment voided : " + voidedBillPayment.getId() + " status ::: " + voidedBillPayment.getPrivateNote()); |
| 46 | + |
| 47 | + } catch (FMSException e) { |
| 48 | + List<Error> list = e.getErrorList(); |
| 49 | + list.forEach(error -> LOG.error("Error while voiding entity :: " + error.getMessage())); |
| 50 | + } |
| 51 | + } |
| 52 | + |
| 53 | + |
| 54 | + |
| 55 | +} |
0 commit comments