Doc: Documentation doxygen
This commit is contained in:
parent
808294fafe
commit
1cf55396a0
@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Copyright (C) 2002-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
/* Copyright (C) 2002-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||||
* Copyright (C) 2004 Laurent Destailleur <eldy@users.sourceforge.net>
|
* Copyright (C) 2004-2005 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
*
|
*
|
||||||
* 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
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
@ -20,188 +20,195 @@
|
|||||||
* $Source$
|
* $Source$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* La tva collectée n'est calculée que sur les factures payées.
|
\file htdocs/chargesociales.class.php
|
||||||
*
|
\ingroup compta
|
||||||
*
|
\brief Fichier de la classe de tva
|
||||||
*/
|
\remarks La tva collectée n'est calculée que sur les factures payées.
|
||||||
|
\version $Revision$
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/** \class PaiementCharge
|
||||||
|
\brief Classe permettant la gestion de la tva
|
||||||
|
*/
|
||||||
|
|
||||||
class Tva
|
class Tva
|
||||||
{
|
{
|
||||||
var $db;
|
var $db;
|
||||||
var $note;
|
var $note;
|
||||||
/*
|
|
||||||
* Initialistation automatique de la classe
|
/*
|
||||||
*/
|
* \brief Constructeur
|
||||||
function Tva($DB)
|
*/
|
||||||
|
function Tva($DB)
|
||||||
{
|
{
|
||||||
$this->db = $DB;
|
$this->db = $DB;
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* \brief Hum la fonction s'appelle 'Solde' elle doit a mon avis calcluer le solde de TVA, non ?
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
function solde($year = 0)
|
|
||||||
{
|
|
||||||
|
|
||||||
$reglee = $this->tva_sum_reglee($year);
|
|
||||||
|
|
||||||
$payee = $this->tva_sum_payee($year);
|
return 1;
|
||||||
$collectee = $this->tva_sum_collectee($year);
|
|
||||||
|
|
||||||
$solde = $reglee - ($collectee - $payee) ;
|
|
||||||
|
|
||||||
return $solde;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* \brief Total de la TVA des factures emises par la societe.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
function tva_sum_collectee($year = 0)
|
|
||||||
{
|
|
||||||
|
|
||||||
$sql = "SELECT sum(f.tva) as amount";
|
|
||||||
$sql .= " FROM ".MAIN_DB_PREFIX."facture as f WHERE f.paye = 1";
|
|
||||||
|
|
||||||
if ($year)
|
|
||||||
{
|
|
||||||
$sql .= " AND f.datef >= '$year-01-01' AND f.datef <= '$year-12-31' ";
|
|
||||||
}
|
|
||||||
|
|
||||||
$result = $this->db->query($sql);
|
|
||||||
|
|
||||||
if ($result)
|
|
||||||
{
|
|
||||||
if ($this->db->num_rows())
|
|
||||||
{
|
|
||||||
$obj = $this->db->fetch_object($result);
|
|
||||||
return $obj->amount;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->db->free();
|
|
||||||
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
print $this->db->error();
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* \brief Tva payée
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
function tva_sum_payee($year = 0)
|
|
||||||
{
|
|
||||||
|
|
||||||
$sql = "SELECT sum(f.amount) as amount";
|
|
||||||
$sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f";
|
|
||||||
|
|
||||||
if ($year)
|
|
||||||
{
|
|
||||||
$sql .= " WHERE f.datef >= '$year-01-01' AND f.datef <= '$year-12-31' ";
|
|
||||||
}
|
|
||||||
|
|
||||||
$result = $this->db->query($sql);
|
|
||||||
|
|
||||||
if ($result)
|
|
||||||
{
|
|
||||||
if ($this->db->num_rows())
|
|
||||||
{
|
|
||||||
$obj = $this->db->fetch_object($result);
|
|
||||||
return $obj->amount;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->db->free();
|
|
||||||
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
print $this->db->error();
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Tva réglée
|
|
||||||
* Total de la TVA réglee aupres de qui de droit
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
function tva_sum_reglee($year = 0)
|
|
||||||
{
|
|
||||||
|
|
||||||
$sql = "SELECT sum(f.amount) as amount";
|
|
||||||
$sql .= " FROM ".MAIN_DB_PREFIX."tva as f";
|
|
||||||
|
|
||||||
if ($year)
|
|
||||||
{
|
|
||||||
$sql .= " WHERE f.datev >= '$year-01-01' AND f.datev <= '$year-12-31' ";
|
|
||||||
}
|
|
||||||
|
|
||||||
$result = $this->db->query($sql);
|
|
||||||
|
|
||||||
if ($result)
|
|
||||||
{
|
|
||||||
if ($this->db->num_rows())
|
|
||||||
{
|
|
||||||
$obj = $this->db->fetch_object($result);
|
|
||||||
return $obj->amount;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->db->free();
|
|
||||||
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
print $this->db->error();
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*
|
* \brief Hum la fonction s'appelle 'Solde' elle doit a mon avis calcluer le solde de TVA, non ?
|
||||||
*/
|
*
|
||||||
|
*/
|
||||||
function add_payement($datep, $datev, $amount)
|
function solde($year = 0)
|
||||||
{
|
{
|
||||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."tva (datep, datev, amount) ";
|
|
||||||
$sql .= " VALUES ('".$this->db->idate($datep)."',";
|
|
||||||
$sql .= "'".$this->db->idate($datev)."'," . ereg_replace(",",".",$amount) .")";
|
|
||||||
|
|
||||||
$result = $this->db->query($sql);
|
$reglee = $this->tva_sum_reglee($year);
|
||||||
|
|
||||||
if ($result)
|
$payee = $this->tva_sum_payee($year);
|
||||||
{
|
$collectee = $this->tva_sum_collectee($year);
|
||||||
return 1;
|
|
||||||
}
|
$solde = $reglee - ($collectee - $payee) ;
|
||||||
else
|
|
||||||
{
|
return $solde;
|
||||||
print $this->db->error()."<br>".$sql;
|
}
|
||||||
return -1;
|
|
||||||
}
|
/*
|
||||||
|
* \brief Total de la TVA des factures emises par la societe.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
function tva_sum_collectee($year = 0)
|
||||||
|
{
|
||||||
|
|
||||||
|
$sql = "SELECT sum(f.tva) as amount";
|
||||||
|
$sql .= " FROM ".MAIN_DB_PREFIX."facture as f WHERE f.paye = 1";
|
||||||
|
|
||||||
|
if ($year)
|
||||||
|
{
|
||||||
|
$sql .= " AND f.datef >= '$year-01-01' AND f.datef <= '$year-12-31' ";
|
||||||
|
}
|
||||||
|
|
||||||
|
$result = $this->db->query($sql);
|
||||||
|
|
||||||
|
if ($result)
|
||||||
|
{
|
||||||
|
if ($this->db->num_rows())
|
||||||
|
{
|
||||||
|
$obj = $this->db->fetch_object($result);
|
||||||
|
return $obj->amount;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->db->free();
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print $this->db->error();
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* \brief Tva payée
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
function tva_sum_payee($year = 0)
|
||||||
|
{
|
||||||
|
|
||||||
|
$sql = "SELECT sum(f.amount) as amount";
|
||||||
|
$sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f";
|
||||||
|
|
||||||
|
if ($year)
|
||||||
|
{
|
||||||
|
$sql .= " WHERE f.datef >= '$year-01-01' AND f.datef <= '$year-12-31' ";
|
||||||
|
}
|
||||||
|
|
||||||
|
$result = $this->db->query($sql);
|
||||||
|
|
||||||
|
if ($result)
|
||||||
|
{
|
||||||
|
if ($this->db->num_rows())
|
||||||
|
{
|
||||||
|
$obj = $this->db->fetch_object($result);
|
||||||
|
return $obj->amount;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->db->free();
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print $this->db->error();
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* \brief Tva réglée
|
||||||
|
* Total de la TVA réglee aupres de qui de droit
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
function tva_sum_reglee($year = 0)
|
||||||
|
{
|
||||||
|
|
||||||
|
$sql = "SELECT sum(f.amount) as amount";
|
||||||
|
$sql .= " FROM ".MAIN_DB_PREFIX."tva as f";
|
||||||
|
|
||||||
|
if ($year)
|
||||||
|
{
|
||||||
|
$sql .= " WHERE f.datev >= '$year-01-01' AND f.datev <= '$year-12-31' ";
|
||||||
|
}
|
||||||
|
|
||||||
|
$result = $this->db->query($sql);
|
||||||
|
|
||||||
|
if ($result)
|
||||||
|
{
|
||||||
|
if ($this->db->num_rows())
|
||||||
|
{
|
||||||
|
$obj = $this->db->fetch_object($result);
|
||||||
|
return $obj->amount;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->db->free();
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print $this->db->error();
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* \brief Ajoute un paiement de TVA
|
||||||
|
*/
|
||||||
|
|
||||||
|
function add_payement($datep, $datev, $amount)
|
||||||
|
{
|
||||||
|
$sql = "INSERT INTO ".MAIN_DB_PREFIX."tva (datep, datev, amount) ";
|
||||||
|
$sql .= " VALUES ('".$this->db->idate($datep)."',";
|
||||||
|
$sql .= "'".$this->db->idate($datev)."'," . ereg_replace(",",".",$amount) .")";
|
||||||
|
|
||||||
|
$result = $this->db->query($sql);
|
||||||
|
|
||||||
|
if ($result)
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$this->error=$this->db->error();
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user