' . esc_html__( 'That invoice does not exist.', 'easy-invoice' ) . '
';
return;
}
$invoice = new \EasyInvoice\Models\Invoice( $post );
$remaining = CreditNote::remainingCreditable( $invoice_id );
$credited = CreditNote::creditedTotal( $invoice_id );
$notes = CreditNote::forInvoice( $invoice_id );
$notice = isset( $_GET['cn_notice'] ) ? sanitize_text_field( wp_unslash( $_GET['cn_notice'] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended
$can_issue = easy_invoice_user_can( 'ei_create_invoice' );
include EASY_INVOICE_PLUGIN_DIR . 'templates/admin/credit-note-page.php';
}
/**
* Add a credit-note link to each invoice row.
*
* @param array $actions Actions contributed so far.
* @param object $invoice Invoice model.
* @return array
*/
public static function addRowAction( $actions, $invoice ): array {
$actions = is_array( $actions ) ? $actions : [];
if ( ! easy_invoice_user_can( 'ei_view_invoices' ) ) {
return $actions;
}
$id = is_callable( [ $invoice, 'getId' ] ) ? (int) $invoice->getId() : 0;
if ( $id <= 0 || ! \EasyInvoice\Services\InvoiceRetention::isIssued( $id ) ) {
// Drafts are edited, not credited.
return $actions;
}
$credited = CreditNote::creditedTotal( $id );
$actions['credit_note'] = sprintf(
'