diff --git a/htdocs/cashdesk/tpl/facturation1.tpl.php b/htdocs/cashdesk/tpl/facturation1.tpl.php index 208727a76448a..8f74cf98626ed 100644 --- a/htdocs/cashdesk/tpl/facturation1.tpl.php +++ b/htdocs/cashdesk/tpl/facturation1.tpl.php @@ -125,23 +125,13 @@ - - + tva(); // Try to get a previously entered VAT rowid. First time, this will return empty. + $buyer = new Societe($db); + if ($_SESSION["CASHDESK_ID_THIRDPARTY"] > 0) $buyer->fetch($_SESSION["CASHDESK_ID_THIRDPARTY"]); + + echo $form->load_tva('selTva', (isset($_POST["selTva"])?GETPOST("selTva",'alpha',2):-1), $mysoc, $buyer, 0, 0, '', false, -1); + ?> diff --git a/htdocs/cashdesk/validation_verif.php b/htdocs/cashdesk/validation_verif.php index afe73820568e9..5775a3c938836 100644 --- a/htdocs/cashdesk/validation_verif.php +++ b/htdocs/cashdesk/validation_verif.php @@ -47,15 +47,25 @@ case 'valide_achat': - + + $thirdpartyid = $_SESSION['CASHDESK_ID_THIRDPARTY']; + $company=new Societe($db); - $company->fetch($conf->global->CASHDESK_ID_THIRDPARTY); + $company->fetch($thirdpartyid); $invoice=new Facture($db); $invoice->date=dol_now(); $invoice->type= Facture::TYPE_STANDARD; + + // TODO + // To use a specific numbering module for POS, reset $conf->global->FACTURE_ADDON and other vars here + // and restore after values just after + $num=$invoice->getNextNumRef($company); + // TODO Restore save values + + $obj_facturation->numInvoice($num); $obj_facturation->getSetPaymentMode($_POST['hdnChoix']); diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php index bd559fb96a311..bfd90b6909b42 100644 --- a/htdocs/comm/card.php +++ b/htdocs/comm/card.php @@ -484,24 +484,28 @@ print ''; print ''; if ($action == 'editlevel') + { $formcompany->form_prospect_level($_SERVER['PHP_SELF'].'?socid='.$object->id,$object->fk_prospectlevel,'prospect_level_id',1); - else - print $object->getLibProspLevel(); - print ""; - print ''; - - // Status - $object->loadCacheOfProspStatus(); - print ''.$langs->trans("StatusProsp").''.$object->getLibProspCommStatut(4, $object->cacheprospectstatus[$object->stcomm_id]['label']); - print '     '; - print '
'; - foreach($object->cacheprospectstatus as $key => $val) - { - $titlealt='default'; - if (! empty($val['code']) && ! in_array($val['code'], array('ST_NO', 'ST_NEVER', 'ST_TODO', 'ST_PEND', 'ST_DONE'))) $titlealt=$val['label']; - if ($object->stcomm_id != $val['id']) print ''.img_action($titlealt,$val['code']).''; - } - print '
'; + } + else + { + print $object->getLibProspLevel(); + } + print ""; + print ''; + + // Status + $object->loadCacheOfProspStatus(); + print ''.$langs->trans("StatusProsp").''.$object->getLibProspCommStatut(4, $object->cacheprospectstatus[$object->stcomm_id]['label']); + print '     '; + print '
'; + foreach($object->cacheprospectstatus as $key => $val) + { + $titlealt='default'; + if (! empty($val['code']) && ! in_array($val['code'], array('ST_NO', 'ST_NEVER', 'ST_TODO', 'ST_PEND', 'ST_DONE'))) $titlealt=$val['label']; + if ($object->stcomm_id != $val['id']) print ''.img_action($titlealt,$val['code']).''; + } + print '
'; print ""; } @@ -575,7 +579,7 @@ $warn = ''; if ($object->outstanding_limit != '' && $object->outstanding_limit < $outstandingOpened) { - $warn = img_warning($langs->trans("OutstandingBillReached")); + $warn = ' '.img_warning($langs->trans("OutstandingBillReached")); } $text=$langs->trans("CurrentOutstandingBill"); $link=DOL_URL_ROOT.'/compta/recap-compta.php?socid='.$object->id; @@ -583,7 +587,7 @@ if ($link) $boxstat.=''; $boxstat.='
'; $boxstat.=''.img_object("",$icon).' '.$text.'
'; - $boxstat.=''.price($outstandingOpened).$warn.''; + $boxstat.=''.price($outstandingOpened, 1, $langs, 1, -1, -1, $conf->currency).$warn.''; $boxstat.='
'; if ($link) $boxstat.='
'; } diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index aef95d1b0a9ba..72e81fd252e89 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -3120,52 +3120,6 @@ function getListOfPayments($filtertype='') } - /** - * Return amount (with tax) of all credit notes and deposits invoices used by invoice - * - * @param int $multicurrency Return multicurrency_amount instead of amount - * @return int <0 if KO, Sum of credit notes and deposits amount otherwise - */ - function getSumCreditNotesUsed($multicurrency=0) - { - require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php'; - - $discountstatic=new DiscountAbsolute($this->db); - $result=$discountstatic->getSumCreditNotesUsed($this, $multicurrency); - if ($result >= 0) - { - return $result; - } - else - { - $this->error=$discountstatic->error; - return -1; - } - } - - /** - * Return amount (with tax) of all deposits invoices used by invoice - * - * @param int $multicurrency Return multicurrency_amount instead of amount - * @return int <0 if KO, Sum of deposits amount otherwise - */ - function getSumDepositsUsed($multicurrency=0) - { - require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php'; - - $discountstatic=new DiscountAbsolute($this->db); - $result=$discountstatic->getSumDepositsUsed($this, $multicurrency); - if ($result >= 0) - { - return $result; - } - else - { - $this->error=$discountstatic->error; - return -1; - } - } - /** * Return next reference of customer invoice not already used (or last reference) * according to numbering module defined into constant FACTURE_ADDON diff --git a/htdocs/core/class/commoninvoice.class.php b/htdocs/core/class/commoninvoice.class.php index 05cf0b4c3cbcc..4822ad7d0d858 100644 --- a/htdocs/core/class/commoninvoice.class.php +++ b/htdocs/core/class/commoninvoice.class.php @@ -88,6 +88,7 @@ abstract class CommonInvoice extends CommonObject */ const STATUS_ABANDONED = 3; + /** * Return amount of payments already done * @@ -124,6 +125,65 @@ function getSommePaiement($multicurrency=0) } } + /** + * Return amount (with tax) of all credit notes and deposits invoices used by invoice + * + * @param int $multicurrency Return multicurrency_amount instead of amount + * @return int <0 if KO, Sum of credit notes and deposits amount otherwise + */ + function getSumCreditNotesUsed($multicurrency=0) + { + if ($this->element == 'facture_fourn' || $this->element == 'invoice_supplier') + { + // TODO + return 0; + } + + require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php'; + + $discountstatic=new DiscountAbsolute($this->db); + $result=$discountstatic->getSumCreditNotesUsed($this, $multicurrency); + if ($result >= 0) + { + return $result; + } + else + { + $this->error=$discountstatic->error; + return -1; + } + } + + /** + * Return amount (with tax) of all deposits invoices used by invoice + * + * @param int $multicurrency Return multicurrency_amount instead of amount + * @return int <0 if KO, Sum of deposits amount otherwise + */ + function getSumDepositsUsed($multicurrency=0) + { + if ($this->element == 'facture_fourn' || $this->element == 'invoice_supplier') + { + // TODO + return 0; + } + + require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php'; + + $discountstatic=new DiscountAbsolute($this->db); + $result=$discountstatic->getSumDepositsUsed($this, $multicurrency); + if ($result >= 0) + { + return $result; + } + else + { + $this->error=$discountstatic->error; + return -1; + } + } + + /** * Renvoie tableau des ids de facture avoir issus de la facture * diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 22a397fb4e736..bc761b2d2b1f4 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -4257,7 +4257,7 @@ function load_cache_vatrates($country_code) dol_syslog(__METHOD__, LOG_DEBUG); - $sql = "SELECT DISTINCT t.code, t.taux, t.recuperableonly"; + $sql = "SELECT DISTINCT t.rowid, t.code, t.taux, t.recuperableonly"; $sql.= " FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_country as c"; $sql.= " WHERE t.fk_pays = c.rowid"; $sql.= " AND t.active > 0"; @@ -4273,6 +4273,7 @@ function load_cache_vatrates($country_code) for ($i = 0; $i < $num; $i++) { $obj = $this->db->fetch_object($resql); + $this->cache_vatrates[$i]['rowid'] = $obj->rowid; $this->cache_vatrates[$i]['code'] = $obj->code; $this->cache_vatrates[$i]['txtva'] = $obj->taux; $this->cache_vatrates[$i]['libtva'] = $obj->taux.'%'.($obj->code?' ('.$obj->code.')':''); // Label must contains only 0-9 , . % or * @@ -4302,9 +4303,9 @@ function load_cache_vatrates($country_code) * @param float|string $selectedrate Force preselected vat rate. Can be '8.5' or '8.5 (NOO)' for example. Use '' for no forcing. * @param Societe $societe_vendeuse Thirdparty seller * @param Societe $societe_acheteuse Thirdparty buyer - * @param int $idprod Id product + * @param int $idprod Id product. O if unknown of NA. * @param int $info_bits Miscellaneous information on line (1 for NPR) - * @param int $type ''=Unknown, 0=Product, 1=Service (Used if idprod not defined) + * @param int|string $type ''=Unknown, 0=Product, 1=Service (Used if idprod not defined) * Si vendeur non assujeti a TVA, TVA par defaut=0. Fin de regle. * Si le (pays vendeur = pays acheteur) alors la TVA par defaut=TVA du produit vendu. Fin de regle. * Si (vendeur et acheteur dans Communaute europeenne) et bien vendu = moyen de transports neuf (auto, bateau, avion), TVA par defaut=0 (La TVA doit etre paye par l'acheteur au centre d'impots de son pays et non au vendeur). Fin de regle. @@ -4312,10 +4313,10 @@ function load_cache_vatrates($country_code) * Si vendeur et acheteur dans Communauté européenne et acheteur= entreprise alors TVA par défaut=0. Fin de règle. * Sinon la TVA proposee par defaut=0. Fin de regle. * @param bool $options_only Return HTML options lines only (for ajax treatment) - * @param int $addcode Add code into key in select list + * @param int $mode 1=Add code into key in select list * @return string */ - function load_tva($htmlname='tauxtva', $selectedrate='', $societe_vendeuse='', $societe_acheteuse='', $idprod=0, $info_bits=0, $type='', $options_only=false, $addcode=0) + function load_tva($htmlname='tauxtva', $selectedrate='', $societe_vendeuse='', $societe_acheteuse='', $idprod=0, $info_bits=0, $type='', $options_only=false, $mode=0) { global $langs,$conf,$mysoc; @@ -4427,10 +4428,13 @@ function load_tva($htmlname='tauxtva', $selectedrate='', $societe_vendeuse='', $ // Keep only 0 if seller is not subject to VAT if ($disabled && $rate['txtva'] != 0) continue; - $return.= '