CoolCMS API

PaymentEditAudit
in package

FinalYes

Audit trail of manual payment edits in the admin.

An admin may change the status, amount and currency of a payment directly. Each such change has effects outside the payment (the invoice cron issues a cancellation or credit note based on the new status), so changes to money and status fields are written to the paymentAudit log channel. The amount and currency of a payment with an issued invoice cannot be changed, because the invoice would no longer match the payment.

Pure logic without dependencies; the presenter only supplies the state before and after saving.

Table of Contents

Constants

AUDITED_FIELDS  : array<string|int, mixed> = ['status', 'totalPrice', 'currencyId', 'invoice...
Audited fields: money, payment status and the invoicing watermark.
CHANNEL  : string = 'paymentAudit'
Log channel (registered in `config/Shared/logging.neon`).
LOCKED_BY_INVOICE_FIELDS  : array<string|int, mixed> = ['totalPrice', 'currencyId']
Fields that freeze once an invoice is issued.
MONEY_SCALE  : int = 3
Scale `payments.total_price` (`decimal(10,3)`).

Methods

buildLogLine()  : string
Builds the audit log line (JSON, machine-searchable, with no customer personal data).
diff()  : array<string, array{0: scalar|null, 1: scalar|null}>
Returns the changed audited fields as `field => [before, after]`.
touchesInvoicedMoney()  : bool
Tells whether the diff changes the amount or the currency.
isSame()  : bool

Constants

AUDITED_FIELDS

Audited fields: money, payment status and the invoicing watermark.

public array<string|int, mixed> AUDITED_FIELDS = ['status', 'totalPrice', 'currencyId', 'invoicedStatus', 'paymentDatetime']

CHANNEL

Log channel (registered in `config/Shared/logging.neon`).

public string CHANNEL = 'paymentAudit'

LOCKED_BY_INVOICE_FIELDS

Fields that freeze once an invoice is issued.

public array<string|int, mixed> LOCKED_BY_INVOICE_FIELDS = ['totalPrice', 'currencyId']

MONEY_SCALE

Scale `payments.total_price` (`decimal(10,3)`).

private int MONEY_SCALE = 3

Methods

buildLogLine()

Builds the audit log line (JSON, machine-searchable, with no customer personal data).

public static buildLogLine(int|null $paymentId, int|string|null $adminUserId, bool $isNew, array<string, array{0: scalar|null, 1: scalar|null}> $changes) : string
Parameters
$paymentId : int|null
$adminUserId : int|string|null
$isNew : bool
$changes : array<string, array{0: scalar|null, 1: scalar|null}>
Return values
string

diff()

Returns the changed audited fields as `field => [before, after]`.

public static diff(array<string, scalar|null> $before, array<string, scalar|null> $after) : array<string, array{0: scalar|null, 1: scalar|null}>
Parameters
$before : array<string, scalar|null>
$after : array<string, scalar|null>
Return values
array<string, array{0: scalar|null, 1: scalar|null}>

touchesInvoicedMoney()

Tells whether the diff changes the amount or the currency.

public static touchesInvoicedMoney(array<string, mixed> $changes) : bool
Parameters
$changes : array<string, mixed>

result of diff()

Return values
bool

isSame()

private static isSame(string $field, int|float|string|bool|null $old, int|float|string|bool|null $new) : bool
Parameters
$field : string
$old : int|float|string|bool|null
$new : int|float|string|bool|null
Return values
bool
On this page

Search results