FIX debug report expense/income
This commit is contained in:
parent
8e839a34e2
commit
940f0484ee
@ -93,7 +93,18 @@ class PaymentVarious extends CommonObject
|
||||
public $fk_project;
|
||||
|
||||
/**
|
||||
* @var int ID
|
||||
* @var int Bank account ID
|
||||
*/
|
||||
public $fk_account;
|
||||
|
||||
/**
|
||||
* @var int Bank account ID
|
||||
* @deprecated See fk_account
|
||||
*/
|
||||
public $accountid;
|
||||
|
||||
/**
|
||||
* @var int ID record into llx_bank
|
||||
*/
|
||||
public $fk_bank;
|
||||
|
||||
@ -102,11 +113,6 @@ class PaymentVarious extends CommonObject
|
||||
*/
|
||||
public $categorie_transaction;
|
||||
|
||||
/**
|
||||
* @var int Account ID
|
||||
*/
|
||||
public $accountid;
|
||||
|
||||
/**
|
||||
* @var int ID
|
||||
*/
|
||||
@ -397,6 +403,10 @@ class PaymentVarious extends CommonObject
|
||||
$this->fk_bank = (int) $this->fk_bank;
|
||||
$this->fk_user_author = (int) $this->fk_user_author;
|
||||
$this->fk_user_modif = (int) $this->fk_user_modif;
|
||||
$this->fk_account = (int) $this->fk_account;
|
||||
if (empty($this->fk_account) && isset($this->accountid)) { // For compatibility
|
||||
$this->fk_account = $this->accountid;
|
||||
}
|
||||
|
||||
// Check parameters
|
||||
if (!$this->label)
|
||||
@ -409,9 +419,9 @@ class PaymentVarious extends CommonObject
|
||||
$this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Amount"));
|
||||
return -5;
|
||||
}
|
||||
if (!empty($conf->banque->enabled) && (empty($this->accountid) || $this->accountid <= 0))
|
||||
if (!empty($conf->banque->enabled) && (empty($this->fk_account) || $this->fk_account <= 0))
|
||||
{
|
||||
$this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Account"));
|
||||
$this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("BankAccount"));
|
||||
return -6;
|
||||
}
|
||||
if (!empty($conf->banque->enabled) && (empty($this->type_payment) || $this->type_payment <= 0))
|
||||
@ -454,7 +464,7 @@ class PaymentVarious extends CommonObject
|
||||
$sql .= ", ".($this->fk_project > 0 ? $this->fk_project : 0);
|
||||
$sql .= ", ".$user->id;
|
||||
$sql .= ", '".$this->db->idate($now)."'";
|
||||
$sql .= ", NULL";
|
||||
$sql .= ", NULL"; // Filled later
|
||||
$sql .= ", ".$conf->entity;
|
||||
$sql .= ")";
|
||||
|
||||
@ -473,7 +483,7 @@ class PaymentVarious extends CommonObject
|
||||
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
|
||||
|
||||
$acc = new Account($this->db);
|
||||
$result = $acc->fetch($this->accountid);
|
||||
$result = $acc->fetch($this->fk_account);
|
||||
if ($result <= 0) dol_print_error($this->db);
|
||||
|
||||
// Insert payment into llx_bank
|
||||
@ -495,7 +505,7 @@ class PaymentVarious extends CommonObject
|
||||
$this->datev
|
||||
);
|
||||
|
||||
// Update fk_bank into llx_paiement.
|
||||
// Update fk_bank into llx_payment_various
|
||||
// So we know the payment which has generate the banking ecriture
|
||||
if ($bank_line_id > 0) {
|
||||
$this->update_fk_bank($bank_line_id);
|
||||
|
||||
@ -491,7 +491,7 @@ if ($id)
|
||||
);
|
||||
$formquestion[] = array('type' => 'date', 'tdclass'=>'fieldrequired', 'name' => 'clone_date_payment', 'label' => $langs->trans("DatePayment"), 'value' => -1);
|
||||
$formquestion[] = array('type' => 'date', 'name' => 'clone_date_value', 'label' => $langs->trans("DateValue"), 'value' => -1);
|
||||
$formquestion[] = array('type' => 'other', 'tdclass'=>'fieldrequired', 'name' => 'accountid', 'label' => $langs->trans("BankAccount"), 'value' => $form->select_comptes($accountid, "accountid", 0, '', 1));
|
||||
$formquestion[] = array('type' => 'other', 'tdclass'=>'fieldrequired', 'name' => 'accountid', 'label' => $langs->trans("BankAccount"), 'value' => $form->select_comptes($accountid, "accountid", 0, '', 1, '', 0, 'minwidth200', 1));
|
||||
|
||||
print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneVariousPayment', $object->ref), 'confirm_clone', $formquestion, 'yes', 1, 300);
|
||||
}
|
||||
|
||||
@ -229,6 +229,8 @@ if ($modecompta == 'BOOKKEEPING')
|
||||
print "</tr>\n";
|
||||
|
||||
|
||||
$total_ht_outcome = $total_ttc_outcome = $total_ht_income = $total_ttc_income = 0;
|
||||
|
||||
|
||||
if ($modecompta == 'BOOKKEEPING')
|
||||
{
|
||||
@ -438,16 +440,97 @@ if ($modecompta == 'BOOKKEEPING')
|
||||
if ($total_ttc == 0)
|
||||
{
|
||||
print '<tr class="oddeven"><td> </td>';
|
||||
print '<td colspan="3" class="opacitymedium">'.$langs->trans("None").'</td>';
|
||||
print '<td colspan="3"><span class="opacitymedium">'.$langs->trans("None").'</span></td>';
|
||||
print '</tr>';
|
||||
}
|
||||
|
||||
$total_ht_income += $total_ht;
|
||||
$total_ttc_income += $total_ttc;
|
||||
print '<tr class="liste_total">';
|
||||
if ($modecompta == 'CREANCES-DETTES')
|
||||
print '<td colspan="3" class="right">'.price($total_ht).'</td>';
|
||||
print '<td colspan="3" class="right">'.price($total_ttc).'</td>';
|
||||
print '</tr>';
|
||||
|
||||
/*
|
||||
* Donations
|
||||
*/
|
||||
|
||||
if (!empty($conf->don->enabled))
|
||||
{
|
||||
print '<tr class="trforbreak"><td colspan="4">'.$langs->trans("Donations").'</td></tr>';
|
||||
|
||||
if ($modecompta == 'CREANCES-DETTES' || $modecompta == 'RECETTES-DEPENSES')
|
||||
{
|
||||
if ($modecompta == 'CREANCES-DETTES')
|
||||
{
|
||||
$sql = "SELECT p.societe as name, p.firstname, p.lastname, date_format(p.datedon,'%Y-%m') as dm, sum(p.amount) as amount";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."don as p";
|
||||
$sql .= " WHERE p.entity IN (".getEntity('donation').")";
|
||||
$sql .= " AND fk_statut in (1,2)";
|
||||
} else {
|
||||
$sql = "SELECT p.societe as nom, p.firstname, p.lastname, date_format(p.datedon,'%Y-%m') as dm, sum(p.amount) as amount";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."don as p";
|
||||
$sql .= " INNER JOIN ".MAIN_DB_PREFIX."payment_donation as pe ON pe.fk_donation = p.rowid";
|
||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as c ON pe.fk_typepayment = c.id";
|
||||
$sql .= " WHERE p.entity IN (".getEntity('donation').")";
|
||||
$sql .= " AND fk_statut >= 2";
|
||||
}
|
||||
if (!empty($date_start) && !empty($date_end))
|
||||
$sql .= " AND p.datedon >= '".$db->idate($date_start)."' AND p.datedon <= '".$db->idate($date_end)."'";
|
||||
}
|
||||
$sql .= " GROUP BY p.societe, p.firstname, p.lastname, dm";
|
||||
$newsortfield = $sortfield;
|
||||
if ($newsortfield == 's.nom, s.rowid') $newsortfield = 'p.societe, p.firstname, p.lastname, dm';
|
||||
if ($newsortfield == 'amount_ht') $newsortfield = 'amount';
|
||||
if ($newsortfield == 'amount_ttc') $newsortfield = 'amount';
|
||||
$sql .= $db->order($newsortfield, $sortorder);
|
||||
|
||||
dol_syslog("get dunning");
|
||||
$result = $db->query($sql);
|
||||
$subtotal_ht = 0;
|
||||
$subtotal_ttc = 0;
|
||||
if ($result)
|
||||
{
|
||||
$num = $db->num_rows($result);
|
||||
$i = 0;
|
||||
if ($num)
|
||||
{
|
||||
while ($i < $num)
|
||||
{
|
||||
$obj = $db->fetch_object($result);
|
||||
|
||||
$total_ht += $obj->amount;
|
||||
$total_ttc += $obj->amount;
|
||||
$subtotal_ht += $obj->amount;
|
||||
$subtotal_ttc += $obj->amount;
|
||||
|
||||
print '<tr class="oddeven"><td> </td>';
|
||||
|
||||
print "<td>".$langs->trans("Donation")." <a href=\"".DOL_URL_ROOT."/don/list.php?search_company=".$obj->name."&search_name=".$obj->firstname." ".$obj->lastname."\">".$obj->name." ".$obj->firstname." ".$obj->lastname."</a></td>\n";
|
||||
|
||||
if ($modecompta == 'CREANCES-DETTES') print '<td class="right">'.price($obj->amount).'</td>';
|
||||
print '<td class="right">'.price($obj->amount).'</td>';
|
||||
print '</tr>';
|
||||
$i++;
|
||||
}
|
||||
} else {
|
||||
print '<tr class="oddeven"><td> </td>';
|
||||
print '<td colspan="3"><span class="opacitymedium">'.$langs->trans("None").'</span></td>';
|
||||
print '</tr>';
|
||||
}
|
||||
} else {
|
||||
dol_print_error($db);
|
||||
}
|
||||
|
||||
$total_ht_income += $subtotal_ht;
|
||||
$total_ttc_income += $subtotal_ttc;
|
||||
print '<tr class="liste_total">';
|
||||
if ($modecompta == 'CREANCES-DETTES')
|
||||
print '<td colspan="3" class="right">'.price($subtotal_ht).'</td>';
|
||||
print '<td colspan="3" class="right">'.price($subtotal_ttc).'</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
|
||||
/*
|
||||
* Suppliers invoices
|
||||
@ -515,7 +598,7 @@ if ($modecompta == 'BOOKKEEPING')
|
||||
}
|
||||
} else {
|
||||
print '<tr class="oddeven"><td> </td>';
|
||||
print '<td colspan="3" class="opacitymedium">'.$langs->trans("None").'</td>';
|
||||
print '<td colspan="3"><span class="opacitymedium">'.$langs->trans("None").'</span></td>';
|
||||
print '</tr>';
|
||||
}
|
||||
|
||||
@ -523,6 +606,9 @@ if ($modecompta == 'BOOKKEEPING')
|
||||
} else {
|
||||
dol_print_error($db);
|
||||
}
|
||||
|
||||
$total_ht_outcome += $subtotal_ht;
|
||||
$total_ttc_outcome += $subtotal_ttc;
|
||||
print '<tr class="liste_total">';
|
||||
if ($modecompta == 'CREANCES-DETTES')
|
||||
print '<td colspan="3" class="right">'.price(-$subtotal_ht).'</td>';
|
||||
@ -530,7 +616,6 @@ if ($modecompta == 'BOOKKEEPING')
|
||||
print '</tr>';
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Charges sociales non deductibles
|
||||
*/
|
||||
@ -592,12 +677,15 @@ if ($modecompta == 'BOOKKEEPING')
|
||||
}
|
||||
} else {
|
||||
print '<tr class="oddeven"><td> </td>';
|
||||
print '<td colspan="3" class="opacitymedium">'.$langs->trans("None").'</td>';
|
||||
print '<td colspan="3"><span class="opacitymedium">'.$langs->trans("None").'</span></td>';
|
||||
print '</tr>';
|
||||
}
|
||||
} else {
|
||||
dol_print_error($db);
|
||||
}
|
||||
|
||||
$total_ht_outcome += $subtotal_ht;
|
||||
$total_ttc_outcome += $subtotal_ttc;
|
||||
print '<tr class="liste_total">';
|
||||
if ($modecompta == 'CREANCES-DETTES')
|
||||
print '<td colspan="3" class="right">'.price(-$subtotal_ht).'</td>';
|
||||
@ -667,36 +755,21 @@ if ($modecompta == 'BOOKKEEPING')
|
||||
}
|
||||
} else {
|
||||
print '<tr class="oddeven"><td> </td>';
|
||||
print '<td colspan="3" class="opacitymedium">'.$langs->trans("None").'</td>';
|
||||
print '<td colspan="3"><span class="opacitymedium">'.$langs->trans("None").'</span></td>';
|
||||
print '</tr>';
|
||||
}
|
||||
} else {
|
||||
dol_print_error($db);
|
||||
}
|
||||
|
||||
$total_ht_outcome += $subtotal_ht;
|
||||
$total_ttc_outcome += $subtotal_ttc;
|
||||
print '<tr class="liste_total">';
|
||||
if ($modecompta == 'CREANCES-DETTES')
|
||||
print '<td colspan="3" class="right">'.price(-$subtotal_ht).'</td>';
|
||||
print '<td colspan="3" class="right">'.price(-$subtotal_ttc).'</td>';
|
||||
print '</tr>';
|
||||
|
||||
if ($mysoc->tva_assuj == 'franchise') // Non assujetti
|
||||
{
|
||||
// Total
|
||||
print '<tr>';
|
||||
print '<td colspan="4"> </td>';
|
||||
print '</tr>';
|
||||
|
||||
print '<tr class="liste_total"><td class="left" colspan="2">'.$langs->trans("Profit").'</td>';
|
||||
if ($modecompta == 'CREANCES-DETTES')
|
||||
print '<td class="border right">'.price($total_ht).'</td>';
|
||||
print '<td class="right">'.price($total_ttc).'</td>';
|
||||
print '</tr>';
|
||||
|
||||
print '<tr>';
|
||||
print '<td colspan="4"> </td>';
|
||||
print '</tr>';
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Salaries
|
||||
@ -759,12 +832,15 @@ if ($modecompta == 'BOOKKEEPING')
|
||||
}
|
||||
} else {
|
||||
print '<tr class="oddeven"><td> </td>';
|
||||
print '<td colspan="3" class="opacitymedium">'.$langs->trans("None").'</td>';
|
||||
print '<td colspan="3"><span class="opacitymedium">'.$langs->trans("None").'</span></td>';
|
||||
print '</tr>';
|
||||
}
|
||||
} else {
|
||||
dol_print_error($db);
|
||||
}
|
||||
|
||||
$total_ht_outcome += $subtotal_ht;
|
||||
$total_ttc_outcome += $subtotal_ttc;
|
||||
print '<tr class="liste_total">';
|
||||
if ($modecompta == 'CREANCES-DETTES')
|
||||
print '<td colspan="3" class="right">'.price(-$subtotal_ht).'</td>';
|
||||
@ -841,98 +917,26 @@ if ($modecompta == 'BOOKKEEPING')
|
||||
}
|
||||
} else {
|
||||
print '<tr class="oddeven"><td> </td>';
|
||||
print '<td colspan="3" class="opacitymedium">'.$langs->trans("None").'</td>';
|
||||
print '<td colspan="3"><span class="opacitymedium">'.$langs->trans("None").'</span></td>';
|
||||
print '</tr>';
|
||||
}
|
||||
} else {
|
||||
dol_print_error($db);
|
||||
}
|
||||
|
||||
$total_ht_outcome += $subtotal_ht;
|
||||
$total_ttc_outcome += $subtotal_ttc;
|
||||
print '<tr class="liste_total">';
|
||||
if ($modecompta == 'CREANCES-DETTES') print '<td colspan="3" class="right">'.price(-$subtotal_ht).'</td>';
|
||||
print '<td colspan="3" class="right">'.price(-$subtotal_ttc).'</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
|
||||
/*
|
||||
* Donations
|
||||
*/
|
||||
|
||||
if (!empty($conf->don->enabled))
|
||||
{
|
||||
print '<tr class="trforbreak"><td colspan="4">'.$langs->trans("Donations").'</td></tr>';
|
||||
|
||||
if ($modecompta == 'CREANCES-DETTES' || $modecompta == 'RECETTES-DEPENSES')
|
||||
{
|
||||
if ($modecompta == 'CREANCES-DETTES')
|
||||
{
|
||||
$sql = "SELECT p.societe as name, p.firstname, p.lastname, date_format(p.datedon,'%Y-%m') as dm, sum(p.amount) as amount";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."don as p";
|
||||
$sql .= " WHERE p.entity IN (".getEntity('donation').")";
|
||||
$sql .= " AND fk_statut in (1,2)";
|
||||
} else {
|
||||
$sql = "SELECT p.societe as nom, p.firstname, p.lastname, date_format(p.datedon,'%Y-%m') as dm, sum(p.amount) as amount";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."don as p";
|
||||
$sql .= " INNER JOIN ".MAIN_DB_PREFIX."payment_donation as pe ON pe.fk_donation = p.rowid";
|
||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as c ON pe.fk_typepayment = c.id";
|
||||
$sql .= " WHERE p.entity IN (".getEntity('donation').")";
|
||||
$sql .= " AND fk_statut >= 2";
|
||||
}
|
||||
if (!empty($date_start) && !empty($date_end))
|
||||
$sql .= " AND p.datedon >= '".$db->idate($date_start)."' AND p.datedon <= '".$db->idate($date_end)."'";
|
||||
}
|
||||
$sql .= " GROUP BY p.societe, p.firstname, p.lastname, dm";
|
||||
$newsortfield = $sortfield;
|
||||
if ($newsortfield == 's.nom, s.rowid') $newsortfield = 'p.societe, p.firstname, p.lastname, dm';
|
||||
if ($newsortfield == 'amount_ht') $newsortfield = 'amount';
|
||||
if ($newsortfield == 'amount_ttc') $newsortfield = 'amount';
|
||||
$sql .= $db->order($newsortfield, $sortorder);
|
||||
|
||||
dol_syslog("get dunning");
|
||||
$result = $db->query($sql);
|
||||
$subtotal_ht = 0;
|
||||
$subtotal_ttc = 0;
|
||||
if ($result)
|
||||
{
|
||||
$num = $db->num_rows($result);
|
||||
$i = 0;
|
||||
if ($num)
|
||||
{
|
||||
while ($i < $num)
|
||||
{
|
||||
$obj = $db->fetch_object($result);
|
||||
|
||||
$total_ht += $obj->amount;
|
||||
$total_ttc += $obj->amount;
|
||||
$subtotal_ht += $obj->amount;
|
||||
$subtotal_ttc += $obj->amount;
|
||||
|
||||
print '<tr class="oddeven"><td> </td>';
|
||||
|
||||
print "<td>".$langs->trans("Donation")." <a href=\"".DOL_URL_ROOT."/don/list.php?search_company=".$obj->name."&search_name=".$obj->firstname." ".$obj->lastname."\">".$obj->name." ".$obj->firstname." ".$obj->lastname."</a></td>\n";
|
||||
|
||||
if ($modecompta == 'CREANCES-DETTES') print '<td class="right">'.price($obj->amount).'</td>';
|
||||
print '<td class="right">'.price($obj->amount).'</td>';
|
||||
print '</tr>';
|
||||
$i++;
|
||||
}
|
||||
} else {
|
||||
print '<tr class="oddeven"><td> </td>';
|
||||
print '<td colspan="3" class="opacitymedium">'.$langs->trans("None").'</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
} else {
|
||||
dol_print_error($db);
|
||||
}
|
||||
print '<tr class="liste_total">';
|
||||
if ($modecompta == 'CREANCES-DETTES')
|
||||
print '<td colspan="3" class="right">'.price($subtotal_ht).'</td>';
|
||||
print '<td colspan="3" class="right">'.price($subtotal_ttc).'</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
|
||||
/*
|
||||
* Various Payments
|
||||
*/
|
||||
//$conf->global->ACCOUNTING_REPORTS_INCLUDE_VARPAY = 1;
|
||||
|
||||
if (!empty($conf->global->ACCOUNTING_REPORTS_INCLUDE_VARPAY) && !empty($conf->banque->enabled) && ($modecompta == 'CREANCES-DETTES' || $modecompta == "RECETTES-DEPENSES"))
|
||||
{
|
||||
@ -953,12 +957,14 @@ if ($modecompta == 'BOOKKEEPING')
|
||||
$result = $db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
// Debit
|
||||
// Debit (payment of suppliers for example)
|
||||
$obj = $db->fetch_object($result);
|
||||
if (isset($obj->amount))
|
||||
{
|
||||
$subtotal_ht += -$obj->amount;
|
||||
$subtotal_ttc += -$obj->amount;
|
||||
$total_ht_outcome += $obj->amount;
|
||||
$total_ttc_outcome += $obj->amount;
|
||||
}
|
||||
print '<tr class="oddeven"><td> </td>';
|
||||
print "<td>".$langs->trans("Debit")."</td>\n";
|
||||
@ -966,12 +972,14 @@ if ($modecompta == 'BOOKKEEPING')
|
||||
print '<td class="right">'.price(-$obj->amount)."</td>\n";
|
||||
print "</tr>\n";
|
||||
|
||||
// Credit
|
||||
// Credit (payment received from customer for example)
|
||||
$obj = $db->fetch_object($result);
|
||||
if (isset($obj->amount))
|
||||
{
|
||||
$subtotal_ht += $obj->amount;
|
||||
$subtotal_ttc += $obj->amount;
|
||||
$total_ht_income += $obj->amount;
|
||||
$total_ttc_income += $obj->amount;
|
||||
}
|
||||
print '<tr class="oddeven"><td> </td>';
|
||||
print "<td>".$langs->trans("Credit")."</td>\n";
|
||||
@ -1030,6 +1038,8 @@ if ($modecompta == 'BOOKKEEPING')
|
||||
}
|
||||
$total_ht += $subtotal_ht;
|
||||
$total_ttc += $subtotal_ttc;
|
||||
$total_ht_income += $subtotal_ht;
|
||||
$total_ttc_income += $subtotal_ttc;
|
||||
print '<tr class="liste_total">';
|
||||
if ($modecompta == 'CREANCES-DETTES')
|
||||
print '<td colspan="3" class="right">'.price($subtotal_ht).'</td>';
|
||||
@ -1050,7 +1060,7 @@ if ($modecompta == 'BOOKKEEPING')
|
||||
{
|
||||
if ($modecompta == 'CREANCES-DETTES')
|
||||
{
|
||||
// TVA a payer
|
||||
// VAT to pay
|
||||
$amount = 0;
|
||||
$sql = "SELECT date_format(f.datef,'%Y-%m') as dm, sum(f.tva) as amount";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."facture as f";
|
||||
@ -1091,13 +1101,15 @@ if ($modecompta == 'BOOKKEEPING')
|
||||
} else {
|
||||
dol_print_error($db);
|
||||
}
|
||||
$total_ht_outcome -= 0;
|
||||
$total_ttc_outcome -= $amount;
|
||||
print '<tr class="oddeven"><td> </td>';
|
||||
print "<td>".$langs->trans("VATToPay")."</td>\n";
|
||||
print '<td class="right"> </td>'."\n";
|
||||
print '<td class="right">'.price($amount)."</td>\n";
|
||||
print "</tr>\n";
|
||||
|
||||
// TVA a recuperer
|
||||
// VAT to retreive
|
||||
$amount = 0;
|
||||
$sql = "SELECT date_format(f.datef,'%Y-%m') as dm, sum(f.total_tva) as amount";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f";
|
||||
@ -1139,6 +1151,9 @@ if ($modecompta == 'BOOKKEEPING')
|
||||
} else {
|
||||
dol_print_error($db);
|
||||
}
|
||||
$total_ht_income += 0;
|
||||
$total_ttc_income += $amount;
|
||||
|
||||
print '<tr class="oddeven"><td> </td>';
|
||||
print '<td>'.$langs->trans("VATToCollect")."</td>\n";
|
||||
print '<td class="right"> </td>'."\n";
|
||||
@ -1182,10 +1197,12 @@ if ($modecompta == 'BOOKKEEPING')
|
||||
} else {
|
||||
dol_print_error($db);
|
||||
}
|
||||
$total_ht_outcome -= 0;
|
||||
$total_ttc_outcome -= $amount;
|
||||
print '<tr class="oddeven"><td> </td>';
|
||||
print "<td>".$langs->trans("VATPaid")."</td>\n";
|
||||
if ($modecompta == 'CREANCES-DETTES')
|
||||
print '<td <class="right">'.price($amount)."</td>\n";
|
||||
print '<td <class="right"></td>'."\n";
|
||||
print '<td class="right">'.price($amount)."</td>\n";
|
||||
print "</tr>\n";
|
||||
|
||||
@ -1226,16 +1243,18 @@ if ($modecompta == 'BOOKKEEPING')
|
||||
} else {
|
||||
dol_print_error($db);
|
||||
}
|
||||
$total_ht_income += 0;
|
||||
$total_ttc_income += $amount;
|
||||
print '<tr class="oddeven"><td> </td>';
|
||||
print "<td>".$langs->trans("VATCollected")."</td>\n";
|
||||
if ($modecompta == 'CREANCES-DETTES')
|
||||
print '<td class="right">'.price($amount)."</td>\n";
|
||||
print '<td class="right"></td>'."\n";
|
||||
print '<td class="right">'.price($amount)."</td>\n";
|
||||
print "</tr>\n";
|
||||
}
|
||||
}
|
||||
|
||||
if ($mysoc->tva_assuj != 'franchise') // Assujetti
|
||||
if ($mysoc->tva_assuj != '0') // Assujetti
|
||||
{
|
||||
print '<tr class="liste_total">';
|
||||
if ($modecompta == 'CREANCES-DETTES')
|
||||
@ -1250,25 +1269,31 @@ $object = array(&$total_ht, &$total_ttc);
|
||||
$parameters["mode"] = $modecompta;
|
||||
$parameters["date_start"] = $date_start;
|
||||
$parameters["date_end"] = $date_end;
|
||||
$parameters["bc"] = $bc;
|
||||
// Initialize technical object to manage hooks of expenses. Note that conf->hooks_modules contains array array
|
||||
$hookmanager->initHooks(array('externalbalance'));
|
||||
$reshook = $hookmanager->executeHooks('addBalanceLine', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
|
||||
print $hookmanager->resPrint;
|
||||
|
||||
if ($mysoc->tva_assuj != 'franchise') // Assujetti
|
||||
{
|
||||
// Total
|
||||
print '<tr>';
|
||||
print '<td colspan="4"> </td>';
|
||||
print '</tr>';
|
||||
// Total
|
||||
print '<tr>';
|
||||
print '<td colspan="4"> </td>';
|
||||
print '</tr>';
|
||||
|
||||
print '<tr class="liste_total"><td class="left" colspan="2">'.$langs->trans("Profit").'</td>';
|
||||
if ($modecompta == 'CREANCES-DETTES')
|
||||
print '<td class="liste_total right">'.price(price2num($total_ht, 'MT')).'</td>';
|
||||
print '<td class="liste_total right">'.price(price2num($total_ttc, 'MT')).'</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
print '<tr class="liste_total"><td class="left" colspan="2">'.$langs->trans("Outcome").'</td>';
|
||||
if ($modecompta == 'CREANCES-DETTES')
|
||||
print '<td class="liste_total right">'.price(price2num(-$total_ht_outcome, 'MT')).'</td>';
|
||||
print '<td class="liste_total right">'.price(price2num(-$total_ttc_outcome, 'MT')).'</td>';
|
||||
print '</tr>';
|
||||
print '<tr class="liste_total"><td class="left" colspan="2">'.$langs->trans("Income").'</td>';
|
||||
if ($modecompta == 'CREANCES-DETTES')
|
||||
print '<td class="liste_total right">'.price(price2num($total_ht_income, 'MT')).'</td>';
|
||||
print '<td class="liste_total right">'.price(price2num($total_ttc_income, 'MT')).'</td>';
|
||||
print '</tr>';
|
||||
print '<tr class="liste_total"><td class="left" colspan="2">'.$langs->trans("Profit").'</td>';
|
||||
if ($modecompta == 'CREANCES-DETTES')
|
||||
print '<td class="liste_total right">'.price(price2num($total_ht, 'MT')).'</td>';
|
||||
print '<td class="liste_total right">'.price(price2num($total_ttc, 'MT')).'</td>';
|
||||
print '</tr>';
|
||||
|
||||
print "</table>";
|
||||
print '<br>';
|
||||
|
||||
@ -355,7 +355,7 @@ abstract class CommonObject
|
||||
public $last_main_doc;
|
||||
|
||||
/**
|
||||
* @var int Bank account ID
|
||||
* @var int Bank account ID sometimes, ID of record into llx_bank sometimes
|
||||
* @deprecated
|
||||
* @see $fk_account
|
||||
*/
|
||||
|
||||
@ -3939,13 +3939,16 @@ class Form
|
||||
* @param string $moreattrib To add more attribute on select
|
||||
* @param int $showcurrency Show currency in label
|
||||
* @param string $morecss More CSS
|
||||
* @param int $nooutput 1=Return string, do not send to output
|
||||
* @return int <0 if error, Num of bank account found if OK (0, 1, 2, ...)
|
||||
*/
|
||||
public function select_comptes($selected = '', $htmlname = 'accountid', $status = 0, $filtre = '', $useempty = 0, $moreattrib = '', $showcurrency = 0, $morecss = '')
|
||||
public function select_comptes($selected = '', $htmlname = 'accountid', $status = 0, $filtre = '', $useempty = 0, $moreattrib = '', $showcurrency = 0, $morecss = '', $nooutput = 0)
|
||||
{
|
||||
// phpcs:enable
|
||||
global $langs, $conf;
|
||||
|
||||
$out = '';
|
||||
|
||||
$langs->load("admin");
|
||||
$num = 0;
|
||||
|
||||
@ -3964,10 +3967,10 @@ class Form
|
||||
$i = 0;
|
||||
if ($num)
|
||||
{
|
||||
print '<select id="select'.$htmlname.'" class="flat selectbankaccount'.($morecss ? ' '.$morecss : '').'" name="'.$htmlname.'"'.($moreattrib ? ' '.$moreattrib : '').'>';
|
||||
$out .= '<select id="select'.$htmlname.'" class="flat selectbankaccount'.($morecss ? ' '.$morecss : '').'" name="'.$htmlname.'"'.($moreattrib ? ' '.$moreattrib : '').'>';
|
||||
if ($useempty == 1 || ($useempty == 2 && $num > 1))
|
||||
{
|
||||
print '<option value="-1"> </option>';
|
||||
$out .= '<option value="-1"> </option>';
|
||||
}
|
||||
|
||||
while ($i < $num)
|
||||
@ -3975,26 +3978,30 @@ class Form
|
||||
$obj = $this->db->fetch_object($result);
|
||||
if ($selected == $obj->rowid || ($useempty == 2 && $num == 1 && empty($selected)))
|
||||
{
|
||||
print '<option value="'.$obj->rowid.'" selected>';
|
||||
$out .= '<option value="'.$obj->rowid.'" selected>';
|
||||
} else {
|
||||
print '<option value="'.$obj->rowid.'">';
|
||||
$out .= '<option value="'.$obj->rowid.'">';
|
||||
}
|
||||
print trim($obj->label);
|
||||
if ($showcurrency) print ' ('.$obj->currency_code.')';
|
||||
if ($status == 2 && $obj->status == 1) print ' ('.$langs->trans("Closed").')';
|
||||
print '</option>';
|
||||
$out .= trim($obj->label);
|
||||
if ($showcurrency) $out .= ' ('.$obj->currency_code.')';
|
||||
if ($status == 2 && $obj->status == 1) $out .= ' ('.$langs->trans("Closed").')';
|
||||
$out .= '</option>';
|
||||
$i++;
|
||||
}
|
||||
print "</select>";
|
||||
print ajax_combobox('select'.$htmlname);
|
||||
$out .= "</select>";
|
||||
$out .= ajax_combobox('select'.$htmlname);
|
||||
} else {
|
||||
if ($status == 0) print '<span class="opacitymedium">'.$langs->trans("NoActiveBankAccountDefined").'</span>';
|
||||
else print '<span class="opacitymedium">'.$langs->trans("NoBankAccountFound").'</span>';
|
||||
if ($status == 0) $out .= '<span class="opacitymedium">'.$langs->trans("NoActiveBankAccountDefined").'</span>';
|
||||
else $out .= '<span class="opacitymedium">'.$langs->trans("NoBankAccountFound").'</span>';
|
||||
}
|
||||
} else {
|
||||
dol_print_error($this->db);
|
||||
}
|
||||
|
||||
// Output or return
|
||||
if (empty($nooutput)) print $out;
|
||||
else return $out;
|
||||
|
||||
return $num;
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user