forked from Wavyzz/dolibarr
FIX Avoid deletion of bank record if in accounting
This commit is contained in:
@@ -353,8 +353,13 @@ if (GETPOST('save') && !$cancel && $user->rights->banque->modifier)
|
||||
if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->banque->modifier)
|
||||
{
|
||||
$accline = new AccountLine($db);
|
||||
$result = $accline->fetch(GETPOST("rowid"));
|
||||
$result = $accline->fetch(GETPOST("rowid", "int"));
|
||||
$result = $accline->delete($user);
|
||||
if ($result <= 0) {
|
||||
setEventMessages($accline->error, $accline->errors, 'errors');
|
||||
} else {
|
||||
setEventMessages('RecordDeleted', null, 'mesgs');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1883,13 +1883,15 @@ class AccountLine extends CommonObject
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete transaction bank line record
|
||||
* Delete bank transaction record
|
||||
*
|
||||
* @param User $user User object that delete
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
public function delete(User $user = null)
|
||||
{
|
||||
global $conf;
|
||||
|
||||
$nbko = 0;
|
||||
|
||||
if ($this->rappro)
|
||||
@@ -1901,6 +1903,26 @@ class AccountLine extends CommonObject
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
// Protection to avoid any delete of accounted lines. Protection on by default
|
||||
if (empty($conf->global->BANK_ALLOW_TRANSACTION_DELETION_EVEN_IF_IN_ACCOUNTING))
|
||||
{
|
||||
$sql = "SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX."accounting_bookkeeping WHERE doc_type = 'bank' AND fk_doc = ".$this->id;
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql) {
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
if ($obj && $obj->nb) {
|
||||
$this->error = 'ErrorRecordAlreadyInAccountingDeletionNotPossible';
|
||||
$this->db->rollback();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else {
|
||||
$this->error = $this->db->lasterror();
|
||||
$this->db->rollback();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
// Delete urls
|
||||
$result = $this->delete_urls($user);
|
||||
if ($result < 0)
|
||||
|
||||
@@ -227,6 +227,7 @@ ErrorNoFieldWithAttributeShowoncombobox=No fields has property 'showoncombobox'
|
||||
ErrorFieldRequiredForProduct=Field '%s' is required for product %s
|
||||
ProblemIsInSetupOfTerminal=Problem is in setup of terminal %s.
|
||||
ErrorAddAtLeastOneLineFirst=Add at least one line first
|
||||
ErrorRecordAlreadyInAccountingDeletionNotPossible=Error, record is already transferred in accounting, deletion is not possible.
|
||||
# Warnings
|
||||
WarningParamUploadMaxFileSizeHigherThanPostMaxSize=Your PHP parameter upload_max_filesize (%s) is higher than PHP parameter post_max_size (%s). This is not a consistent setup.
|
||||
WarningPasswordSetWithNoAccount=A password was set for this member. However, no user account was created. So this password is stored but can't be used to login to Dolibarr. It may be used by an external module/interface but if you don't need to define any login nor password for a member, you can disable option "Manage a login for each member" from Member module setup. If you need to manage a login but don't need any password, you can keep this field empty to avoid this warning. Note: Email can also be used as a login if the member is linked to a user.
|
||||
|
||||
Reference in New Issue
Block a user