From efd24e5922b1eb75b2b75b8795fb7b8188b2dc34 Mon Sep 17 00:00:00 2001 From: aspangaro Date: Sat, 29 Oct 2016 07:45:24 +0200 Subject: [PATCH] Work on supplier credit note --- htdocs/compta/facture.php | 70 +++++++++++++++++------------------ htdocs/fourn/facture/card.php | 50 +++++++++++++------------ 2 files changed, 60 insertions(+), 60 deletions(-) diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index 2f4f887f652..3ee875b5d93 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -2933,17 +2933,17 @@ else if ($id > 0 || ! empty($ref)) } } $morehtmlref.=''; - + $object->totalpaye = $totalpaye; // To give a chance to dol_banner_tab to use already paid amount to show correct status - + dol_banner_tab($object, 'ref', $linkback, 1, 'facnumber', 'ref', $morehtmlref, '', 0, '', $morehtmlright); - + print '
'; print '
'; print '
'; - + print ''; - + // Type print '
' . $langs->trans('Type') . ''; print $object->getLibType(); @@ -3303,7 +3303,7 @@ else if ($id > 0 || ! empty($ref)) include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; print '
'; - + print '
'; print '
'; print '
'; @@ -3328,15 +3328,15 @@ else if ($id > 0 || ! empty($ref)) print '' . price($object->multicurrency_total_ttc, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . ''; print ''; } - + // Amount - print '' . $langs->trans('AmountHT') . ''; + print '' . $langs->trans('AmountHT') . ''; print '' . price($object->total_ht, 1, '', 1, - 1, - 1, $conf->currency) . ''; - + // Vat print '' . $langs->trans('AmountVAT') . '' . price($object->total_tva, 1, '', 1, - 1, - 1, $conf->currency) . ''; print ''; - + // Amount Local Taxes if (($mysoc->localtax1_assuj == "1" && $mysoc->useLocalTax(1)) || $object->total_localtax1 != 0) // Localtax1 { @@ -3348,7 +3348,7 @@ else if ($id > 0 || ! empty($ref)) print '' . $langs->transcountry("AmountLT2", $mysoc->country_code) . ''; print '' . price($object->total_localtax2, 1, '', 1, - 1, - 1, $conf->currency) . ''; } - + // Revenue stamp if ($selleruserevenustamp) // Test company use revenue stamp { @@ -3375,14 +3375,14 @@ else if ($id > 0 || ! empty($ref)) } print ''; } - + // Total with tax print '' . $langs->trans('AmountTTC') . '' . price($object->total_ttc, 1, '', 1, - 1, - 1, $conf->currency) . ''; - + print ''; - + // List of payments - + $sign = 1; if ($object->type == Facture::TYPE_CREDIT_NOTE) $sign = - 1; $nbrows = 8; @@ -3491,9 +3491,9 @@ else if ($id > 0 || ! empty($ref)) if (count($object->tab_previous_situation_invoice) > 0 || count($object->tab_next_situation_invoice) > 0) print ''; } - + print ''; - + // List of payments already done print ''; print ''; @@ -3505,9 +3505,9 @@ else if ($id > 0 || ! empty($ref)) print ''; print ''; print ''; - + $var = true; - + // Payments already done (from payment on this invoice) $sql = 'SELECT p.datep as dp, p.ref, p.num_paiement, p.rowid, p.fk_bank,'; $sql .= ' c.code as payment_code, c.libelle as payment_label,'; @@ -3518,12 +3518,12 @@ else if ($id > 0 || ! empty($ref)) $sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'bank_account as ba ON b.fk_account = ba.rowid'; $sql .= ' WHERE pf.fk_facture = ' . $object->id . ' AND p.fk_paiement = c.id AND pf.fk_paiement = p.rowid'; $sql .= ' ORDER BY p.datep, p.tms'; - + $result = $db->query($sql); if ($result) { $num = $db->num_rows($result); $i = 0; - + // if ($object->type != 2) // { if ($num > 0) { @@ -3563,7 +3563,7 @@ else if ($id > 0 || ! empty($ref)) } else { dol_print_error($db); } - + if ($object->type != Facture::TYPE_CREDIT_NOTE) { // Total already paid print ''; - + $resteapayeraffiche = $resteapayer; $cssforamountpaymentcomplete = 'amountpaymentcomplete'; - + // Loop on each credit note or deposit amount applied $creditnoteamount = 0; $depositamount = 0; @@ -3611,7 +3611,7 @@ else if ($id > 0 || ! empty($ref)) } else { dol_print_error($db); } - + // Paye partiellement 'escompte' if (($object->statut == Facture::STATUS_CLOSED || $object->statut == Facture::STATUS_ABANDONED) && $object->close_code == 'discount_vat') { print ''; @@ -3667,10 +3667,10 @@ else if ($id > 0 || ! empty($ref)) print ''; - + // Billed print ''; - + // Remainder to pay back print ''; print ''; print ''; - + // Sold credit note // print ''; // print ''; } - + print '
' . ($object->type == Facture::TYPE_CREDIT_NOTE ? $langs->trans("PaymentsBack") : $langs->trans('Payments')) . '' . $langs->trans('Amount') . ' 
'; @@ -3572,10 +3572,10 @@ else if ($id > 0 || ! empty($ref)) else print $langs->trans('AlreadyPaid'); print ' : 0)?' class="amountalreadypaid"':'').'>' . price($totalpaye) . ' 
'; @@ -3647,7 +3647,7 @@ else if ($id > 0 || ! empty($ref)) $resteapayeraffiche = 0; $cssforamountpaymentcomplete = ''; } - + // Billed print '
' . $langs->trans("Billed") . ' :' . price($object->total_ttc) . ' 
'; print $langs->trans('AlreadyPaidBack'); print ' :' . price($sign * $totalpaye) . ' 
' . $langs->trans("Billed") . ' :' . price($sign * $object->total_ttc) . ' 
'; if ($resteapayeraffiche <= 0) @@ -3680,27 +3680,26 @@ else if ($id > 0 || ! empty($ref)) print ' :' . price($sign * $resteapayeraffiche) . ' 
'.$langs->trans('TotalTTC').' :'.price($sign * // $object->total_ttc).' 
'; - + // Margin Infos if (! empty($conf->margin->enabled)) { $formmargin->displayMarginInfos($object); } - print '
'; print '
'; print '
'; - + print '

'; - + if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) { $blocname = 'contacts'; $title = $langs->trans('ContactsAddresses'); @@ -3811,8 +3810,7 @@ else if ($id > 0 || ! empty($ref)) print '
'; $parameters = array(); - $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been - // modified by hook + $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook if (empty($reshook)) { // Editer une facture deja validee, sans paiement effectue et pas exporte en compta if ($object->statut == 1) diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index bd7d1317957..1fbbe41978b 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -8,7 +8,7 @@ * Copyright (C) 2013-2015 Philippe Grand * Copyright (C) 2013 Florian Henry * Copyright (C) 2014 Marcos GarcĂ­a - * Copyright (C) 2016 Alexandre Spangaro + * Copyright (C) 2016 Alexandre Spangaro * * 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 @@ -2249,9 +2249,9 @@ else print '
'; print '
'; print '
'; - + print ''; - + // Amount print ''; print ''; - + // Amount Local Taxes //TODO: Place into a function to control showing by country or study better option if ($societe->localtax1_assuj=="1") //Localtax1 @@ -2281,7 +2281,7 @@ else print ''; } print ''; - + if (!empty($conf->multicurrency->enabled)) { // Multicurrency Amount HT @@ -2298,22 +2298,26 @@ else print ''; print ''; print ''; - } - + } + print '
'.$langs->trans('AmountHT').''.price($object->total_ht,1,$langs,0,-1,-1,$conf->currency).'
'.$langs->trans('AmountVAT').''.price($object->total_tva,1,$langs,0,-1,-1,$conf->currency).'
        '; @@ -2265,7 +2265,7 @@ else $s.=''.$langs->trans("Mode2").''; print $form->textwithtooltip($s, $langs->trans("CalculationRuleDesc",$calculationrulenum).'
'.$langs->trans("CalculationRuleDescSupplier"), 2, 1, img_picto('','help')); print '
'.$langs->trans('AmountTTC').''.price($object->total_ttc,1,$langs,0,-1,-1,$conf->currency).'
' . fieldLabel('MulticurrencyAmountTTC','multicurrency_total_ttc') . '' . price($object->multicurrency_total_ttc, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '
'; - + /* * List of payments */ - $nbrows=9; $nbcols=3; + $sign = 1; + if ($object->type == FactureFournisseur::TYPE_CREDIT_NOTE) $sign = - 1; + + $nbrows=9; $nbcols=3; if (! empty($conf->projet->enabled)) $nbrows++; if (! empty($conf->banque->enabled)) { $nbrows++; $nbcols++; } if (! empty($conf->incoterm->enabled)) $nbrows++; - + if (! empty($conf->multicurrency->enabled)) $nbrows += 5; + // Local taxes if ($societe->localtax1_assuj=="1") $nbrows++; if ($societe->localtax2_assuj=="1") $nbrows++; - + $sql = 'SELECT p.datep as dp, p.ref, p.num_paiement, p.rowid, p.fk_bank,'; $sql.= ' c.id as paiement_type,'; $sql.= ' pf.amount,'; @@ -2325,7 +2329,7 @@ else $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'paiementfourn_facturefourn as pf ON pf.fk_paiementfourn = p.rowid'; $sql.= ' WHERE pf.fk_facturefourn = '.$object->id; $sql.= ' ORDER BY p.datep, p.tms'; - + $result = $db->query($sql); if ($result) { @@ -2333,14 +2337,14 @@ else $i = 0; $totalpaye = 0; print ''; print ''; - print ''; + print ''; print ''; print ''; if (! empty($conf->banque->enabled)) print ''; print ''; print ''; print ''; - + $var=false; if ($num > 0) { @@ -2369,7 +2373,7 @@ else if ($objp->baid > 0) print $bankaccountstatic->getNomUrl(1,'transactions'); print ''; } - print ''; + print ''; print '
'.$langs->trans('Payments').'' . ($object->type == FactureFournisseur::TYPE_CREDIT_NOTE ? $langs->trans("PaymentsBack") : $langs->trans('Payments')) . ''.$langs->trans('Date').''.$langs->trans('Type').''.$langs->trans('BankAccount').''.$langs->trans('Amount').' 
'.price($objp->amount).'' . price($sign * $objp->amount) . ''; if ($object->statut == FactureFournisseur::STATUS_VALIDATED && $object->paye == 0 && $user->societe_id == 0) { @@ -2405,7 +2409,6 @@ else { dol_print_error($db); } - print ''; print ''; @@ -2435,13 +2438,12 @@ else //$result = $object->getLinesArray(); - print '
- - - - - - '; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; if (! empty($conf->use_javascript_ajax) && $object->statut == FactureFournisseur::STATUS_DRAFT) { include DOL_DOCUMENT_ROOT . '/core/tpl/ajaxrow.tpl.php'; @@ -2449,7 +2451,7 @@ else print ''; - global $forceall, $senderissupplier, $dateSelector, $inputalsopricewithtax; + global $forceall, $senderissupplier, $dateSelector, $inputalsopricewithtax; $forceall=1; $senderissupplier=1; $dateSelector=0; $inputalsopricewithtax=1; // Show object lines