Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dolibarr
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Software_Artifact_Infrastructure_Repository
dolibarr
Commits
1cf55396
Commit
1cf55396
authored
19 years ago
by
Laurent Destailleur
Browse files
Options
Downloads
Patches
Plain Diff
Doc: Documentation doxygen
parent
808294fa
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
htdocs/tva.class.php
+170
-163
170 additions, 163 deletions
htdocs/tva.class.php
with
170 additions
and
163 deletions
htdocs/tva.class.php
+
170
−
163
View file @
1cf55396
<?php
/* 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
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
...
...
@@ -20,188 +20,195 @@
* $Source$
*/
/*
* La tva collecte n'est calcule que sur les factures payes.
*
*
*/
/**
\file htdocs/chargesociales.class.php
\ingroup compta
\brief Fichier de la classe de tva
\remarks La tva collecte n'est calcule que sur les factures payes.
\version $Revision$
*/
/** \class PaiementCharge
\brief Classe permettant la gestion de la tva
*/
class
Tva
{
var
$db
;
var
$note
;
/*
* Initialistation automatique de la classe
*/
function
Tva
(
$DB
)
var
$db
;
var
$note
;
/*
* \brief Constructeur
*/
function
Tva
(
$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
)
$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
);
$collectee
=
$this
->
tva_sum_collectee
(
$year
);
$reglee
=
$this
->
tva_sum_reglee
(
$year
);
$solde
=
$reglee
-
(
$collectee
-
$payee
)
;
$payee
=
$this
->
tva_sum_payee
(
$year
);
$collectee
=
$this
->
tva_sum_collectee
(
$year
);
return
$solde
;
}
/*
* \brief Total de la TVA des factures emises par la societe.
*
*/
function
tva_sum_collectee
(
$year
=
0
)
{
$solde
=
$reglee
-
(
$collectee
-
$payee
)
;
$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
;
}
return
$solde
;
}
/*
* \brief Tva paye
*
*/
function
tva_sum_
pay
ee
(
$year
=
0
)
/*
* \brief Total de la TVA des factures emises par la societe.
*
*/
function
tva_sum_
collect
ee
(
$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
;
}
$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
;
}
}
/*
* Tva rgle
* Total de la TVA rglee aupres de qui de droit
*
*/
function
tva_sum_reglee
(
$year
=
0
)
/*
* \brief Tva paye
*
*/
function
tva_sum_payee
(
$year
=
0
)
{
$sql
=
"SELECT sum(f.amount) as amount"
;
$sql
.
=
" FROM "
.
MAIN_DB_PREFIX
.
"
tva
as f"
;
if
(
$year
)
{
$sql
.
=
" WHERE f.date
v
>= '
$year
-01-01' AND f.date
v
<= '
$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
;
}
$sql
=
"SELECT sum(f.amount) as amount"
;
$sql
.
=
" FROM "
.
MAIN_DB_PREFIX
.
"
facture_fourn
as f"
;
if
(
$year
)
{
$sql
.
=
" WHERE f.date
f
>= '
$year
-01-01' AND f.date
f
<= '
$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
;
}
}
/*
*
*/
function
add_payement
(
$datep
,
$datev
,
$amount
)
/*
* \brief Tva rgle
* Total de la TVA rglee aupres de qui de droit
*
*/
function
tva_sum_reglee
(
$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
);
$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
;
}
}
if
(
$result
)
{
return
1
;
}
else
{
print
$this
->
db
->
error
()
.
"<br>"
.
$sql
;
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
;
}
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment