Skip to content

add a simpler message return for the action tests #2068

@shoulders

Description

@shoulders

consider the method expense:checkRecordAllowsDelete() when reporting it returns each fail reason whcih can be useful, but perhaps add an option at the bottom where the messaage

also add a silent switch + see how I did the others

This expense cannot be deleted

Obviously control this by a function variable

change all of the checkers to match this format, where appropriate.

SEE those switch statements where I handle messages so they are only pushed at the end. this will allow me to have simple and all messages returned

eg
look at the test in the function variable

public function checkRecordCanBeCreated($client_id = null, $invoice_id = null, $supplier_id = null, $expense_id = null, $silent = \CMSApplication::$simpleMessages ? true : $silent) {

eg

checkRecordCanBeCreated($client_id = null, $invoice_id = null, $supplier_id = null, $expense_id = null, $silent = false, $simpleMessage = \CMSApplication::$simpleMessages) {

// If simple messaging is on, make sure silent is on
$silent = \CMSApplication::$simpleMessages ? true : $silent;

// Test function
$this->app->system->variables->systemMessagesWrite('danger', _gettext("The client is not active so you cannot create a credit note against it.", $silent));

// Silent Message
if( \CMSApplication::$simpleMessages){
$this->app->system->variables->systemMessagesWrite('danger', _gettext("You cannot create a credit note against this client.", $silent));
}

}

NB: I do not have to declare it as a variable in the function list.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions