2
0
forked from Wavyzz/dolibarr

Work on vat report

This commit is contained in:
Laurent Destailleur
2018-04-30 18:17:22 +02:00
parent 56be581a98
commit 1bf56e58b3
3 changed files with 79 additions and 32 deletions

View File

@@ -81,10 +81,10 @@ $result = restrictedArea($user, 'tax', '', '', 'charges');
/**
* print function
*
* @param DoliDB $db Database handler
* @param string $sql SQL Request
* @param string $date Date
* @return void
* @param DoliDB $db Database handler
* @param string $sql SQL Request
* @param string $date Date
* @return void
*/
function pt ($db, $sql, $date)
{
@@ -98,8 +98,9 @@ function pt ($db, $sql, $date)
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td class="nowrap" width="60%">'.$date.'</td>';
print '<td align="right">'.$langs->trans("Amount").'</td>';
print '<td class="nowrap">'.$date.'</td>';
print '<td align="right">'.$langs->trans("ClaimedForThisPeriod").'</td>';
print '<td align="right">'.$langs->trans("PaidDuringThisPeriod").'</td>';
print "</tr>\n";
while ($i < $num) {
@@ -107,14 +108,26 @@ function pt ($db, $sql, $date)
print '<tr class="oddeven">';
print '<td class="nowrap">'.$obj->dm."</td>\n";
$total = $total + $obj->mm;
print '<td class="nowrap" align="right">'.price($obj->mm)."</td>\n";
$amountclaimed = 0;
$amountpaid = 0;
if ($obj->mode == 'claimed') $amountclaimed = $obj->mm;
if ($obj->mode == 'paid') $amountpaid = $obj->mm;
$totalclaimed = $totalclaimed + $amountclaimed;
$totalpaid = $totalpaid + $amountpaied;
print '<td class="nowrap" align="right">'.price($amountclaimed)."</td>\n";
print '<td class="nowrap" align="right">'.price($amountpaid)."</td>\n";
print "</tr>\n";
$i++;
}
print '<tr class="liste_total"><td align="right">'.$langs->trans("Total")." :</td><td class=\"nowrap\" align=\"right\"><b>".price($total)."</b></td></tr>";
print '<tr class="liste_total">';
print '<td align="right">'.$langs->trans("Total").'</td>';
print '<td class="nowrap" align="right">'.price($totalclaimed).'</td>';
print '<td class="nowrap" align="right">'.price($totalpaid).'</td>';
print "</tr>";
print "</table>";
$db->free($result);
@@ -498,20 +511,29 @@ print '</div><div class="fichetwothirdright"><div class="ficheaddleft">';
print load_fiche_titre($langs->transcountry($LTPaid,$mysoc->country_code), '', '');
$sql = "SELECT SUM(amount) as mm, date_format(f.datev,'%Y-%m') as dm";
$sql='';
$sql.= "SELECT SUM(amount) as mm, date_format(f.datev,'%Y-%m') as dm, 'claimed' as mode";
$sql.= " FROM ".MAIN_DB_PREFIX."localtax as f";
$sql.= " WHERE f.entity = ".$conf->entity;
$sql.= " AND f.datev >= '".$db->idate($date_start)."'";
$sql.= " AND f.datev <= '".$db->idate($date_end)."'";
$sql.= " AND (f.datev >= '".$db->idate($date_start)."' AND f.datev <= '".$db->idate($date_end)."')";
$sql.= " AND localtaxtype=".$localTaxType;
$sql.= " GROUP BY dm";
$sql.= " UNION ";
$sql.= "SELECT SUM(amount) as mm, date_format(f.datep,'%Y-%m') as dm, 'paid' as mode";
$sql.= " FROM ".MAIN_DB_PREFIX."localtax as f";
$sql.= " WHERE f.entity = ".$conf->entity;
$sql.= " AND (f.datep >= '".$db->idate($date_start)."' AND f.datep <= '".$db->idate($date_end)."')";
$sql.= " AND localtaxtype=".$localTaxType;
$sql.= " GROUP BY dm";
$sql.= " ORDER BY dm ASC";
pt($db, $sql,$langs->trans("Month"));
pt($db, $sql, $langs->trans("Month"));
print '<br>';
print '</div></div>';
llxFooter();

View File

@@ -81,10 +81,10 @@ $result = restrictedArea($user, 'tax', '', '', 'charges');
/**
* print function
*
* @param DoliDB $db Database handler
* @param string $sql SQL Request
* @param string $date Date
* @return void
* @param DoliDB $db Database handler
* @param string $sql SQL Request
* @param string $date Date
* @return void
*/
function pt ($db, $sql, $date)
{
@@ -98,8 +98,9 @@ function pt ($db, $sql, $date)
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td class="nowrap" width="60%">'.$date.'</td>';
print '<td align="right">'.$langs->trans("Amount").'</td>';
print '<td class="nowrap">'.$date.'</td>';
print '<td align="right">'.$langs->trans("ClaimedForThisPeriod").'</td>';
print '<td align="right">'.$langs->trans("PaidDuringThisPeriod").'</td>';
print "</tr>\n";
while ($i < $num) {
@@ -107,14 +108,26 @@ function pt ($db, $sql, $date)
print '<tr class="oddeven">';
print '<td class="nowrap">'.$obj->dm."</td>\n";
$total = $total + $obj->mm;
print '<td class="nowrap" align="right">'.price($obj->mm)."</td\n";
$amountclaimed = 0;
$amountpaid = 0;
if ($obj->mode == 'claimed') $amountclaimed = $obj->mm;
if ($obj->mode == 'paid') $amountpaid = $obj->mm;
$totalclaimed = $totalclaimed + $amountclaimed;
$totalpaid = $totalpaid + $amountpaied;
print '<td class="nowrap" align="right">'.price($amountclaimed)."</td>\n";
print '<td class="nowrap" align="right">'.price($amountpaid)."</td>\n";
print "</tr>\n";
$i++;
}
print '<tr class="liste_total"><td align="right">'.$langs->trans("Total")." :</td><td class=\"nowrap\" align=\"right\"><b>".price($total)."</b></td></tr>";
print '<tr class="liste_total">';
print '<td align="right">'.$langs->trans("Total").'</td>';
print '<td class="nowrap" align="right">'.price($totalclaimed).'</td>';
print '<td class="nowrap" align="right">'.price($totalpaid).'</td>';
print "</tr>";
print "</table>";
$db->free($result);
@@ -465,23 +478,33 @@ print '</div><div class="fichetwothirdright"><div class="ficheaddleft">';
print load_fiche_titre($langs->trans("VATPaid"), '', '');
$sql = "SELECT SUM(amount) as mm, date_format(f.datep,'%Y-%m') as dm";
$sql='';
$sql.= "SELECT SUM(amount) as mm, date_format(f.datev,'%Y-%m') as dm, 'claimed' as mode";
$sql.= " FROM ".MAIN_DB_PREFIX."tva as f";
$sql.= " WHERE f.entity = ".$conf->entity;
$sql.= " AND f.datep >= '".$db->idate($date_start)."'";
$sql.= " AND f.datep <= '".$db->idate($date_end)."'";
$sql.= " AND (f.datev >= '".$db->idate($date_start)."' AND f.datev <= '".$db->idate($date_end)."')";
$sql.= " GROUP BY dm";
$sql.= " UNION ";
$sql.= "SELECT SUM(amount) as mm, date_format(f.datep,'%Y-%m') as dm, 'paid' as mode";
$sql.= " FROM ".MAIN_DB_PREFIX."tva as f";
$sql.= " WHERE f.entity = ".$conf->entity;
$sql.= " AND (f.datep >= '".$db->idate($date_start)."' AND f.datep <= '".$db->idate($date_end)."')";
$sql.= " GROUP BY dm";
$sql.= " ORDER BY dm ASC";
//print $sql;
pt($db, $sql, $langs->trans("Month"));
print '<br>';
if (! empty($conf->global->MAIN_FEATURES_LEVEL))
{
/*
print '<br>';
/*
* Recap
*/

View File

@@ -244,4 +244,6 @@ FiscalPeriod=Accounting period
ListSocialContributionAssociatedProject=List of social contributions associated with the project
DeleteFromCat=Remove from accounting group
AccountingAffectation=Accounting assignement
LastDayTaxIsRelatedTo=Last day of period the tax is related to
LastDayTaxIsRelatedTo=Last day of period the tax is related to
ClaimedForThisPeriod=Claimed for the period
PaidDuringThisPeriod=Paid during this period