diff --git a/htdocs/compta/tva/quadri_detail.php b/htdocs/compta/tva/quadri_detail.php index dc6c12e29dc..d2b05c777d8 100644 --- a/htdocs/compta/tva/quadri_detail.php +++ b/htdocs/compta/tva/quadri_detail.php @@ -1,7 +1,7 @@ * Copyright (C) 2004 Éric Seigne - * Copyright (C) 2004-2008 Laurent Destailleur + * Copyright (C) 2004-2009 Laurent Destailleur * Copyright (C) 2006-2007 Yannick Warnier * * This program is free software; you can redistribute it and/or modify @@ -181,6 +181,7 @@ else { $invoice_customer->id=$x_coll[$my_coll_rate]['facid'][$id]; $invoice_customer->ref=$x_coll[$my_coll_rate]['facnum'][$id]; + $invoice_customer->type=$x_coll[$my_coll_rate]['type'][$id]; $x_both[$my_coll_rate]['coll']['detail'][] = array( 'id' =>$x_coll[$my_coll_rate]['facid'][$id], 'descr' =>$x_coll[$my_coll_rate]['descr'][$id], @@ -194,7 +195,7 @@ else 'dtype' =>$x_coll[$my_coll_rate]['dtype'][$id], 'totalht' =>$x_coll[$my_coll_rate]['totalht_list'][$id], 'vat' =>$x_coll[$my_coll_rate]['vat_list'][$id], - 'link' =>$invoice_customer->getNomUrl(1)); + 'link' =>$invoice_customer->getNomUrl(1,'',12)); //$x_both[$my_coll_rate]['coll']['links'] .= '..'.substr($x_coll[$my_coll_rate]['facnum'][$id],-2).' '; } } @@ -213,6 +214,7 @@ else { $invoice_supplier->id=$x_paye[$my_paye_rate]['facid'][$id]; $invoice_supplier->ref=$x_paye[$my_paye_rate]['facnum'][$id]; + $invoice_supplier->type=$x_paye[$my_paye_rate]['type'][$id]; $x_both[$my_paye_rate]['paye']['detail'][] = array( 'id' =>$x_paye[$my_paye_rate]['facid'][$id], 'descr' =>$x_paye[$my_paye_rate]['descr'][$id], @@ -226,7 +228,7 @@ else 'dtype' =>$x_paye[$my_paye_rate]['dtype'][$id], 'totalht' =>$x_paye[$my_paye_rate]['totalht_list'][$id], 'vat' =>$x_paye[$my_paye_rate]['vat_list'][$id], - 'link' =>$invoice_supplier->getNomUrl(1)); + 'link' =>$invoice_supplier->getNomUrl(1,'',12)); //$x_both[$my_paye_rate]['paye']['links'] .= '..'.substr($x_paye[$my_paye_rate]['facnum'][$id],-2).' '; } } @@ -245,6 +247,7 @@ else //print ''..')'; + // Customers invoices print ''; print ''.$elementcust.''; print ''.$productcust.''; @@ -256,6 +259,7 @@ else print ''.$langs->trans("AmountHTVATRealReceived").''; print ''.$vatcust.''; print ''; + foreach(array_keys($x_coll) as $rate) { $subtot_coll_total_ht = 0; @@ -263,16 +267,20 @@ else if (is_array($x_both[$rate]['coll']['detail'])) { + // VAT Rate $var=true; print ""; print ''.$langs->trans("Rate").': '.vatrate($rate).'%'; print ''."\n"; + foreach($x_both[$rate]['coll']['detail'] as $index => $fields) { $var=!$var; print ''; + // Ref print ''.$fields['link'].''; + //Description print ''; if ($fields['pid']) @@ -289,8 +297,10 @@ else else $text = img_object($langs->trans('Product'),'product'); print $text.' '; } - print dol_trunc($fields['descr'],16).''; - // Amount line + print dol_trunc(dol_string_nohtmltag($fields['descr']),16); + print ''; + + // Total HT if ($modetax == 0) { print ''; @@ -303,26 +313,35 @@ else } print ''; } + // Payment $ratiopaymentinvoice=1; if ($modetax == 0) { if ($fields['payment_amount'] && $fields['ftotal_ttc']) $ratiopaymentinvoice=($fields['payment_amount']/$fields['ftotal_ttc']); print ''; + //print $fields['totalht']."-".$fields['payment_amount']."-".$fields['ftotal_ttc']; if ($fields['payment_amount'] && $fields['ftotal_ttc']) { $payment_static->rowid=$fields['payment_id']; print $payment_static->getNomUrl(2); } - print $fields['payment_amount']; + if ($fields['ptype'] == 0) + { + print $langs->trans("NotUsedForGoods"); + } + else print $fields['payment_amount']; if ($fields['payment_amount'] && $ratiopaymentinvoice) print ' ('.round($ratiopaymentinvoice*100,2).'%)'; print ''; } + + // Total collected print ''; $temp_ht=$fields['totalht']; if ($ratiopaymentinvoice) $temp_ht=$fields['totalht']*$ratiopaymentinvoice; print price(price2num($temp_ht,'MT')); print ''; + // VAT print ''; $temp_vat=$fields['vat']*$ratiopaymentinvoice; @@ -365,6 +384,7 @@ else print ''.$langs->trans("AmountHTVATRealPayed").''; print ''.$vatsup.''; print ''."\n"; + foreach(array_keys($x_paye) as $rate) { $subtot_paye_total_ht = 0; @@ -380,7 +400,11 @@ else { $var=!$var; print ''; + + // Ref print ''.$fields['link'].''; + + //Description print ''; if ($fields['pid']) { @@ -397,7 +421,8 @@ else print $text.' '; } print dol_trunc($fields['descr'],24).''; - // Amount line + + // Total HT if ($modetax == 0) { print ''; @@ -410,6 +435,7 @@ else } print ''; } + // Payment $ratiopaymentinvoice=1; if ($modetax == 0) @@ -421,15 +447,22 @@ else $paymentfourn_static->rowid=$fields['payment_id']; print $paymentfourn_static->getNomUrl(2); } - print $fields['payment_amount']; + if ($fields['ptype'] == 0) + { + print $langs->trans("NotUsedForGoods"); + } + else print $fields['payment_amount']; if ($fields['payment_amount'] && $ratiopaymentinvoice) print ' ('.round($ratiopaymentinvoice*100,2).'%)'; print ''; } + + // VAT payed print ''; $temp_ht=$fields['totalht']; if ($ratiopaymentinvoice) $temp_ht=$fields['totalht']*$ratiopaymentinvoice; print price(price2num($temp_ht,'MT')); print ''; + // VAT print ''; $temp_vat=$fields['vat']*$ratiopaymentinvoice; @@ -460,7 +493,7 @@ else print ' '; print ''; - print ''.$langs->trans("TotalToPay").', '.$langs->trans("Quadri").' '.$q.':'; + print ''.$langs->trans("TotalToPay").', '.$langs->trans("Quadri").' '.$q.':'; print ''."\n"; $diff = $x_coll_sum - $x_paye_sum; diff --git a/htdocs/facture.class.php b/htdocs/facture.class.php index b7cb20bffeb..566442f9f61 100644 --- a/htdocs/facture.class.php +++ b/htdocs/facture.class.php @@ -451,9 +451,10 @@ class Facture extends CommonObject * \brief Renvoie nom clicable (avec eventuellement le picto) * \param withpicto 0=Pas de picto, 1=Inclut le picto dans le lien, 2=Picto seul * \param option Sur quoi pointe le lien ('', 'withdraw') + * \param max Max length of shown ref * \return string Chaine avec URL */ - function getNomUrl($withpicto=0,$option='') + function getNomUrl($withpicto=0,$option='',$max=0) { global $langs; @@ -482,7 +483,7 @@ class Facture extends CommonObject if ($withpicto) $result.=($lien.img_object($label,$picto).$lienfin); if ($withpicto && $withpicto != 2) $result.=' '; - if ($withpicto != 2) $result.=$lien.$this->ref.$lienfin; + if ($withpicto != 2) $result.=$lien.($max?dol_trunc($this->ref,$max):$this->ref).$lienfin; return $result; } diff --git a/htdocs/fourn/fournisseur.facture.class.php b/htdocs/fourn/fournisseur.facture.class.php index d66361e682a..28bdb9ce4da 100644 --- a/htdocs/fourn/fournisseur.facture.class.php +++ b/htdocs/fourn/fournisseur.facture.class.php @@ -705,9 +705,10 @@ class FactureFournisseur extends Facture * \brief Renvoie nom clicable (avec eventuellement le picto) * \param withpicto 0=Pas de picto, 1=Inclut le picto dans le lien, 2=Picto seul * \param option Sur quoi pointe le lien - * \return string Chaine avec URL + * \param max Max length of shown ref + * \return string Chaine avec URL */ - function getNomUrl($withpicto=0,$option='') + function getNomUrl($withpicto=0,$option='',$max=0) { global $langs; @@ -716,8 +717,10 @@ class FactureFournisseur extends Facture $lien = ''; $lienfin=''; - if ($withpicto) $result.=($lien.img_object($langs->trans("ShowInvoice"),'bill').$lienfin.' '); - $result.=$lien.$this->ref.$lienfin; + $label=$langs->trans("ShowInvoice").': '.$this->ref; + + if ($withpicto) $result.=($lien.img_object($label,'bill').$lienfin.' '); + $result.=$lien.($max?dol_trunc($this->ref,$max):$this->ref).$lienfin; return $result; } diff --git a/htdocs/langs/en_US/compta.lang b/htdocs/langs/en_US/compta.lang index 77f28d0db6b..d4acd1da813 100644 --- a/htdocs/langs/en_US/compta.lang +++ b/htdocs/langs/en_US/compta.lang @@ -109,6 +109,7 @@ RulesVATIn=For services, the report includes the VAT regulations actually receiv RulesVATDue=For services, the report includes VAT invoices due, paid or not, based on the date of validation of these bills.
- For material assets, it includes the VAT invoices, based on the date of validation of the invoice. OptionVatInfoModuleComptabilite=Note: For material assets, it should use the date of delivery to be more fair. PercentOfInvoice=%%/invoice +NotUsedForGoods=Not used on goods Dispatch=Dispatching Dispatched=Dispatched ToDispatch=To dispatch \ No newline at end of file diff --git a/htdocs/langs/fr_FR/compta.lang b/htdocs/langs/fr_FR/compta.lang index 7d0b066084e..6379b37d0ba 100644 --- a/htdocs/langs/fr_FR/compta.lang +++ b/htdocs/langs/fr_FR/compta.lang @@ -109,6 +109,7 @@ RulesVATIn=- Pour les services, le rapport inclut les TVA des réglements effect RulesVATDue=- Pour les services, le rapport inclut les TVA des factures dues, payées ou non en se basant sur la date de validation de ces factures.
- Pour les biens matériels, il inclut les TVA des factures en se basant sur la date de validation de la facture. OptionVatInfoModuleComptabilite=Remarque : Pour les biens matériels, il faudrait utiliser la date de livraison pour être plus juste. PercentOfInvoice=%%/facture +NotUsedForGoods=Non utilisé pour les biens OrderStats=Statistiques sur les commandes Dispatch=Ventilation Dispatched=Ventilés diff --git a/htdocs/langs/fr_FR/users.lang b/htdocs/langs/fr_FR/users.lang index d85e8d2abba..e125b970678 100755 --- a/htdocs/langs/fr_FR/users.lang +++ b/htdocs/langs/fr_FR/users.lang @@ -44,7 +44,7 @@ NameNotDefined=Le nom n'est pas défini. ListOfUsers=Liste des utilisateurs Administrator=Administrateur DefaultRights=Permissions par défaut -DefaultRightsDesc=Définissez ici les permissions par défaut, c'est-à-dire les permissions qui seront attribuées automatiquement à un nouvel utilisateur lors de sa création. +DefaultRightsDesc=Définissez ici les permissions par défaut, c'est-à-dire les permissions qui seront attribuées automatiquement à un nouvel utilisateur lors de sa création. DolibarrUsers=Utilisateurs Dolibarr LastName=Nom FirstName=Prénom diff --git a/htdocs/lib/tax.lib.php b/htdocs/lib/tax.lib.php index a69e6d40df0..b6ec98a415a 100644 --- a/htdocs/lib/tax.lib.php +++ b/htdocs/lib/tax.lib.php @@ -41,14 +41,14 @@ function vat_by_thirdparty($db, $y, $modetax, $direction) //print "xx".$conf->global->MAIN_MODULE_COMPTABILITEEXPERT; //print "xx".$conf->global->MAIN_MODULE_COMPTABILITE; - if ($direction == 'sell') + if ($direction == 'sell') { $invoicetable='facture'; $invoicedettable='facturedet'; $fk_facture='fk_facture'; $total_tva='total_tva'; } - if ($direction == 'buy') + if ($direction == 'buy') { $invoicetable='facture_fourn'; $invoicedettable='facture_fourn_det'; @@ -154,7 +154,7 @@ function vat_by_quarter($db, $y, $q, $modetax, $direction) $list=array(); - if ($direction == 'sell') + if ($direction == 'sell') { $invoicetable='facture'; $invoicedettable='facturedet'; @@ -165,7 +165,7 @@ function vat_by_quarter($db, $y, $q, $modetax, $direction) $paymenttable='paiement'; $paymentfacturetable='paiement_facture'; } - if ($direction == 'buy') + if ($direction == 'buy') { $invoicetable='facture_fourn'; $invoicedettable='facture_fourn_det'; @@ -176,12 +176,12 @@ function vat_by_quarter($db, $y, $q, $modetax, $direction) $paymenttable='paiementfourn'; $paymentfacturetable='paiementfourn_facturefourn'; } - + // CAS DES BIENS - + // Define sql request $sql=''; - if ($modetax == 1) + if ($modetax == 1) // Option vat on debit { // If vat payed on due invoices (non draft) if ($conf->global->MAIN_MODULE_COMPTABILITEEXPERT) @@ -196,9 +196,10 @@ function vat_by_quarter($db, $y, $q, $modetax, $direction) if ($conf->global->MAIN_MODULE_COMPTABILITE) { $sql = "SELECT d.rowid, d.product_type as dtype, d.".$fk_facture." as facid, d.tva_taux as rate, d.total_ht as total_ht, d.total_ttc as total_ttc, d.".$total_tva." as total_vat, d.description as descr,"; - $sql.= " f.facnumber as facnum, f.total_ttc as ftotal_ttc,"; - $sql.= " p.rowid as pid, p.ref as pref, p.fk_product_type as ptype"; - $sql.= " FROM ".MAIN_DB_PREFIX.$invoicetable." as f,"; + $sql.= " f.facnumber as facnum, f.type, f.total_ttc as ftotal_ttc,"; + $sql.= " p.rowid as pid, p.ref as pref, p.fk_product_type as ptype,"; + $sql.= " 0 as payment_id, 0 as payment_amount"; + $sql.= " FROM ".MAIN_DB_PREFIX.$invoicetable." as f,"; $sql.= " ".MAIN_DB_PREFIX.$invoicedettable." as d" ; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p on d.fk_product = p.rowid"; $sql.= " WHERE "; @@ -210,7 +211,7 @@ function vat_by_quarter($db, $y, $q, $modetax, $direction) $sql.= " ORDER BY d.rowid, d.".$fk_facture; } } - else + else // Option vat on payments { // If vat payed on payments if ($conf->global->MAIN_MODULE_COMPTABILITEEXPERT) @@ -224,16 +225,24 @@ function vat_by_quarter($db, $y, $q, $modetax, $direction) } if ($conf->global->MAIN_MODULE_COMPTABILITE) { - // Tva sur factures payés (should be on payment) + // Tva sur factures payés (should be on shipment, done on payment instead !) $sql = "SELECT d.rowid, d.product_type as dtype, d.".$fk_facture." as facid, d.tva_taux as rate, d.total_ht as total_ht, d.total_ttc as total_ttc, d.".$total_tva." as total_vat, d.description as descr,"; - $sql.= " f.facnumber as facnum, f.total_ttc as ftotal_ttc,"; - $sql.= " p.rowid as pid, p.ref as pref, p.fk_product_type as ptype"; + $sql.= " f.facnumber as facnum, f.type, f.total_ttc as ftotal_ttc,"; + $sql.= " p.rowid as pid, p.ref as pref, p.fk_product_type as ptype,"; + $sql.= " 0 as payment_id, 0 as payment_amount"; +// $sql.= " pf.".$fk_payment." as payment_id, pf.amount as payment_amount"; $sql.= " FROM ".MAIN_DB_PREFIX.$invoicetable." as f,"; +// $sql.= " ".MAIN_DB_PREFIX.$paymentfacturetable." as pf,"; +// $sql.= " ".MAIN_DB_PREFIX.$paymenttable." as pa,"; $sql.= " ".MAIN_DB_PREFIX.$invoicedettable." as d" ; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p on d.fk_product = p.rowid"; $sql.= " WHERE "; $sql.= " f.fk_statut in (1,2)"; // Validated or payed (partially or completely) $sql.= " AND f.rowid = d.".$fk_facture; +// $sql.= " AND pf.".$fk_facture2." = f.rowid"; +// $sql.= " AND pa.rowid = pf.".$fk_payment; +// $sql.= " AND pa.datep >= '".$y."0101000000' AND pa.datep <= '".$y."1231235959'"; +// $sql.= " AND (date_format(pa.datep,'%m') > ".(($q-1)*3)." AND date_format(pa.datep,'%m') <= ".($q*3).")"; $sql.= " AND f.datef >= '".$y."0101000000' AND f.datef <= '".$y."1231235959'"; $sql.= " AND (date_format(f.datef,'%m') > ".(($q-1)*3)." AND date_format(f.datef,'%m') <= ".($q*3).")"; $sql.= " AND d.product_type = 0"; // Limit to products @@ -267,6 +276,7 @@ function vat_by_quarter($db, $y, $q, $modetax, $direction) $list[$assoc['rate']]['facid'][] = $assoc['facid']; $list[$assoc['rate']]['facnum'][] = $assoc['facnum']; + $list[$assoc['rate']]['type'][] = $assoc['type']; $list[$assoc['rate']]['ftotal_ttc'][] = $assoc['ftotal_ttc']; $list[$assoc['rate']]['descr'][] = $assoc['descr']; @@ -279,7 +289,7 @@ function vat_by_quarter($db, $y, $q, $modetax, $direction) $list[$assoc['rate']]['payment_id'][] = $assoc['payment_id']; $list[$assoc['rate']]['payment_amount'][] = $assoc['payment_amount']; - + $rate = $assoc['rate']; } } @@ -292,7 +302,7 @@ function vat_by_quarter($db, $y, $q, $modetax, $direction) // CAS DES SERVICES - + // Define sql request $sql=''; if ($modetax == 1) // Option vat on debit @@ -310,8 +320,9 @@ function vat_by_quarter($db, $y, $q, $modetax, $direction) if ($conf->global->MAIN_MODULE_COMPTABILITE) { $sql = "SELECT d.rowid, d.product_type as dtype, d.".$fk_facture." as facid, d.tva_taux as rate, d.total_ht as total_ht, d.total_ttc as total_ttc, d.".$total_tva." as total_vat, d.description as descr,"; - $sql.= " f.facnumber as facnum, f.total_ttc as ftotal_ttc,"; - $sql.= " p.rowid as pid, p.ref as pref, p.fk_product_type as ptype"; + $sql.= " f.facnumber as facnum, f.type, f.total_ttc as ftotal_ttc,"; + $sql.= " p.rowid as pid, p.ref as pref, p.fk_product_type as ptype,"; + $sql.= " 0 as payment_id, 0 as payment_amount"; $sql.= " FROM ".MAIN_DB_PREFIX.$invoicetable." as f,"; $sql.= " ".MAIN_DB_PREFIX.$invoicedettable." as d" ; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p on d.fk_product = p.rowid"; @@ -324,7 +335,7 @@ function vat_by_quarter($db, $y, $q, $modetax, $direction) $sql.= " ORDER BY d.rowid, d.".$fk_facture; } } - else + else // Option vat on payments { // If vat payed on payments if ($conf->global->MAIN_MODULE_COMPTABILITEEXPERT) @@ -332,7 +343,7 @@ function vat_by_quarter($db, $y, $q, $modetax, $direction) // \todo a ce jour on se sait pas la compter car le montant tva d'un payment // n'est pas stocké dans la table des payments. // Seul le module compta expert peut résoudre ce problème. - // (Il faut quand un payment a lieu, stocker en plus du montant du paiement le + // (Il faut quand un paiement a lieu, stocker en plus du montant du paiement le // detail part tva et part ht). $sql='TODO'; } @@ -340,7 +351,7 @@ function vat_by_quarter($db, $y, $q, $modetax, $direction) { // Tva sur factures payés (should be on payment) $sql = "SELECT d.rowid, d.product_type as dtype, d.".$fk_facture." as facid, d.tva_taux as rate, d.total_ht as total_ht, d.total_ttc as total_ttc, d.".$total_tva." as total_vat, d.description as descr,"; - $sql.= " f.facnumber as facnum, f.total_ttc as ftotal_ttc,"; + $sql.= " f.facnumber as facnum, f.type, f.total_ttc as ftotal_ttc,"; $sql.= " p.rowid as pid, p.ref as pref, p.fk_product_type as ptype,"; $sql.= " pf.".$fk_payment." as payment_id, pf.amount as payment_amount"; $sql.= " FROM ".MAIN_DB_PREFIX.$invoicetable." as f,"; @@ -383,9 +394,10 @@ function vat_by_quarter($db, $y, $q, $modetax, $direction) } $list[$assoc['rate']]['dtotal_ttc'][] = $assoc['total_ttc']; $list[$assoc['rate']]['dtype'][] = $assoc['dtype']; - + $list[$assoc['rate']]['facid'][] = $assoc['facid']; $list[$assoc['rate']]['facnum'][] = $assoc['facnum']; + $list[$assoc['rate']]['type'][] = $assoc['type']; $list[$assoc['rate']]['ftotal_ttc'][] = $assoc['ftotal_ttc']; $list[$assoc['rate']]['descr'][] = $assoc['descr']; @@ -408,7 +420,7 @@ function vat_by_quarter($db, $y, $q, $modetax, $direction) return -3; } } - + return $list; }