marcosgdf-bug-1827

Conflicts:
	ChangeLog
This commit is contained in:
Laurent Destailleur 2015-02-07 23:56:38 +01:00
commit e8b2b22c32
2 changed files with 10 additions and 17 deletions

View File

@ -20,6 +20,7 @@ English Dolibarr ChangeLog
- Fix: Tracking number not visible on shipment pdf - Fix: Tracking number not visible on shipment pdf
- Fix: [ bug #1812 ] SQL Error message while sending emailing with PostgreSQL datatabase - Fix: [ bug #1812 ] SQL Error message while sending emailing with PostgreSQL datatabase
- Fix: [ bug #1819 ] SQL error when searching for an invoice payment - Fix: [ bug #1819 ] SQL error when searching for an invoice payment
- Fix: [ bug #1827 ] Tax reports gives incorrect amounts when using external modules that create lines with special codes
***** ChangeLog for 3.6.2 compared to 3.6.1 ***** ***** ChangeLog for 3.6.2 compared to 3.6.1 *****
- Fix: fix ErrorBadValueForParamNotAString error message in price customer multiprice. - Fix: fix ErrorBadValueForParamNotAString error message in price customer multiprice.

View File

@ -3,6 +3,7 @@
* Copyright (C) 2006-2007 Yannick Warnier <ywarnier@beeznest.org> * Copyright (C) 2006-2007 Yannick Warnier <ywarnier@beeznest.org>
* Copyright (C) 2011 Regis Houssin <regis.houssin@capnetworks.com> * Copyright (C) 2011 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2012 Juanjo Menent <jmenent@2byte.es> * Copyright (C) 2012 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2015 Marcos García <marcosgdf@gmail.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
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -86,26 +87,18 @@ function vat_by_thirdparty($db, $y, $date_start, $date_end, $modetax, $direction
global $conf; global $conf;
$list=array(); $list=array();
//print "xx".$conf->global->MAIN_MODULE_ACCOUNTING;
//print "xx".$conf->global->MAIN_MODULE_COMPTABILITE;
if ($direction == 'sell') if ($direction == 'sell')
{ {
$invoicetable='facture'; $invoicetable='facture';
$invoicedettable='facturedet'; $total_ht='total';
$fk_facture='fk_facture'; $total_tva='tva';
$total_tva='total_tva';
$total_localtax1='total_localtax1';
$total_localtax2='total_localtax2';
} }
if ($direction == 'buy') if ($direction == 'buy')
{ {
$invoicetable='facture_fourn'; $invoicetable='facture_fourn';
$invoicedettable='facture_fourn_det'; $total_ht='total_ht';
$fk_facture='fk_facture_fourn'; $total_tva='total_tva';
$total_tva='tva';
$total_localtax1='total_localtax1';
$total_localtax2='total_localtax2';
} }
// Define sql request // Define sql request
@ -125,11 +118,10 @@ function vat_by_thirdparty($db, $y, $date_start, $date_end, $modetax, $direction
if (! empty($conf->global->MAIN_MODULE_COMPTABILITE)) if (! empty($conf->global->MAIN_MODULE_COMPTABILITE))
{ {
$sql = "SELECT s.rowid as socid, s.nom as nom, s.siren as tva_intra, s.tva_assuj as assuj,"; $sql = "SELECT s.rowid as socid, s.nom as nom, s.siren as tva_intra, s.tva_assuj as assuj,";
$sql.= " sum(fd.total_ht) as amount, sum(fd.".$total_tva.") as tva,"; $sql.= " sum(f.$total_ht) as amount, sum(f.".$total_tva.") as tva,";
$sql.= " sum(fd.".$total_localtax1.") as localtax1,"; $sql.= " sum(f.localtax1) as localtax1,";
$sql.= " sum(fd.".$total_localtax2.") as localtax2"; $sql.= " sum(f.localtax2) as localtax2";
$sql.= " FROM ".MAIN_DB_PREFIX.$invoicetable." as f,"; $sql.= " FROM ".MAIN_DB_PREFIX.$invoicetable." as f,";
$sql.= " ".MAIN_DB_PREFIX.$invoicedettable." as fd,";
$sql.= " ".MAIN_DB_PREFIX."societe as s"; $sql.= " ".MAIN_DB_PREFIX."societe as s";
$sql.= " WHERE f.entity = " . $conf->entity; $sql.= " WHERE f.entity = " . $conf->entity;
$sql.= " AND f.fk_statut in (1,2)"; // Validated or paid (partially or completely) $sql.= " AND f.fk_statut in (1,2)"; // Validated or paid (partially or completely)
@ -146,7 +138,7 @@ function vat_by_thirdparty($db, $y, $date_start, $date_end, $modetax, $direction
$sql.= " AND f.datef <= '".$db->idate(dol_get_last_day($y,12,false))."'"; $sql.= " AND f.datef <= '".$db->idate(dol_get_last_day($y,12,false))."'";
} }
if ($date_start && $date_end) $sql.= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'"; if ($date_start && $date_end) $sql.= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'";
$sql.= " AND s.rowid = f.fk_soc AND f.rowid = fd.".$fk_facture; $sql.= " AND s.rowid = f.fk_soc";
$sql.= " GROUP BY s.rowid, s.nom, s.tva_intra, s.tva_assuj"; $sql.= " GROUP BY s.rowid, s.nom, s.tva_intra, s.tva_assuj";
} }
} }