Skip to content

Commit

Permalink
Merge branch 'marcosgdf-bug-1827' into 3.6
Browse files Browse the repository at this point in the history
  • Loading branch information
eldy committed Feb 7, 2015
2 parents d10e28d + e8b2b22 commit 07877bc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 17 deletions.
1 change: 1 addition & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ English Dolibarr ChangeLog
- Fix: Tracking number not visible on shipment pdf
- 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 #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 *****
- Fix: fix ErrorBadValueForParamNotAString error message in price customer multiprice.
Expand Down
26 changes: 9 additions & 17 deletions htdocs/core/lib/tax.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* Copyright (C) 2006-2007 Yannick Warnier <ywarnier@beeznest.org>
* Copyright (C) 2011 Regis Houssin <regis.houssin@capnetworks.com>
* 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
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -86,26 +87,18 @@ function vat_by_thirdparty($db, $y, $date_start, $date_end, $modetax, $direction
global $conf;

$list=array();
//print "xx".$conf->global->MAIN_MODULE_ACCOUNTING;
//print "xx".$conf->global->MAIN_MODULE_COMPTABILITE;

if ($direction == 'sell')
{
$invoicetable='facture';
$invoicedettable='facturedet';
$fk_facture='fk_facture';
$total_tva='total_tva';
$total_localtax1='total_localtax1';
$total_localtax2='total_localtax2';
$total_ht='total';
$total_tva='tva';
}
if ($direction == 'buy')
{
$invoicetable='facture_fourn';
$invoicedettable='facture_fourn_det';
$fk_facture='fk_facture_fourn';
$total_tva='tva';
$total_localtax1='total_localtax1';
$total_localtax2='total_localtax2';
$total_ht='total_ht';
$total_tva='total_tva';
}

// Define sql request
Expand All @@ -125,11 +118,10 @@ function vat_by_thirdparty($db, $y, $date_start, $date_end, $modetax, $direction
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.= " sum(fd.total_ht) as amount, sum(fd.".$total_tva.") as tva,";
$sql.= " sum(fd.".$total_localtax1.") as localtax1,";
$sql.= " sum(fd.".$total_localtax2.") as localtax2";
$sql.= " sum(f.$total_ht) as amount, sum(f.".$total_tva.") as tva,";
$sql.= " sum(f.localtax1) as localtax1,";
$sql.= " sum(f.localtax2) as localtax2";
$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)
Expand All @@ -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))."'";
}
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";
}
}
Expand Down

0 comments on commit 07877bc

Please sign in to comment.