// Iterates over all invoices retrieved and prints their information.
foreach ($response->getInvoices() as $invoice) {
/** @var Invoice $invoice */
printf(
"- Found the invoice '%s':" . PHP_EOL .
" ID (also known as Invoice Number): '%s'" . PHP_EOL .
" Type: %s" . PHP_EOL .
" Billing setup ID: '%s'" . PHP_EOL .
" Payments account ID (also known as Billing Account Number): '%s'" . PHP_EOL .
" Payments profile ID (also known as Billing ID): '%s'" . PHP_EOL .
" Issue date (also known as Invoice Date): %s" . PHP_EOL .
" Due date: %s" . PHP_EOL .
" Currency code: %s" . PHP_EOL .
" Service date range (inclusive): from %s to %s" . PHP_EOL .
" Adjustments: subtotal '%.2f', tax '%.2f', total '%.2f'" . PHP_EOL .
" Regulatory costs: subtotal '%.2f', tax '%.2f', total '%.2f'" . PHP_EOL .
" Replaced invoices: '%s'" . PHP_EOL .
" Amounts: subtotal '%.2f', tax '%.2f', total '%.2f'" . PHP_EOL .
" Corrected invoice: '%s'" . PHP_EOL .
" PDF URL: '%s'" . PHP_EOL .
" Account budgets:" . PHP_EOL,
$invoice->getResourceName(),
$invoice->getId(),
InvoiceType::name($invoice->getType()),
$invoice->getBillingSetup(),
$invoice->getPaymentsAccountId(),
$invoice->getPaymentsProfileId(),
$invoice->getIssueDate(),
$invoice->getDueDate(),
$invoice->getCurrencyCode(),
$invoice->getServiceDateRange()->getStartDate(),
$invoice->getServiceDateRange()->getEndDate(),
Helper::microToBase($invoice->getAdjustmentsSubtotalAmountMicros()),
Helper::microToBase($invoice->getAdjustmentsTaxAmountMicros()),
Helper::microToBase($invoice->getAdjustmentsTotalAmountMicros()),
Helper::microToBase($invoice->getRegulatoryCostsSubtotalAmountMicros()),
Helper::microToBase($invoice->getRegulatoryCostsTaxAmountMicros()),
Helper::microToBase($invoice->getRegulatoryCostsTotalAmountMicros()),
$invoice->getReplacedInvoices()
? implode(
"', '",
iterator_to_array($invoice->getReplacedInvoices()->getIterator())
) : 'none',
Helper::microToBase($invoice->getSubtotalAmountMicros()),
Helper::microToBase($invoice->getTaxAmountMicros()),
Helper::microToBase($invoice->getTotalAmountMicros()),
$invoice->getCorrectedInvoice() ?: 'none',
$invoice->getPdfUrl()
);
foreach ($invoice->getAccountBudgetSummaries() as $accountBudgetSummary) {
/** @var AccountBudgetSummary $accountBudgetSummary */
printf(
" - Account budget '%s':" . PHP_EOL .
" Name (also known as Account Budget): '%s'" . PHP_EOL .
" Customer (also known as Account ID): '%s'" . PHP_EOL .
" Customer descriptive name (also known as Account): '%s'" . PHP_EOL .
" Purchase order number (also known as Purchase Order): '%s'" . PHP_EOL .
" Billing activity date range (inclusive): from %s to %s" . PHP_EOL .
" Amounts: subtotal '%.2f', tax '%.2f', total '%.2f'" . PHP_EOL,
$accountBudgetSummary->getAccountBudget(),
$accountBudgetSummary->getAccountBudgetName() ?: 'none',
$accountBudgetSummary->getCustomer(),
$accountBudgetSummary->getCustomerDescriptiveName() ?: 'none',
$accountBudgetSummary->getPurchaseOrderNumber() ?: 'none',
$accountBudgetSummary->getBillableActivityDateRange()->getStartDate(),
$accountBudgetSummary->getBillableActivityDateRange()->getEndDate(),
Helper::microToBase($accountBudgetSummary->getSubtotalAmountMicros()),
Helper::microToBase($accountBudgetSummary->getTaxAmountMicros()),
Helper::microToBase($accountBudgetSummary->getTotalAmountMicros())
);
}
}