Skip to content

Commit

Permalink
Merge branch 'develop' of [email protected]:Dolibarr/dolibarr.git into d…
Browse files Browse the repository at this point in the history
…evelop
  • Loading branch information
eldy committed Aug 20, 2024
2 parents eee66bf + 16e72b4 commit 91ef884
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 42 deletions.
1 change: 0 additions & 1 deletion dev/tools/phan/baseline.txt
Original file line number Diff line number Diff line change
Expand Up @@ -809,7 +809,6 @@ return [
'htdocs/fourn/class/fournisseur.class.php' => ['PhanPluginUnknownArrayMethodReturnType'],
'htdocs/fourn/class/fournisseur.commande.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType', 'PhanPluginUnknownObjectMethodCall', 'PhanPluginUnknownPropertyType', 'PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchArgumentNullableInternal', 'PhanUndeclaredProperty'],
'htdocs/fourn/class/fournisseur.facture-rec.class.php' => ['PhanPluginUnknownPropertyType', 'PhanUndeclaredProperty'],
'htdocs/fourn/class/fournisseur.facture.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownPropertyType', 'PhanPossiblyUndeclaredVariable', 'PhanUndeclaredProperty'],
'htdocs/fourn/class/fournisseur.product.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownObjectMethodCall', 'PhanPluginUnknownPropertyType', 'PhanTypeMismatchProperty'],
'htdocs/fourn/class/paiementfourn.class.php' => ['PhanEmptyForeach', 'PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownObjectMethodCall', 'PhanPluginUnknownPropertyType', 'PhanPossiblyNullTypeMismatchProperty', 'PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchArgumentProbablyReal'],
'htdocs/fourn/commande/card.php' => ['PhanPluginBothLiteralsBinaryOp', 'PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchProperty', 'PhanUndeclaredProperty'],
Expand Down
97 changes: 56 additions & 41 deletions htdocs/fourn/class/fournisseur.facture.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,12 +176,12 @@ class FactureFournisseur extends CommonInvoice
public $date_echeance;

/**
* @var double $amount
* @var float
* @deprecated See $total_ttc, $total_ht, $total_tva
*/
public $amount = 0;
/**
* @var double $remise
* @var float
* @deprecated
*/
public $remise = 0;
Expand Down Expand Up @@ -315,6 +315,11 @@ class FactureFournisseur extends CommonInvoice
);


/**
* @var int Id User modifying
*/
public $fk_user_valid;

/**
* Standard invoice
*/
Expand Down Expand Up @@ -418,6 +423,12 @@ public function create($user)

$this->db->begin();

// Defaults
$originaldatewhen = 0;
$nextdatewhen = 0;
$previousdaynextdatewhen = 0;
$_facrec = null;

// Create invoice from a template recurring invoice
if ($this->fac_rec > 0) {
$this->fk_fac_rec_source = $this->fac_rec;
Expand All @@ -433,10 +444,6 @@ public function create($user)
$nextdatewhen = dol_time_plus_duree($originaldatewhen, $_facrec->frequency, $_facrec->unit_frequency);
$previousdaynextdatewhen = dol_time_plus_duree($nextdatewhen, -1, 'd');
$this->socid = $_facrec->socid;
} else {
$originaldatewhen = 0;
$nextdatewhen = 0;
$previousdaynextdatewhen = 0;
}

$this->entity = $_facrec->entity; // Invoice created in same entity than template
Expand Down Expand Up @@ -506,8 +513,8 @@ public function create($user)
if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang) && isset($this->thirdparty->default_lang)) {
$newlang = $this->thirdparty->default_lang; // for proposal, order, invoice, ...
}
if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang) && isset($this->default_lang)) {
$newlang = $this->default_lang; // for thirdparty
if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang) && property_exists($this, 'default_lang') && isset($this->default_lang)) { // @phan-suppress-current-line PhanUndeclaredProperty
$newlang = $this->default_lang; // for thirdparty @phan-suppress-current-line PhanUndeclaredProperty
}
if (!empty($newlang)) {
$outputlangs = new Translate("", $conf);
Expand Down Expand Up @@ -747,7 +754,8 @@ public function create($user)
$localtax1_tx = $_facrec->lines[$i]->localtax1_tx;
$localtax2_tx = $_facrec->lines[$i]->localtax2_tx;

$fk_product_fournisseur_price = empty($_facrec->lines[$i]->fk_product_fournisseur_price) ? null : $_facrec->lines[$i]->fk_product_fournisseur_price;
// $fk_product_fournisseur_price not used and does not exist on line
// $fk_product_fournisseur_price = empty($_facrec->lines[$i]->fk_product_fournisseur_price) ? null : $_facrec->lines[$i]->fk_product_fournisseur_price;
$buyprice = empty($_facrec->lines[$i]->buyprice) ? 0 : $_facrec->lines[$i]->buyprice;

// If buyprice not defined from template invoice, we try to guess the best value
Expand Down Expand Up @@ -1204,7 +1212,7 @@ public function update($user = null, $notrigger = 0)
$this->author = (int) $this->author;
}
if (isset($this->fk_user_valid)) {
$this->fk_user_valid = trim($this->fk_user_valid);
$this->fk_user_valid = (int) $this->fk_user_valid;
}
if (isset($this->fk_facture_source)) {
$this->fk_facture_source = (int) $this->fk_facture_source;
Expand Down Expand Up @@ -2056,13 +2064,13 @@ public function setDraft($user, $idwarehouse = -1, $notrigger = 0)
* already have the right value (the caller has to manage the multilanguage).
*
* @param string $desc Description of the line
* @param double $pu Unit price (HT or TTC according to price_base_type, > 0 even for credit note)
* @param double $txtva Force Vat rate to use, -1 for auto.
* @param double $txlocaltax1 LocalTax1 Rate
* @param double $txlocaltax2 LocalTax2 Rate
* @param double $qty Quantity
* @param float $pu Unit price (HT or TTC according to price_base_type, > 0 even for credit note)
* @param float $txtva Force Vat rate to use, -1 for auto.
* @param float $txlocaltax1 LocalTax1 Rate
* @param float $txlocaltax2 LocalTax2 Rate
* @param float $qty Quantity
* @param int $fk_product Product/Service ID predefined
* @param double $remise_percent Percentage discount of the line
* @param float $remise_percent Percentage discount of the line
* @param int $date_start Service start date
* @param int $date_end Service expiry date
* @param int $fk_code_ventilation Accounting breakdown code
Expand All @@ -2071,10 +2079,10 @@ public function setDraft($user, $idwarehouse = -1, $notrigger = 0)
* @param int $type Type of line (0=product, 1=service)
* @param int $rang Position of line
* @param int $notrigger Disable triggers
* @param array $array_options extrafields array
* @param array<string,mixed> $array_options extrafields array
* @param int|null $fk_unit Code of the unit to use. Null to use the default one
* @param int $origin_id id origin document
* @param double $pu_devise Amount in currency
* @param float $pu_devise Amount in currency
* @param string $ref_supplier Supplier ref
* @param int $special_code Special code
* @param int $fk_parent_line Parent line id
Expand Down Expand Up @@ -2320,29 +2328,29 @@ public function addline($desc, $pu, $txtva, $txlocaltax1, $txlocaltax2, $qty, $f
}

/**
* Update a line detail into database
* Update a line detail in the database
*
* @param int $id Id of line invoice
* @param string $desc Description of line
* @param double $pu Prix unitaire (HT ou TTC selon price_base_type)
* @param double $vatrate VAT Rate (Can be '8.5', '8.5 (ABC)')
* @param double $txlocaltax1 LocalTax1 Rate
* @param double $txlocaltax2 LocalTax2 Rate
* @param double $qty Quantity
* @param int $idproduct Id produit
* @param string $price_base_type HT or TTC
* @param int $info_bits Miscellaneous information of line
* @param int $type Type of line (0=product, 1=service)
* @param double $remise_percent Percentage discount of the line
* @param int $notrigger Disable triggers
* @param int|string $date_start Date start of service
* @param int|string $date_end Date end of service
* @param array $array_options extrafields array
* @param int|null $fk_unit Code of the unit to use. Null to use the default one
* @param double $pu_devise Amount in currency
* @param string $ref_supplier Supplier ref
* @param int $rang Line rank
* @return int<-1,1> Return integer <0 if KO, >0 if OK
* @param int $id Id of line invoice
* @param string $desc Description of line
* @param float $pu Prix unitaire (HT ou TTC selon price_base_type)
* @param float $vatrate VAT Rate (Can be '8.5', '8.5 (ABC)')
* @param float $txlocaltax1 LocalTax1 Rate
* @param float $txlocaltax2 LocalTax2 Rate
* @param float $qty Quantity
* @param int $idproduct Id produit
* @param string $price_base_type HT or TTC
* @param int $info_bits Miscellaneous information of line
* @param int $type Type of line (0=product, 1=service)
* @param float $remise_percent Percentage discount of the line
* @param int $notrigger Disable triggers
* @param int|string $date_start Date start of service
* @param int|string $date_end Date end of service
* @param array<string,mixed> $array_options extrafields array
* @param ?int $fk_unit Code of the unit to use. Null to use the default one
* @param float $pu_devise Amount in currency
* @param string $ref_supplier Supplier ref
* @param int $rang Line rank
* @return int<-1,1> Return integer <0 if KO, >0 if OK
*/
public function updateline($id, $desc, $pu, $vatrate, $txlocaltax1 = 0, $txlocaltax2 = 0, $qty = 1, $idproduct = 0, $price_base_type = 'HT', $info_bits = 0, $type = 0, $remise_percent = 0, $notrigger = 0, $date_start = '', $date_end = '', $array_options = [], $fk_unit = null, $pu_devise = 0, $ref_supplier = '', $rang = 0)
{
Expand Down Expand Up @@ -3765,7 +3773,8 @@ class SupplierInvoiceLine extends CommonObjectLine
public $oldline;

/**
* @deprecated
* @var string
* @deprecated See $product_ref
* @see $product_ref
*/
public $ref;
Expand Down Expand Up @@ -3830,7 +3839,13 @@ class SupplierInvoiceLine extends CommonObjectLine
*/
public $description;

/**
* @var int|string
*/
public $date_start;
/**
* @var int|string
*/
public $date_end;

/**
Expand Down
25 changes: 25 additions & 0 deletions htdocs/reception/card.php
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,7 @@
// avec info diverses + qte a livrer

if ($object->origin == "supplierorder") {
$object->origin = 'order_supplier';
$classname = 'CommandeFournisseur';
} else {
$classname = ucfirst($object->origin);
Expand Down Expand Up @@ -438,6 +439,30 @@
if ($ret <= 0) {
setEventMessages($object->error, $object->errors, 'errors');
$error++;
} else {
// Define output language
if (!getDolGlobalString('MAIN_DISABLE_PDF_AUTOUPDATE')) {
$object->fetch_thirdparty();
$outputlangs = $langs;
$newlang = '';
if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang) && GETPOST('lang_id', 'aZ09')) {
$newlang = GETPOST('lang_id', 'aZ09');
}
if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang)) {
$newlang = $object->thirdparty->default_lang;
}
if (!empty($newlang)) {
$outputlangs = new Translate("", $conf);
$outputlangs->setDefaultLang($newlang);
}
$model = $object->model_pdf;
$ret = $object->fetch($object->id); // Reload to get new records

$result = $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
if ($result < 0) {
dol_print_error($db, $result);
}
}
}
}
} else {
Expand Down

0 comments on commit 91ef884

Please sign in to comment.