mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2026-02-07 16:41:48 +01:00
NEW billing on shipment+reception. Can be done before or after delivery.
This commit is contained in:
@@ -370,7 +370,7 @@ class Reception extends CommonObject
|
||||
return -1;
|
||||
}
|
||||
|
||||
$sql = "SELECT e.rowid, e.entity, e.ref, e.fk_soc as socid, e.date_creation, e.ref_supplier, e.ref_ext, e.fk_user_author, e.fk_statut";
|
||||
$sql = "SELECT e.rowid, e.entity, e.ref, e.fk_soc as socid, e.date_creation, e.ref_supplier, e.ref_ext, e.fk_user_author, e.fk_statut as status";
|
||||
$sql .= ", e.weight, e.weight_units, e.size, e.size_units, e.width, e.height";
|
||||
$sql .= ", e.date_reception as date_reception, e.model_pdf, e.date_delivery";
|
||||
$sql .= ", e.fk_shipping_method, e.tracking_number";
|
||||
@@ -404,7 +404,8 @@ class Reception extends CommonObject
|
||||
$this->socid = $obj->socid;
|
||||
$this->ref_supplier = $obj->ref_supplier;
|
||||
$this->ref_ext = $obj->ref_ext;
|
||||
$this->statut = $obj->fk_statut;
|
||||
$this->statut = $obj->status;
|
||||
$this->status = $obj->status;
|
||||
$this->user_author_id = $obj->fk_user_author;
|
||||
$this->date_creation = $this->db->jdate($obj->date_creation);
|
||||
$this->date = $this->db->jdate($obj->date_reception); // TODO deprecated
|
||||
@@ -1530,9 +1531,14 @@ class Reception extends CommonObject
|
||||
|
||||
$error = 0;
|
||||
|
||||
// Protection. This avoid to move stock later when we should not
|
||||
if ($this->statut == self::STATUS_CLOSED) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
$sql = 'UPDATE '.MAIN_DB_PREFIX.'reception SET fk_statut='.self::STATUS_CLOSED;
|
||||
$sql = 'UPDATE '.MAIN_DB_PREFIX.'reception SET fk_statut = '.self::STATUS_CLOSED;
|
||||
$sql .= " WHERE rowid = ".((int) $this->id).' AND fk_statut > 0';
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
@@ -1562,7 +1568,7 @@ class Reception extends CommonObject
|
||||
}
|
||||
|
||||
$this->statut = self::STATUS_CLOSED;
|
||||
|
||||
$this->status = self::STATUS_CLOSED;
|
||||
|
||||
// If stock increment is done on closing
|
||||
if (!$error && isModEnabled('stock') && !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE)) {
|
||||
@@ -1653,7 +1659,7 @@ class Reception extends CommonObject
|
||||
}
|
||||
|
||||
/**
|
||||
* Classify the reception as invoiced (used when WORKFLOW_EXPEDITION_CLASSIFY_CLOSED_INVOICE is on)
|
||||
* Classify the reception as invoiced (used for exemple by trigger when WORKFLOW_RECEPTION_CLASSIFY_BILLED_INVOICE is on)
|
||||
*
|
||||
* @return int <0 if ko, >0 if ok
|
||||
*/
|
||||
@@ -1666,17 +1672,17 @@ class Reception extends CommonObject
|
||||
|
||||
$this->setClosed();
|
||||
|
||||
$sql = 'UPDATE '.MAIN_DB_PREFIX.'reception SET billed=1';
|
||||
$sql = 'UPDATE '.MAIN_DB_PREFIX.'reception SET billed=1';
|
||||
$sql .= " WHERE rowid = ".((int) $this->id).' AND fk_statut > 0';
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql) {
|
||||
$this->statut = 2;
|
||||
$this->billed = 1;
|
||||
|
||||
// Call trigger
|
||||
$result = $this->call_trigger('RECEPTION_BILLED', $user);
|
||||
if ($result < 0) {
|
||||
$this->billed = 0;
|
||||
$error++;
|
||||
}
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user