Skip to content

Commit

Permalink
Merge pull request #2020 from GPCsolutions/situationsinvoices
Browse files Browse the repository at this point in the history
Situations invoices support
  • Loading branch information
eldy committed Jan 17, 2015
2 parents 30abacd + 50c2b75 commit eeeb6de
Show file tree
Hide file tree
Showing 28 changed files with 913 additions and 124 deletions.
23 changes: 17 additions & 6 deletions htdocs/accountancy/journal/sellsjournal.php
Expand Up @@ -7,6 +7,7 @@
* Copyright (C) 2013-2014 Alexandre Spangaro <alexandre.spangaro@gmail.com>
* Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2014 Raphaël Doursenaud <rdoursenaud@gpcsolutions.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
Expand Down Expand Up @@ -100,9 +101,9 @@
}
$sql .= " AND f.fk_statut > 0";
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS))
$sql .= " AND f.type IN (0,1,2)";
$sql .= " AND f.type IN (0,1,2,5)";
else
$sql .= " AND f.type IN (0,1,2,3)";
$sql .= " AND f.type IN (0,1,2,3,5)";
$sql .= " AND fd.product_type IN (0,1)";
if ($date_start && $date_end)
$sql .= " AND f.datef >= '" . $db->idate($date_start) . "' AND f.datef <= '" . $db->idate($date_end) . "'";
Expand Down Expand Up @@ -136,6 +137,16 @@
$cpttva = (! empty($conf->global->ACCOUNTING_VAT_ACCOUNT)) ? $conf->global->ACCOUNTING_VAT_ACCOUNT : $langs->trans("CodeNotDef");
$compta_tva = (! empty($obj->account_tva) ? $obj->account_tva : $cpttva);

// Situation invoices handling
$line = new FactureLigne($db);
$line->fetch($obj->id);
$prev_progress = $line->get_prev_progress();
if ($obj->situation_percent == 0) { // Avoid divide by 0
$situation_ratio = 0;
} else {
$situation_ratio = ($obj->situation_percent - $prev_progress) / $obj->situation_percent;
}

// Invoice lines
$tabfac[$obj->rowid]["date"] = $obj->df;
$tabfac[$obj->rowid]["ref"] = $obj->facnumber;
Expand All @@ -148,9 +159,9 @@
$tabht[$obj->rowid][$compta_prod] = 0;
if (! isset($tabtva[$obj->rowid][$compta_tva]))
$tabtva[$obj->rowid][$compta_tva] = 0;
$tabttc[$obj->rowid][$compta_soc] += $obj->total_ttc;
$tabht[$obj->rowid][$compta_prod] += $obj->total_ht;
$tabtva[$obj->rowid][$compta_tva] += $obj->total_tva;
$tabttc[$obj->rowid][$compta_soc] += $obj->total_ttc * $situation_ratio;
$tabht[$obj->rowid][$compta_prod] += $obj->total_ht * $situation_ratio;
$tabtva[$obj->rowid][$compta_tva] += $obj->total_tva * $situation_ratio;
$tabcompany[$obj->rowid] = array (
'id' => $obj->socid,
'name' => $obj->name,
Expand Down Expand Up @@ -471,4 +482,4 @@ function writebookkeeping() {
// End of page
llxFooter();
}
$db->close();
$db->close();

0 comments on commit eeeb6de

Please sign in to comment.