From c7569e6316fd6a6e36ac2245375495206b3cc250 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 16 Nov 2008 22:26:47 +0000 Subject: [PATCH] New: Added a link to vat payment on bank transaction view for vat payment. --- htdocs/compta/bank/account.class.php | 16 ++--- htdocs/compta/bank/account.php | 36 ++++++----- htdocs/compta/bank/ligne.php | 11 +++- htdocs/compta/bank/rappro.php | 2 +- htdocs/compta/facture/impayees.php | 4 +- htdocs/compta/paiement/fiche.php | 2 +- htdocs/compta/paiement/info.php | 2 +- htdocs/compta/paiement/liste.php | 13 ++-- htdocs/compta/tva/fiche.php | 66 ++++++++++---------- htdocs/compta/tva/tva.class.php | 20 +++--- htdocs/fourn/facture/paiementfourn.class.php | 4 +- htdocs/langs/en_US/compta.lang | 5 ++ htdocs/langs/fr_FR/compta.lang | 5 ++ htdocs/paiement.class.php | 4 +- 14 files changed, 105 insertions(+), 85 deletions(-) diff --git a/htdocs/compta/bank/account.class.php b/htdocs/compta/bank/account.class.php index f63fe917dcf..59bf7074a0a 100644 --- a/htdocs/compta/bank/account.class.php +++ b/htdocs/compta/bank/account.class.php @@ -43,7 +43,7 @@ class Account extends CommonObject var $rowid; var $ref; var $label; - var $type; + var $type; // 'payment', 'company', 'member', 'banktransfert', 'payment_supplier', 'sc', 'payment_vat', ... var $bank; var $clos; var $rappro; @@ -97,13 +97,13 @@ class Account extends CommonObject /** - * \brief Ajoute lien entre ecriture bancaire et sources - * \param line_id Id ecriture bancaire - * \param url_id Id parametre url - * \param url Url - * \param label Libell� du lien - * \param type Type de lien (payment, company, member, ...) - * \return int <0 si ko, id line si ok + * Add a link between bank line record and its source + * @param line_id Id ecriture bancaire + * @param url_id Id parametre url + * @param url Url + * @param label Link label + * @param type Type of link ('payment', 'company', 'member', ...) + * @return int <0 if KO, id line if OK */ function add_url_line($line_id, $url_id, $url, $label, $type) { diff --git a/htdocs/compta/bank/account.php b/htdocs/compta/bank/account.php index 70438d9a44e..065cadbc8e6 100644 --- a/htdocs/compta/bank/account.php +++ b/htdocs/compta/bank/account.php @@ -21,11 +21,11 @@ */ /** - \file htdocs/compta/bank/account.php - \ingroup banque - \brief Page de détail des transactions bancaires - \version $Id$ -*/ + * \file htdocs/compta/bank/account.php + * \ingroup banque + * \brief Page de détail des transactions bancaires + * \version $Id$ + */ require("./pre.inc.php"); require_once(DOL_DOCUMENT_ROOT."/lib/bank.lib.php"); @@ -33,6 +33,7 @@ require_once(DOL_DOCUMENT_ROOT."/societe.class.php"); require_once(DOL_DOCUMENT_ROOT."/adherents/adherent.class.php"); require_once(DOL_DOCUMENT_ROOT."/chargesociales.class.php"); require_once(DOL_DOCUMENT_ROOT."/paiement.class.php"); +require_once(DOL_DOCUMENT_ROOT."/compta/tva/tva.class.php"); require_once(DOL_DOCUMENT_ROOT."/fourn/facture/paiementfourn.class.php"); // Security check @@ -121,6 +122,7 @@ $chargestatic=new ChargeSociales($db); $memberstatic=new Adherent($db); $paymentstatic=new Paiement($db); $paymentsupplierstatic=new PaiementFourn($db); +$paymentvatstatic=new TVA($db); $html = new Form($db); @@ -427,9 +429,8 @@ if ($account || $_GET["ref"]) } if ($mode_search && $conf->tax->enabled) { - // \TODO Mettre jointure sur charges sociales pour recherche sur une charge - //$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_url as bu ON bu.fk_bank = b.rowid AND bu.type='company'"; - //$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON bu.url_id = s.rowid"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_url as bu ON bu.fk_bank = b.rowid AND bu.type='payment_vat'"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."tva as t ON bu.url_id = t.rowid"; } $sql.= " WHERE fk_account=".$acct->id; $sql.= $sql_rech; @@ -503,18 +504,19 @@ if ($account || $_GET["ref"]) foreach($links as $key=>$val) { if ($links[$key]['type']=='payment') { - $paymentstatic->rowid=$links[$key]['url_id']; + $paymentstatic->id=$links[$key]['url_id']; print ' '.$paymentstatic->getNomUrl(2); } else if ($links[$key]['type']=='payment_supplier') { - - $paymentsupplierstatic->rowid=$links[$key]['url_id']; - print ' '.$paymentsupplierstatic->getNomUrl(2); + $paymentsupplierstatic->id=$links[$key]['url_id']; + $paymentsupplierstatic->ref=$links[$key]['url_id']; + print ' '.$paymentsupplierstatic->getNomUrl(2); } else if ($links[$key]['type']=='company') { } else if ($links[$key]['type']=='sc') { // This is waiting for card to link to payment_sc $chargestatic->id=$links[$key]['url_id']; + $chargestatic->ref=$links[$key]['url_id']; print ' '.$chargestatic->getNomUrl(2); } else if ($links[$key]['type']=='payment_sc') @@ -527,6 +529,12 @@ if ($account || $_GET["ref"]) print ''; */ } + else if ($links[$key]['type']=='payment_vat') + { + $paymentvatstatic->id=$links[$key]['url_id']; + $paymentvatstatic->ref=$links[$key]['url_id']; + print ' '.$paymentvatstatic->getNomUrl(2); + } else if ($links[$key]['type']=='banktransfert') { /* Do not show this link (avoid confusion). Can already be accessed from transaction detail */ } @@ -551,9 +559,7 @@ if ($account || $_GET["ref"]) print ''; - /* - * Ajout les liens tiers - */ + // Add third party column print ''; foreach($links as $key=>$val) { diff --git a/htdocs/compta/bank/ligne.php b/htdocs/compta/bank/ligne.php index c032fd74282..48a8beeebce 100644 --- a/htdocs/compta/bank/ligne.php +++ b/htdocs/compta/bank/ligne.php @@ -32,6 +32,7 @@ if (! $user->rights->banque->lire && ! $user->rights->banque->consolidate) accessforbidden(); $langs->load("banks"); +$langs->load("compta"); $langs->load("bills"); $langs->load("categories"); if ($conf->adherent->enabled) $langs->load("members"); @@ -311,7 +312,7 @@ if ($result) print ''; if (eregi('^\((.*)\)$',$objp->label,$reg)) { - // Label g�n�rique car entre parenth�ses. On l'affiche en le traduisant + // Label generique car entre parentheses. On l'affiche en le traduisant print $langs->trans($reg[1]); } else @@ -375,6 +376,12 @@ if ($result) print $langs->trans("SocialContributionPayment"); print ''; } + else if ($links[$key]['type']=='payment_vat') { + print ''; + print img_object($langs->trans('ShowVAT'),'payment').' '; + print $langs->trans("VATPayment"); + print ''; + } else if ($links[$key]['type']=='member') { print ''; print img_object($langs->trans('ShowMember'),'user').' '; diff --git a/htdocs/compta/bank/rappro.php b/htdocs/compta/bank/rappro.php index 578eb427b9d..a485f19038f 100644 --- a/htdocs/compta/bank/rappro.php +++ b/htdocs/compta/bank/rappro.php @@ -223,7 +223,7 @@ if ($resql) // Date value if (! $objp->rappro && ($user->rights->banque->modifier || $user->rights->banque->consolidate)) { - print ''; + print ''; print dolibarr_print_date($objp->dv,"day"); print '   '; print ''; diff --git a/htdocs/compta/facture/impayees.php b/htdocs/compta/facture/impayees.php index 6f52987b7dd..972fd4d034b 100644 --- a/htdocs/compta/facture/impayees.php +++ b/htdocs/compta/facture/impayees.php @@ -92,8 +92,8 @@ if ($_POST["action"] == "builddoc" && $user->rights->facture->lire) create_exdir($diroutputpdf); // enregistre le fichier pdf concatene - $filename=sanitizeFileName(strtolower($langs->transnoentities("Unpayed"))); - if ($option=='late') $filename.='_'.sanitizeFileName(strtolower($langs->transnoentities("Late"))); + $filename=strtolower(sanitizeFileName($langs->transnoentities("Unpayed"))); + if ($option=='late') $filename.='_'.strtolower(sanitizeFileName($langs->transnoentities("Late"))); if ($pagecount) { $file=$diroutputpdf.'/'.$filename.'_'.dolibarr_print_date(mktime(),'dayhourlog').'.pdf'; diff --git a/htdocs/compta/paiement/fiche.php b/htdocs/compta/paiement/fiche.php index 3eba329de7a..e668e259fcb 100644 --- a/htdocs/compta/paiement/fiche.php +++ b/htdocs/compta/paiement/fiche.php @@ -128,7 +128,7 @@ $head[$h][1] = $langs->trans("Info"); $h++; -dolibarr_fiche_head($head, $hselected, $langs->trans("Payment")); +dolibarr_fiche_head($head, $hselected, $langs->trans("PaymentCustomerInvoice")); /* * Confirmation de la suppression du paiement diff --git a/htdocs/compta/paiement/info.php b/htdocs/compta/paiement/info.php index b659a2aa759..32b3ab9d559 100644 --- a/htdocs/compta/paiement/info.php +++ b/htdocs/compta/paiement/info.php @@ -55,7 +55,7 @@ $hselected = $h; $h++; -dolibarr_fiche_head($head, $hselected, $langs->trans("Payment")); +dolibarr_fiche_head($head, $hselected, $langs->trans("PaymentCustomerInvoice")); print ''; diff --git a/htdocs/compta/paiement/liste.php b/htdocs/compta/paiement/liste.php index 08a9b625d7e..6c59afb2501 100644 --- a/htdocs/compta/paiement/liste.php +++ b/htdocs/compta/paiement/liste.php @@ -18,11 +18,11 @@ */ /** - \file htdocs/compta/paiement/liste.php - \ingroup compta - \brief Page liste des paiements des factures clients - \version $Id$ -*/ + * \file htdocs/compta/paiement/liste.php + * \ingroup compta + * \brief Page liste des paiements des factures clients + * \version $Id$ + */ require("./pre.inc.php"); require_once(DOL_DOCUMENT_ROOT.'/paiement.class.php'); @@ -154,7 +154,8 @@ if ($resql) print ""; print ''; diff --git a/htdocs/compta/tva/fiche.php b/htdocs/compta/tva/fiche.php index 706e8984360..e60c8859d2a 100644 --- a/htdocs/compta/tva/fiche.php +++ b/htdocs/compta/tva/fiche.php @@ -18,11 +18,11 @@ */ /** - \file htdocs/compta/tva/fiche.php - \ingroup tax - \brief Page des règlements de TVA - \version $Id$ -*/ + * \file htdocs/compta/tva/fiche.php + * \ingroup tax + * \brief Page des règlements de TVA + * \version $Id$ + */ require("./pre.inc.php"); require_once(DOL_DOCUMENT_ROOT."/compta/tva/tva.class.php"); @@ -50,10 +50,13 @@ if ($_POST["action"] == 'add' && $_POST["cancel"] <> $langs->trans("Cancel")) $db->begin(); + $datev=dolibarr_mktime(12,0,0, $_POST["datevmonth"], $_POST["datevday"], $_POST["datevyear"]); + $datep=dolibarr_mktime(12,0,0, $_POST["datepmonth"], $_POST["datepday"], $_POST["datepyear"]); + $tva->accountid=$_POST["accountid"]; $tva->paymenttype=$_POST["paiementtype"]; - $tva->datev=dolibarr_mktime(12,0,0, $_POST["datevmonth"], $_POST["datevday"], $_POST["datevyear"]); - $tva->datep=dolibarr_mktime(12,0,0, $_POST["datepmonth"], $_POST["datepday"], $_POST["datepyear"]); + $tva->datev=$datev; + $tva->datep=$datep; $tva->amount=$_POST["amount"]; $tva->label=$_POST["label"]; @@ -150,27 +153,27 @@ if ($_GET["action"] == 'create') print ""; print ''; print ''; // Label - print ''; + print ''; // Amount - print ''; + print ''; if ($conf->banque->enabled) { print ''; print '\n"; } @@ -216,29 +219,24 @@ if ($id) print dolibarr_print_date($vatpayment->datev,'day'); print ''; - if ($conf->banque->enabled) - { - print ''; - if ($vatpayment->fk_account > 0) - { - $account=new Account($db); - $result=$account->fetch($vatpayment->fk_account); - print ''; - print ''; - } - else - { - print ''; - } - print ''; - - print '\n"; - } - print ''; + if ($conf->banque->enabled) + { + if ($vatpayment->fk_account > 0) + { + $bankline=new AccountLine($db); + $bankline->fetch($vatpayment->fk_bank); + + print ''; + print ''; + print ''; + print ''; + } + } + print '
'; - $paymentstatic->rowid=$objp->rowid; + $paymentstatic->id=$objp->rowid; + $paymentstatic->ref=$objp->rowid; print $paymentstatic->getNomUrl(1); print '
'.$langs->trans("DatePayment").''; - print $html->select_date("","datev",'','','','add'); + print $html->select_date($datep,"datep",'','','','add'); print '
'.$langs->trans("DateValue").''; - print $html->select_date("","datep",'','','','add'); + print $html->select_date($datev,"datev",'','','','add'); print '
'.$langs->trans("Label").'
'.$langs->trans("Label").'trans("VATPayment")).'">
'.$langs->trans("Amount").'
'.$langs->trans("Amount").'
'.$langs->trans("Account").''; - $html->select_comptes($vatpayment->fk_account,"accountid",0,"courant=1",1); // Affiche liste des comptes courant + $html->select_comptes($_POST["accountid"],"accountid",0,"courant=1",1); // Affiche liste des comptes courant print '
'.$langs->trans("PaymentMode").''; - $html->select_types_paiements($vatpayment->fk_type, "paiementtype"); + $html->select_types_paiements($_POST["paiementtype"], "paiementtype"); print "
'.$langs->trans("Account").''.$account->getNomUrl(1).''.$langs->trans("BankLineConciliated").''.yn($vatpayment->rappro).' 
'.$langs->trans("PaymentMode").''; - print $vatpayment->fk_type ? $langs->trans("PaymentTypeShort".$vatpayment->fk_type) : ' '; - print "
'.$langs->trans("Amount").''.price($vatpayment->amount).'
'.$langs->trans('BankTransactionLine').''; + print $bankline->getNomUrl(1,0,'showall'); + print '
'; print ''; diff --git a/htdocs/compta/tva/tva.class.php b/htdocs/compta/tva/tva.class.php index 38ce1b4d6f0..f491de56efd 100644 --- a/htdocs/compta/tva/tva.class.php +++ b/htdocs/compta/tva/tva.class.php @@ -42,6 +42,7 @@ class Tva extends CommonObject //var $table_element='tva'; //!< Name of table without prefix where object is stored var $id; + var $ref; var $tms; var $datep; @@ -461,7 +462,7 @@ class Tva extends CommonObject } - /* + /** * \brief Ajoute un paiement de TVA * \param user Object user that insert * \return int <0 if KO, rowid in tva table if OK @@ -538,16 +539,13 @@ class Tva extends CommonObject $ok=0; } - // Mise a jour liens (pour chaque charge concernée par le paiement) - //foreach ($paiement->amounts as $key => $value) - //{ - // $chid = $key; - // $fac = new Facture($db); - // $fac->fetch($chid); - // $fac->fetch_client(); - // $acc->add_url_line($bank_line_id, $paiement_id, DOL_URL_ROOT.'/compta/paiement/fiche.php?id=', "(paiement)"); - // $acc->add_url_line($bank_line_id, $fac->client->id, DOL_URL_ROOT.'/compta/fiche.php?socid=', $fac->client->nom); - //} + // Mise a jour liens + $result=$acc->add_url_line($bank_line_id, $this->id, DOL_URL_ROOT.'/compta/tva/fiche.php?id=', "(VATPayment)", "payment_vat"); + if ($result < 0) + { + $this->error=$acc->error; + $ok=0; + } } if ($ok) diff --git a/htdocs/fourn/facture/paiementfourn.class.php b/htdocs/fourn/facture/paiementfourn.class.php index 5b1a99170af..d88e87ca0f0 100644 --- a/htdocs/fourn/facture/paiementfourn.class.php +++ b/htdocs/fourn/facture/paiementfourn.class.php @@ -479,12 +479,12 @@ class PaiementFourn $result=''; - $lien = '
'; + $lien = ''; $lienfin=''; if ($withpicto) $result.=($lien.img_object($langs->trans("ShowPayment"),'payment').$lienfin); if ($withpicto && $withpicto != 2) $result.=' '; - if ($withpicto != 2) $result.=$lien.$this->rowid.$lienfin; + if ($withpicto != 2) $result.=$lien.$this->ref.$lienfin; return $result; } /** diff --git a/htdocs/langs/en_US/compta.lang b/htdocs/langs/en_US/compta.lang index 98aa6321c69..fbbd474f700 100644 --- a/htdocs/langs/en_US/compta.lang +++ b/htdocs/langs/en_US/compta.lang @@ -47,6 +47,10 @@ AccountancyTreasuryArea=Accountancy/Treasury area AccountancySetup=Accountancy setup NewPayment=New payment Payments=Payments +PaymentCustomerInvoice=Customer invoice payment +PaymentSupplierInvoice=Supplier invoice payment +PaymentSocialContribution=Social contribution payment +PaymentVat=VAT payment ListPayment=List of payments ListOfPayments=List of payments ListOfCustomerPayments=List of customer payments @@ -55,6 +59,7 @@ DatePayment=Payment date NewVATPayment=New VAT payment VATPayment=VAT Payment VATPayments=VAT Payments +ShowVatPayment=Show VAT payement TotalToPay=Total to pay TotalVATReceived=Total VAT received CustomerAccountancyCode=Customer accountancy code diff --git a/htdocs/langs/fr_FR/compta.lang b/htdocs/langs/fr_FR/compta.lang index 3277bcd53c8..bf60ec19b11 100644 --- a/htdocs/langs/fr_FR/compta.lang +++ b/htdocs/langs/fr_FR/compta.lang @@ -47,6 +47,10 @@ AccountancyTreasuryArea=Espace Compta/Tr AccountancySetup=Configuration compta NewPayment=Nouveau réglement Payments=Réglements +PaymentCustomerInvoice=Réglement facture client +PaymentSupplierInvoice=Réglement facture fournisseur +PaymentSocialContribution=Réglement charge sociale +PaymentVat=Réglement TVA ListPayment=Liste des réglements ListOfPayments=Liste des réglements ListOfCustomerPayments=Liste des réglements clients @@ -55,6 +59,7 @@ DatePayment=Date de r NewVATPayment=Nouveau réglement de TVA VATPayment=Réglement TVA VATPayments=Réglements TVA +ShowVatPayment=Affiche payment TVA TotalToPay=Total à payer TotalVATReceived=Total TVA perçue CustomerAccountancyCode=Code compta client diff --git a/htdocs/paiement.class.php b/htdocs/paiement.class.php index 96801add4f9..2277f126a69 100644 --- a/htdocs/paiement.class.php +++ b/htdocs/paiement.class.php @@ -422,12 +422,12 @@ class Paiement $result=''; - $lien = ''; + $lien = ''; $lienfin=''; if ($withpicto) $result.=($lien.img_object($langs->trans("ShowPayment"),'payment').$lienfin); if ($withpicto && $withpicto != 2) $result.=' '; - if ($withpicto != 2) $result.=$lien.$this->rowid.$lienfin; + if ($withpicto != 2) $result.=$lien.$this->ref.$lienfin; return $result; }