[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Dolibarr-dev] Patch pour creer une facture a partir d'une commande four
From: |
Sébastien Wacquiez |
Subject: |
[Dolibarr-dev] Patch pour creer une facture a partir d'une commande fournisseur |
Date: |
Mon, 26 May 2008 16:51:15 +0000 |
User-agent: |
Icedove 1.5.0.14eol (X11/20080509) |
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Salutation,
J'ai eu le besoin, pour simplifier mes process internes, de pouvoir
creer des factures à partir des commandes fournisseurs établies
(histoire de ne pas tout avoir a recopier).
Je ne sais pas trop si c'est pertinent ou pas sur un plan comptable, si
cela peu etre utile à quelqu'un d'autre ou si le code que j'ai ecris
merite d'etre publié, mais dans tout les cas, voici le patch en piece
jointe, que j'aimerais vraiment voir inclu dans dolibarr :)
Pour sa réalisation, j'ai principalement repomper sur le modele qu'il y
avait deja ; etant donné que contrairement aux commandes clientes, le
module fournisseur à l'air completement séparé du reste, je n'ai pas
touché au module compta.
Au niveau sql, je n'ai rien rajouté qui n'existait deja, la table
nécéssaire étant déja présente dans la DB.
Enfin, j'aurais aimé savoir ; j'ai besoin de préciser des conditions de
paiement sur les bons de commande fournisseur que j'envoie, ce qu'on ne
peut apparement pas faire a présent ; je ne vois pas de moyen propre de
proceder sans modifier la structure de la base de donnée, quelqu'un en
voit-il un ?
- --
Sébastien Wacquiez, Network Engineer
Smartjog S.A. - http://www.smartjog.com
27 Bd Hippolyte Marques, 94200 Ivry sur Seine, France
Tel : +33 (0)1 58 68 62 38
Cell : +33 (0)6 08 03 62 67
Fax : +33 (0)1 58 68 62 05
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFIOuqDgw1oyjuyyqcRAgENAJ9bnUXh+L/61gA1JOzxIUUVNA5DRwCcCF06
7EsIZJNV6CNUXPY1zoOmLis=
=lGIQ
-----END PGP SIGNATURE-----
? patch-commande-vers-facture.patch
? compta/commande_fourn.php
Index: fourn/fournisseur.facture.class.php
===================================================================
RCS file:
/cvsroot/dolibarr/dolibarr/htdocs/fourn/fournisseur.facture.class.php,v
retrieving revision 1.61
diff -r1.61 fournisseur.facture.class.php
123a124
> $error = 0;
139a141,148
>
> if (! $error && $this->id && $this->commandeid)
> {
> $sql = 'INSERT INTO
> '.MAIN_DB_PREFIX.'comfourn_facfourn (fk_facture, fk_commande) VALUES
> ('.$this->id.','.$this->commandeid.')';
> $resql=$this->db->query($sql);
> if (! $resql) $error++;
> }
>
141c150
< if ($this->update_price() > 0)
---
> if (! $error && $this->update_price() > 0)
148c157,158
<
$this->error=$langs->trans('FailedToUpdatePrice');
---
> $this->error=$this->db->error();
> dolibarr_syslog("FournFacture::create error
> ".$this->error." sql=".$sql);
Index: fourn/commande/fiche.php
===================================================================
RCS file: /cvsroot/dolibarr/dolibarr/htdocs/fourn/commande/fiche.php,v
retrieving revision 1.100
diff -r1.100 fiche.php
895c895
< if ($user->societe_id == 0 && $commande->statut < 3 &&
$_GET['action'] <> 'editline')
---
> if ($user->societe_id == 0 && ($commande->statut < 3 ||
> $commande->statut == 5) && $_GET['action'] <> 'editline')
937a938,946
>
> if ($commande->statut >= 2)
>
> {
> if ($user->rights->fournisseur->facture->creer)
> {
> print '<a class="butAction"
> href="../facture/fiche.php?commandeid='.$commande->id.'&action=create">'.$langs->trans("CreateBill").'</a>';
> }
> }
958,962c967,1014
<
<
< print '</td><td width="50%" valign="top">';
<
<
---
>
> /*
> * Commande Ratache
> */
>
> $sql = 'SELECT '.$db->pdate('f.datec').' as date, f.total_ht as
> total_ht, f.facnumber as ref, f.fk_soc as ref_fourn, f.rowid as id';
> $sql .= ' FROM '.MAIN_DB_PREFIX.'facture_fourn as f';
> $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'comfourn_facfourn as cf ON
> (f.rowid = cf.fk_facture)';
> $sql .= ' WHERE cf.fk_commande = '.$commande->id;
>
> dolibarr_syslog("fournisseur/commande/fiche.php: sql=".$sql);
>
> $resql = $db->query($sql);
> if ($resql)
> {
> $num = $db->num_rows($resql);
> if ($num)
> {
> $i = 0; $total = 0;
> if ($somethingshown) print '<br>';
> $somethingshown=1;
> print_titre($langs->trans('RelatedBills'));
> print '<table class="noborder">';
> print '<tr class="liste_titre">';
> print '<td width="150">'.$langs->trans('Ref').'</td>';
> print '<td>'.$langs->trans('RefSupplier').'</td>';
> print '<td align="center">'.$langs->trans('Date').'</td>';
> print '<td align="right">'.$langs->trans('AmountHT').'</td>';
> print '</tr>';
>
> $var=True;
> while ($i < $num)
> {
> $objp = $db->fetch_object($resql);
> $var=!$var;
> print '<tr '.$bc[$var].'>';
> print '<td><a
> href="../facture/fiche.php?facid='.$objp->id.'">'.img_object($langs->trans('SupplierOrder'),'company').'
> '.$objp->ref.'</a></td>';
> print '<td>'.$objp->ref_fourn.'</td>';
> print '<td
> align="center">'.dolibarr_print_date($objp->date,'day').'</td>';
> print '<td align="right">'.price($objp->total_ht).'</td>';
> print '</tr>';
> $total = $total + $objp->total_ht;
> $i++;
> }
> print '</table>';
> }
> }
>
Index: fourn/facture/fiche.php
===================================================================
RCS file: /cvsroot/dolibarr/dolibarr/htdocs/fourn/facture/fiche.php,v
retrieving revision 1.138
diff -r1.138 fiche.php
132a133,140
> // S'il y a une commande associe, on la fetch.
> $commande = "";
> if ($_POST["commande"])
> {
> $commande = New CommandeFournisseur($db);
> $commande->fetch($_POST["commande"]);
> }
>
142c150
<
---
> $facfou->commandeid = $commande->id;
148c156,170
< for ($i = 1 ; $i < 9 ; $i++)
---
> if ($commande)
> {
> for ($i = 0 ; $i < sizeof($commande->lignes) ; $i++)
> {
> $l = $commande->lignes[$i];
> $result = $facfou->addline(
> $l->desc,
>
> $commande->lignes[$i]->subprice,
>
> $commande->lignes[$i]->tva_tx,
> $commande->lignes[$i]->qty,
>
> $commande->lignes[$i]->fk_product,
>
> $commande->lignes[$i]->remise_percent);
> }
> }
> for ($i = 1 ; $i < 9 ; $i++)
325a348,354
>
> $commande = '';
> if ($_GET['commandeid'])
> {
> $commande = new CommandeFournisseur($db);
> $commande->fetch($_GET['commandeid']);
> }
363a393,396
> else if ($commande)
> {
> print '<tr><td>'.$langs->trans('Label').'</td><td><input size="30"
> name="libelle" value="Commande Ref '.$commande->ref.'" type="text"><input
> type="hidden" name="commande" value="'.$commande->id.'"></td></tr>';
> }
365,367c398,400
< {
< print '<tr><td>'.$langs->trans('Label').'</td><td><input
size="30" name="libelle" type="text"></td></tr>';
< }
---
> {
> print '<tr><td>'.$langs->trans('Label').'</td><td><input size="30"
> name="libelle" type="text"></td></tr>';
> }
390c423,424
< for ($i = 1 ; $i < 9 ; $i++)
---
> $length = max(9, sizeof($commande->lignes),
> sizeof($fac_ori->lignes));
> for ($i = 1 ; $i < $length ; $i++)
398a433,439
> else if ($commande)
> {
> $value_label = $commande->lignes[$i-1]->desc;
> $value_pu = $commande->lignes[$i-1]->total_ht;
> $value_tauxtva =
> $commande->lignes[$i-1]->tva_tx;
> $value_qty = $commande->lignes[$i-1]->qty;
> }
924a966,1024
>
> /*
> * Truc en bas.
> */
>
> print '<table width="100%"><tr><td width="50%" valign="top">';
>
> /*
> * Commande Ratache
> */
>
> $sql = 'SELECT '.$db->pdate('c.date_creation').' as cp,
> c.total_ht as total_ht, c.ref as ref, c.fk_soc as ref_fourn, c.rowid as id';
> $sql .= ' FROM '.MAIN_DB_PREFIX.'commande_fournisseur as c';
> $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'comfourn_facfourn as cf
> ON (c.rowid = cf.fk_commande)';
> $sql .= ' WHERE cf.fk_facture = '.$fac->id;
>
> dolibarr_syslog("fournisseur/facture/fiche.php: sql=".$sql);
>
> $resql = $db->query($sql);
> if ($resql)
> {
> $num = $db->num_rows($resql);
> if ($num)
> {
> $i = 0; $total = 0;
> if ($somethingshown) print '<br>';
> $somethingshown=1;
> print_titre($langs->trans('RelatedOrder'));
> print '<table class="noborder" width="100%">';
> print '<tr class="liste_titre">';
> print '<td width="150">'.$langs->trans('Ref').'</td>';
> print '<td>'.$langs->trans('RefSupplier').'</td>';
> print '<td
> align="center">'.$langs->trans('Date').'</td>';
> print '<td
> align="right">'.$langs->trans('AmountHT').'</td>';
> print '</tr>';
>
> $var=True;
> while ($i < $num)
> {
> $objp = $db->fetch_object($resql);
> $var=!$var;
> print '<tr '.$bc[$var].'>';
> print '<td><a
> href="../commande/fiche.php?id='.$objp->id.'">'.img_object($langs->trans('SupplierOrder'),'company').'
> '.$objp->ref.'</a></td>';
> print '<td>'.$objp->ref_fourn.'</td>';
> print '<td
> align="center">'.dolibarr_print_date($objp->dp,'day').'</td>';
> print '<td
> align="right">'.price($objp->total_ht).'</td>';
> print '</tr>';
> $total = $total + $objp->total_ht;
> $i++;
> }
> print '</table>';
> }
> }
>
> /*
> * Fin truc en bas.
> */
>
> print '</td><td></td></tr></table>';
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Dolibarr-dev] Patch pour creer une facture a partir d'une commande fournisseur,
Sébastien Wacquiez <=