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

This commit is contained in:
Laurent Destailleur 2013-12-09 22:39:41 +01:00
parent 705192215a
commit a89a4ee81a

View File

@ -1,6 +1,6 @@
<?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");
$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"))
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')
{ {
$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');