Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX #28347 FIX #28962 FIX #29224 FIX #29035 #29303

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
91 changes: 67 additions & 24 deletions htdocs/fourn/commande/card.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
* Copyright (C) 2022 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
* Copyright (C) 2022 Charlene Benke <charlene@patas-monkey.com>
* Copyright (C) 2023 Joachim Kueter <git-jk@bloxera.com>
* Copyright (C) 2024 Nick Fragoulis
*
* 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
Expand Down Expand Up @@ -1333,10 +1334,35 @@
$product_fourn_price_id = 0;
if ($origin == "commande") {
$productsupplier = new ProductFournisseur($db);
$result = $productsupplier->find_min_price_product_fournisseur($lines[$i]->fk_product, $lines[$i]->qty, $srcobject->socid);
$result = $productsupplier->find_min_price_product_fournisseur($lines[$i]->fk_product, $lines[$i]->qty, $object->socid);
$lines[$i]->subprice = 0;
if ($result > 0) {
$ref_supplier = $productsupplier->ref_supplier;
$product_fourn_price_id = $productsupplier->product_fourn_price_id;
// we need supplier subprice
foreach ($srcobject->lines as $li) {
$sql = 'SELECT price, unitprice, tva_tx, remise_percent, entity, ref_fourn';
$sql .= ' FROM '.MAIN_DB_PREFIX.'product_fournisseur_price';
$sql .= ' WHERE fk_product = '.((int) $li->fk_product);
$sql .= ' AND entity IN ('.getEntity('product_fournisseur_price').')';
$sql .= ' AND fk_soc = '.((int) $object->socid);
sonikf marked this conversation as resolved.
Show resolved Hide resolved
$sql .= ' ORDER BY unitprice ASC';

$resql = $db->query($sql);
if ($resql) {
$num_row = $db->num_rows($resql);
if (empty($num_row)) {
$li->remise_percent = 0;
} else {
$obj = $db->fetch_object($resql);
$li->subprice = $obj->unitprice;
$li->remise_percent = $obj->remise_percent;
}
} else {
dol_print_error($db);
}
$db->free($resql);
}
}
} else {
$ref_supplier = $lines[$i]->ref_fourn;
Expand Down Expand Up @@ -1626,35 +1652,52 @@

$projectid = (!empty($objectsrc->fk_project) ? $objectsrc->fk_project : '');
$ref_client = (!empty($objectsrc->ref_client) ? $objectsrc->ref_client : '');
if ($origin == "commande") {
$cond_reglement_id = 0;
$mode_reglement_id = 0;
$delivery_date = '';
$objectsrc->note_private = '';
$objectsrc->note_public = '';
if ($societe = $object->thirdparty) {
$cond_reglement_id = $societe->cond_reglement_supplier_id;
$mode_reglement_id = $societe->mode_reglement_supplier_id;
if (isModEnabled("multicurrency")) {
$currency_code = $societe->multicurrency_code;
if (getDolGlobalString('MULTICURRENCY_USE_ORIGIN_TX')) {
$currency_tx = $societe->multicurrency_tx;
}
}
}
} else {
$soc = $objectsrc->thirdparty;

$soc = $objectsrc->thirdparty;

$cond_reglement_id = (!empty($objectsrc->cond_reglement_id) ? $objectsrc->cond_reglement_id : (!empty($soc->cond_reglement_id) ? $soc->cond_reglement_id : 0));
$mode_reglement_id = (!empty($objectsrc->mode_reglement_id) ? $objectsrc->mode_reglement_id : (!empty($soc->mode_reglement_id) ? $soc->mode_reglement_id : 0));
$fk_account = (!empty($objectsrc->fk_account) ? $objectsrc->fk_account : (!empty($soc->fk_account) ? $soc->fk_account : 0));
$availability_id = (!empty($objectsrc->availability_id) ? $objectsrc->availability_id : (!empty($soc->availability_id) ? $soc->availability_id : 0));
$shipping_method_id = (!empty($objectsrc->shipping_method_id) ? $objectsrc->shipping_method_id : (!empty($soc->shipping_method_id) ? $soc->shipping_method_id : 0));
$demand_reason_id = (!empty($objectsrc->demand_reason_id) ? $objectsrc->demand_reason_id : (!empty($soc->demand_reason_id) ? $soc->demand_reason_id : 0));
//$remise_percent = (!empty($objectsrc->remise_percent) ? $objectsrc->remise_percent : (!empty($soc->remise_supplier_percent) ? $soc->remise_supplier_percent : 0));
//$remise_absolue = (!empty($objectsrc->remise_absolue) ? $objectsrc->remise_absolue : (!empty($soc->remise_absolue) ? $soc->remise_absolue : 0));
$dateinvoice = !getDolGlobalString('MAIN_AUTOFILL_DATE') ? -1 : '';
$cond_reglement_id = (!empty($objectsrc->cond_reglement_id) ? $objectsrc->cond_reglement_id : (!empty($soc->cond_reglement_id) ? $soc->cond_reglement_id : 0));
$mode_reglement_id = (!empty($objectsrc->mode_reglement_id) ? $objectsrc->mode_reglement_id : (!empty($soc->mode_reglement_id) ? $soc->mode_reglement_id : 0));
$fk_account = (!empty($objectsrc->fk_account) ? $objectsrc->fk_account : (!empty($soc->fk_account) ? $soc->fk_account : 0));
$availability_id = (!empty($objectsrc->availability_id) ? $objectsrc->availability_id : (!empty($soc->availability_id) ? $soc->availability_id : 0));
$shipping_method_id = (!empty($objectsrc->shipping_method_id) ? $objectsrc->shipping_method_id : (!empty($soc->shipping_method_id) ? $soc->shipping_method_id : 0));
$demand_reason_id = (!empty($objectsrc->demand_reason_id) ? $objectsrc->demand_reason_id : (!empty($soc->demand_reason_id) ? $soc->demand_reason_id : 0));
//$remise_percent = (!empty($objectsrc->remise_percent) ? $objectsrc->remise_percent : (!empty($soc->remise_supplier_percent) ? $soc->remise_supplier_percent : 0));
//$remise_absolue = (!empty($objectsrc->remise_absolue) ? $objectsrc->remise_absolue : (!empty($soc->remise_absolue) ? $soc->remise_absolue : 0));
$dateinvoice = !getDolGlobalString('MAIN_AUTOFILL_DATE') ? -1 : '';

$datedelivery = (!empty($objectsrc->delivery_date) ? $objectsrc->delivery_date : '');
$datedelivery = (!empty($objectsrc->delivery_date) ? $objectsrc->delivery_date : '');

if (isModEnabled("multicurrency")) {
if (!empty($objectsrc->multicurrency_code)) {
$currency_code = $objectsrc->multicurrency_code;
}
if (getDolGlobalString('MULTICURRENCY_USE_ORIGIN_TX') && !empty($objectsrc->multicurrency_tx)) {
$currency_tx = $objectsrc->multicurrency_tx;
if (isModEnabled("multicurrency")) {
if (!empty($objectsrc->multicurrency_code)) {
$currency_code = $objectsrc->multicurrency_code;
}
if (getDolGlobalString('MULTICURRENCY_USE_ORIGIN_TX') && !empty($objectsrc->multicurrency_tx)) {
$currency_tx = $objectsrc->multicurrency_tx;
}
}
}

$note_private = $object->getDefaultCreateValueFor('note_private', (!empty($objectsrc->note_private) ? $objectsrc->note_private : null));
$note_public = $object->getDefaultCreateValueFor('note_public', (!empty($objectsrc->note_public) ? $objectsrc->note_public : null));
$note_private = $object->getDefaultCreateValueFor('note_private', (!empty($objectsrc->note_private) ? $objectsrc->note_private : null));
$note_public = $object->getDefaultCreateValueFor('note_public', (!empty($objectsrc->note_public) ? $objectsrc->note_public : null));

// Object source contacts list
$srccontactslist = $objectsrc->liste_contact(-1, 'external', 1);
// Object source contacts list
$srccontactslist = $objectsrc->liste_contact(-1, 'external', 1);
}
} else {
$cond_reglement_id = !empty($societe->cond_reglement_supplier_id) ? $societe->cond_reglement_supplier_id : 0;
$mode_reglement_id = !empty($societe->mode_reglement_supplier_id) ? $societe->mode_reglement_supplier_id : 0;
Expand Down