public static void runExample( DfpServices dfpServices, DfpSession session, long reconciliationReportId, long lineItemId) throws Exception { // Get the ReconciliationLineItemReportService. ReconciliationLineItemReportServiceInterface reconciliationLineItemReportService = dfpServices.get(session, ReconciliationLineItemReportServiceInterface.class); // Create a statement to select a reconciliation line item report. StatementBuilder statementBuilder = new StatementBuilder() .where("reconciliationReportId = :reconciliationReportId AND lineItemId = :lineItemId") .orderBy("lineItemId ASC") .limit(1) .withBindVariableValue("reconciliationReportId", reconciliationReportId) .withBindVariableValue("lineItemId", lineItemId); // Get reconciliation line item reports by statement. ReconciliationLineItemReportPage page = reconciliationLineItemReportService.getReconciliationLineItemReportsByStatement( statementBuilder.toStatement()); ReconciliationLineItemReport lineItemReport = Iterables.getOnlyElement(Arrays.asList(page.getResults())); // Add $10 to the computed billable revenue as an override. Money billableRevenue; if (PricingModel.NET.equals(lineItemReport.getPricingModel())) { billableRevenue = lineItemReport.getNetBillableRevenue(); } else { billableRevenue = lineItemReport.getGrossBillableRevenue(); } billableRevenue.setMicroAmount(billableRevenue.getMicroAmount() + 10000000L); BillableRevenueOverrides billableRevenueOverrides = new BillableRevenueOverrides(); billableRevenueOverrides.setBillableRevenueOverride(billableRevenue); lineItemReport.setBillableRevenueOverrides(billableRevenueOverrides); ReconciliationLineItemReport[] updatedLineItemReports = reconciliationLineItemReportService.updateReconciliationLineItemReports( new ReconciliationLineItemReport[] {lineItemReport}); for (ReconciliationLineItemReport updatedLineItemReport : updatedLineItemReports) { System.out.printf( "Reconciliation line item report for line item ID \"%d\" was " + "updated, with net billable revenue \"%.2f\" and reconciled volume \"%d\".%n", updatedLineItemReport.getLineItemId(), updatedLineItemReport.getNetBillableRevenue().getMicroAmount() / 1000000f, updatedLineItemReport.getReconciledVolume()); } }
public static void runExample( DfpServices dfpServices, DfpSession session, long reconciliationLineItemReportId) throws Exception { // Get the ReconciliationLineItemReportService. ReconciliationLineItemReportServiceInterface reconciliationLineItemReportService = dfpServices.get(session, ReconciliationLineItemReportServiceInterface.class); // Create a statement to select a reconciliation line item report. StatementBuilder statementBuilder = new StatementBuilder() .where("id = :lineItemReportId") .orderBy("id ASC") .limit(1) .withBindVariableValue("lineItemReportId", reconciliationLineItemReportId); // Get reconciliation line item reports by statement. ReconciliationLineItemReportPage page = reconciliationLineItemReportService.getReconciliationLineItemReportsByStatement( statementBuilder.toStatement()); ReconciliationLineItemReport lineItemReport = Iterables.getOnlyElement(Arrays.asList(page.getResults())); // Set and use a manual volume for billing. This example splits the difference between DFP // and the third party volume. lineItemReport.setManualVolume( (lineItemReport.getDfpVolume() + lineItemReport.getThirdPartyVolume()) / 2); lineItemReport.setReconciliationSource(BillFrom.MANUAL); ReconciliationLineItemReport[] updatedLineItemReports = reconciliationLineItemReportService.updateReconciliationLineItemReports( new ReconciliationLineItemReport[] {lineItemReport}); for (ReconciliationLineItemReport updatedLineItemReport : updatedLineItemReports) { System.out.printf( "Reconciliation line item report with ID \"%d\" for line item ID \"%d\" was " + "updated, with manual volume \"%d\".%n", updatedLineItemReport.getId(), updatedLineItemReport.getLineItemId(), updatedLineItemReport.getManualVolume()); } }