diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index d9dd02ac1e5..6c3fcde5227 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -886,9 +886,9 @@ class FactureFournisseur extends CommonInvoice $sql .= " t.fk_soc,"; $sql .= " t.datec,"; $sql .= " t.datef,"; - $sql .= " t.tms,"; + $sql .= " t.tms as datem,"; $sql .= " t.libelle as label,"; - $sql .= " t.paye,"; + $sql .= " t.paye as paid,"; $sql .= " t.close_code,"; $sql .= " t.close_note,"; $sql .= " t.tva,"; @@ -953,14 +953,15 @@ class FactureFournisseur extends CommonInvoice $this->type = empty($obj->type) ? self::TYPE_STANDARD : $obj->type; $this->subtype = (int) $obj->subtype; $this->socid = $obj->fk_soc; - $this->datec = $this->db->jdate($obj->datec); $this->date = $this->db->jdate($obj->datef); - //$this->datep = $this->db->jdate($obj->datef); - $this->tms = $this->db->jdate($obj->tms); + $this->date_creation = $this->db->jdate($obj->datec); + $this->datec = $this->db->jdate($obj->datec); + $this->date_modification = $this->db->jdate($obj->datem); + $this->tms = $this->db->jdate($obj->datem); $this->libelle = $obj->label; // deprecated $this->label = $obj->label; - $this->paye = $obj->paye; - $this->paid = $obj->paye; + $this->paye = $obj->paid; + $this->paid = $obj->paid; $this->close_code = $obj->close_code; $this->close_note = $obj->close_note; $this->total_localtax1 = $obj->localtax1; @@ -1186,11 +1187,11 @@ class FactureFournisseur extends CommonInvoice $this->label = trim($this->label); } if (isset($this->paid)) { - $this->paid = (int) (bool) $this->paye; - $this->paye = $this->paid; + $this->paid = (int) (bool) $this->paid; + $this->paye = $this->paid; // deprecated } elseif (isset($this->paye)) { $this->paid = (int) (bool) $this->paye; - $this->paye = $this->paid; + $this->paye = $this->paid; // deprecared } if (isset($this->close_code)) { $this->close_code = trim($this->close_code); @@ -1268,7 +1269,9 @@ class FactureFournisseur extends CommonInvoice $sql .= " fk_soc=".(isset($this->socid) ? ((int) $this->socid) : "null").","; $sql .= " datec=".(dol_strlen((string) $this->datec) != 0 ? "'".$this->db->idate($this->datec)."'" : 'null').","; $sql .= " datef=".(dol_strlen((string) $this->date) != 0 ? "'".$this->db->idate($this->date)."'" : 'null').","; - if (dol_strlen((string) $this->tms) != 0) { + if (dol_strlen((string) $this->date_modification) != 0) { + $sql .= " tms=".(dol_strlen((string) $this->date_modification) != 0 ? "'".$this->db->idate($this->date_modification)."'" : 'null').","; + } elseif (dol_strlen((string) $this->tms) != 0) { // For backward compatibility $sql .= " tms=".(dol_strlen((string) $this->tms) != 0 ? "'".$this->db->idate($this->tms)."'" : 'null').","; } $sql .= " libelle=".(isset($this->label) ? "'".$this->db->escape($this->label)."'" : "null").","; @@ -2647,9 +2650,9 @@ class FactureFournisseur extends CommonInvoice $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture_fourn as ff ON f.rowid = ff.fk_facture_source"; $sql .= " WHERE (f.fk_statut = ".self::STATUS_VALIDATED." OR (f.fk_statut = ".self::STATUS_ABANDONED." AND f.close_code = '".self::CLOSECODE_ABANDONED."'))"; $sql .= " AND f.entity = ".$conf->entity; - $sql .= " AND f.paye = 0"; // Pas classee payee completement - $sql .= " AND pf.fk_paiementfourn IS NULL"; // Aucun paiement deja fait - $sql .= " AND ff.fk_statut IS NULL"; // Renvoi vrai si pas facture de replacement + $sql .= " AND f.paye = 0"; // Not closed completely + $sql .= " AND pf.fk_paiementfourn IS NULL"; // No payment already done + $sql .= " AND ff.fk_statut IS NULL"; // Return true (is null) if it is not a replacing invoice (we can't replace a replacing invoice) if ($socid > 0) { $sql .= " AND f.fk_soc = ".((int) $socid); } @@ -2680,8 +2683,7 @@ class FactureFournisseur extends CommonInvoice * (validated + payment in progress) or classified (paid in full or paid in part) + not already replaced + not already having * * @param int $socid Thirdparty id - * @return array,paymentornot:int<0,1>}>|int<-1,-1> Table of invoices ($id => array('ref'=>,'paymentornot'=>,'status'=>,'paye'=>) - * <0 if error + * @return array,paye:int<0,1>,paymentornot:int<0,1>}>|int<-1,-1> Table of invoices ($id => array('ref'=>,'paymentornot'=>,'status'=>,'paye'=>) or <0 if error */ public function list_qualified_avoir_supplier_invoices($socid = 0) { @@ -2690,7 +2692,7 @@ class FactureFournisseur extends CommonInvoice $return = array(); - $sql = "SELECT f.rowid as rowid, f.ref, f.fk_statut, f.type, f.subtype, f.paye, pf.fk_paiementfourn"; + $sql = "SELECT f.rowid as rowid, f.ref, f.fk_statut, f.type, f.subtype, f.paye as paid, pf.fk_paiementfourn"; $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."paiementfourn_facturefourn as pf ON f.rowid = pf.fk_facturefourn"; $sql .= " WHERE f.entity = ".$conf->entity; @@ -2716,7 +2718,7 @@ class FactureFournisseur extends CommonInvoice } if ($qualified) { $paymentornot = ($obj->fk_paiementfourn ? 1 : 0); - $return[$obj->rowid] = array('ref' => (string) $obj->ref, 'status' => (int) $obj->fk_statut, 'type' => (int) $obj->type, 'paye' => (int) $obj->paye, 'paymentornot' => (int) $paymentornot); + $return[$obj->rowid] = array('ref' => (string) $obj->ref, 'status' => (int) $obj->fk_statut, 'type' => (int) $obj->type, 'paid' => (int) $obj->paid, 'paye' => (int) $obj->paid, 'paymentornot' => (int) $paymentornot); } } diff --git a/htdocs/webservices/server_supplier_invoice.php b/htdocs/webservices/server_supplier_invoice.php index 7462538356e..261c63c41c8 100644 --- a/htdocs/webservices/server_supplier_invoice.php +++ b/htdocs/webservices/server_supplier_invoice.php @@ -283,7 +283,7 @@ function getSupplierInvoice($authentication, $id = 0, $ref = '', $ref_ext = '') foreach ($invoice->lines as $line) { //var_dump($line); exit; $linesresp[] = array( - 'id' => $line->rowid, + 'id' => $line->id, 'type' => $line->product_type, 'total_net' => $line->total_ht, 'total_vat' => $line->total_tva, @@ -310,8 +310,8 @@ function getSupplierInvoice($authentication, $id = 0, $ref = '', $ref_ext = '') 'total_net' => $invoice->total_ht, 'total_vat' => $invoice->total_tva, 'total' => $invoice->total_ttc, - 'date_creation' => dol_print_date($invoice->datec, 'dayhourrfc'), - 'date_modification' => dol_print_date($invoice->datem, 'dayhourrfc'), + 'date_creation' => dol_print_date($invoice->date_creation, 'dayhourrfc'), + 'date_modification' => dol_print_date($invoice->date_modification, 'dayhourrfc'), 'date_invoice' => dol_print_date($invoice->date, 'dayhourrfc'), 'date_term' => dol_print_date($invoice->date_echeance, 'dayhourrfc'), 'label' => $invoice->label, @@ -436,8 +436,8 @@ function getSupplierInvoicesForThirdParty($authentication, $idthirdparty) 'total_net' => $invoice->total_ht, 'total_vat' => $invoice->total_tva, 'total' => $invoice->total_ttc, - 'date_creation' => dol_print_date($invoice->datec, 'dayhourrfc'), - 'date_modification' => dol_print_date($invoice->datem, 'dayhourrfc'), + 'date_creation' => dol_print_date($invoice->date_creation, 'dayhourrfc'), + 'date_modification' => dol_print_date($invoice->date_modification, 'dayhourrfc'), 'date_invoice' => dol_print_date($invoice->date, 'dayhourrfc'), 'date_term' => dol_print_date($invoice->date_echeance, 'dayhourrfc'), 'label' => $invoice->label,