Fix: bad value with multi-company module
This commit is contained in:
parent
417b77be6d
commit
852a800fbd
@ -1,6 +1,7 @@
|
||||
<?php
|
||||
/* Copyright (C) 2004-2009 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2006-2007 Yannick Warnier <ywarnier@beeznest.org>
|
||||
/* Copyright (C) 2004-2009 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2006-2007 Yannick Warnier <ywarnier@beeznest.org>
|
||||
* Copyright (C) 2011 Regis Houssin <regis@dolibarr.fr>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -75,9 +76,11 @@ function vat_by_thirdparty($db, $y, $date_start, $date_end, $modetax, $direction
|
||||
{
|
||||
$sql = "SELECT s.rowid as socid, s.nom as nom, s.tva_intra as tva_intra, s.tva_assuj as assuj,";
|
||||
$sql.= " sum(fd.total_ht) as amount, sum(fd.".$total_tva.") as tva";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX.$invoicetable." as f, ".MAIN_DB_PREFIX.$invoicedettable." as fd, ".MAIN_DB_PREFIX."societe as s";
|
||||
$sql.= " WHERE ";
|
||||
$sql.= " f.fk_statut in (1,2)"; // Validated or paid (partially or completely)
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX.$invoicetable." as f,";
|
||||
$sql.= " ".MAIN_DB_PREFIX.$invoicedettable." as fd,";
|
||||
$sql.= " ".MAIN_DB_PREFIX."societe as s";
|
||||
$sql.= " WHERE f.entity = " . $conf->entity;
|
||||
$sql.= " AND f.fk_statut in (1,2)"; // Validated or paid (partially or completely)
|
||||
$sql.= " AND (f.type = 0"; // Standard
|
||||
$sql.= " OR f.type = 1"; // Replacement
|
||||
$sql.= " OR f.type = 2)"; // Credit note
|
||||
@ -233,8 +236,8 @@ function vat_by_date($db, $y, $q, $date_start, $date_end, $modetax, $direction,
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX.$invoicetable." as f,";
|
||||
$sql.= " ".MAIN_DB_PREFIX.$invoicedettable." as d" ;
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p on d.fk_product = p.rowid";
|
||||
$sql.= " WHERE ";
|
||||
$sql.= " f.fk_statut in (1,2)"; // Validated or paid (partially or completely)
|
||||
$sql.= " WHERE f.entity = " . $conf->entity;
|
||||
$sql.= " AND f.fk_statut in (1,2)"; // Validated or paid (partially or completely)
|
||||
$sql.= " AND (f.type = 0"; // Standard
|
||||
$sql.= " OR f.type = 1"; // Replacement
|
||||
$sql.= " OR f.type = 2)"; // Credit note
|
||||
@ -282,8 +285,8 @@ function vat_by_date($db, $y, $q, $date_start, $date_end, $modetax, $direction,
|
||||
// $sql.= " ".MAIN_DB_PREFIX.$paymenttable." as pa,";
|
||||
$sql.= " ".MAIN_DB_PREFIX.$invoicedettable." as d" ;
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p on d.fk_product = p.rowid";
|
||||
$sql.= " WHERE ";
|
||||
$sql.= " f.fk_statut in (1,2)"; // Validated or paid (partially or completely)
|
||||
$sql.= " WHERE f.entity = " . $conf->entity;
|
||||
$sql.= " AND f.fk_statut in (1,2)"; // Validated or paid (partially or completely)
|
||||
$sql.= " AND (f.type = 0"; // Standard
|
||||
$sql.= " OR f.type = 1"; // Replacement
|
||||
$sql.= " OR f.type = 2)"; // Credit note
|
||||
@ -394,8 +397,8 @@ function vat_by_date($db, $y, $q, $date_start, $date_end, $modetax, $direction,
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX.$invoicetable." as f,";
|
||||
$sql.= " ".MAIN_DB_PREFIX.$invoicedettable." as d" ;
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p on d.fk_product = p.rowid";
|
||||
$sql.= " WHERE ";
|
||||
$sql.= " f.fk_statut in (1,2)"; // Validated or paid (partially or completely)
|
||||
$sql.= " WHERE f.entity = " . $conf->entity;
|
||||
$sql.= " AND f.fk_statut in (1,2)"; // Validated or paid (partially or completely)
|
||||
$sql.= " AND (f.type = 0"; // Standard
|
||||
$sql.= " OR f.type = 1"; // Replacement
|
||||
$sql.= " OR f.type = 2)"; // Credit note
|
||||
@ -443,8 +446,8 @@ function vat_by_date($db, $y, $q, $date_start, $date_end, $modetax, $direction,
|
||||
$sql.= " ".MAIN_DB_PREFIX.$paymenttable." as pa,";
|
||||
$sql.= " ".MAIN_DB_PREFIX.$invoicedettable." as d";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p on d.fk_product = p.rowid";
|
||||
$sql.= " WHERE ";
|
||||
$sql.= " f.fk_statut in (1,2)"; // Paid (partially or completely)
|
||||
$sql.= " WHERE f.entity = " . $conf->entity;
|
||||
$sql.= " AND f.fk_statut in (1,2)"; // Paid (partially or completely)
|
||||
$sql.= " AND (f.type = 0"; // Standard
|
||||
$sql.= " OR f.type = 1"; // Replacement
|
||||
$sql.= " OR f.type = 2)"; // Credit note
|
||||
|
||||
Loading…
Reference in New Issue
Block a user