Skip to content
Snippets Groups Projects
Commit a89a4ee8 authored by Laurent Destailleur's avatar Laurent Destailleur
Browse files

Fix: Delete vat entry when bank line was already deleted.

parent 70519221
No related branches found
No related tags found
No related merge requests found
<?php <?php
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2013 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2013 Regis Houssin <regis.houssin@capnetworks.com> * Copyright (C) 2005-2013 Regis Houssin <regis.houssin@capnetworks.com>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
...@@ -31,7 +31,7 @@ $langs->load("compta"); ...@@ -31,7 +31,7 @@ $langs->load("compta");
$langs->load("banks"); $langs->load("banks");
$langs->load("bills"); $langs->load("bills");
$id=GETPOST("id"); $id=GETPOST("id",'int');
$action=GETPOST('action'); $action=GETPOST('action');
$mesg = ''; $mesg = '';
...@@ -89,7 +89,7 @@ if ($action == 'add' && $_POST["cancel"] <> $langs->trans("Cancel")) ...@@ -89,7 +89,7 @@ if ($action == 'add' && $_POST["cancel"] <> $langs->trans("Cancel"))
if ($action == 'delete') if ($action == 'delete')
{ {
$result=$tva->fetch($_GET['id']); $result=$tva->fetch($id);
if ($tva->rappro == 0) if ($tva->rappro == 0)
{ {
...@@ -102,10 +102,10 @@ if ($action == 'delete') ...@@ -102,10 +102,10 @@ if ($action == 'delete')
{ {
$accountline=new AccountLine($db); $accountline=new AccountLine($db);
$result=$accountline->fetch($tva->fk_bank); $result=$accountline->fetch($tva->fk_bank);
$result=$accountline->delete($user); if ($result > 0) $result=$accountline->delete($user); // $result may be 0 if not found (when bank entry was deleted manually and fk_bank point to nothing)
} }
if ($result > 0) if ($result >= 0)
{ {
$db->commit(); $db->commit();
header("Location: ".DOL_URL_ROOT.'/compta/tva/reglement.php'); header("Location: ".DOL_URL_ROOT.'/compta/tva/reglement.php');
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment