Merge branch '10.0' of git@github.com:Dolibarr/dolibarr.git into 11.0
Conflicts: htdocs/categories/traduction.php htdocs/compta/facture/class/facture.class.php htdocs/contact/card.php htdocs/core/modules/modSociete.class.php htdocs/fourn/class/fournisseur.product.class.php htdocs/langs/en_US/products.lang htdocs/margin/agentMargins.php htdocs/margin/customerMargins.php htdocs/margin/productMargins.php htdocs/margin/tabs/productMargins.php htdocs/margin/tabs/thirdpartyMargins.php
This commit is contained in:
commit
9a08a6bf6d
@ -82,7 +82,7 @@ $cancel != $langs->trans("Cancel") &&
|
||||
// check parameters
|
||||
$forcelangprod = GETPOST('forcelangprod', 'alpha');
|
||||
$libelle = GETPOST('libelle', 'alpha');
|
||||
$desc = GETPOST('desc');
|
||||
$desc = GETPOST('desc', 'none');
|
||||
|
||||
if (empty($forcelangprod)) {
|
||||
$error++;
|
||||
@ -345,7 +345,7 @@ if ($action == 'add' && ($user->rights->produit->creer || $user->rights->service
|
||||
print $formadmin->select_language(GETPOST('forcelangprod', 'alpha'), 'forcelangprod', 0, $object->multilangs);
|
||||
print '</td></tr>';
|
||||
print '<tr><td class="fieldrequired">'.$langs->trans('Label').'</td>';
|
||||
print '<td><input name="libelle" size="40" value="'.GETPOST('libelle', 'alpha').'"></td></tr>';
|
||||
print '<td><input name="libelle" class="minwidth200 maxwidth300" value="'.GETPOST('libelle', 'alpha').'"></td></tr>';
|
||||
print '<tr><td>'.$langs->trans('Description').'</td><td>';
|
||||
$doleditor = new DolEditor('desc', GETPOST('desc', 'none'), '', 160, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, ROWS_3, '90%');
|
||||
$doleditor->Create();
|
||||
|
||||
@ -538,7 +538,6 @@ class Facture extends CommonInvoice
|
||||
$sql .= ", ".(empty($this->retained_warranty) ? "0" : $this->db->escape($this->retained_warranty));
|
||||
$sql .= ", ".(!empty($this->retained_warranty_date_limit) ? "'".$this->db->idate($this->retained_warranty_date_limit)."'" : 'NULL');
|
||||
$sql .= ", ".(int) $this->retained_warranty_fk_cond_reglement;
|
||||
|
||||
$sql .= ")";
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
|
||||
@ -1020,7 +1020,7 @@ else
|
||||
print '<tr><td><label for="state_id">'.$langs->trans('State').'</label></td><td colspan="3" class="maxwidthonsmartphone">';
|
||||
}
|
||||
|
||||
print $formcompany->select_state(GETPOSTISSET('state_id') ?GETPOST('state_id', 'alpha') : $object->state_id, $object->country_code, 'state_id');
|
||||
print $formcompany->select_state(GETPOSTISSET('state_id') ? GETPOST('state_id', 'alpha') : $object->state_id, $object->country_code, 'state_id');
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
|
||||
@ -467,7 +467,7 @@ class CMailFile
|
||||
} else {
|
||||
$this->message->setBody($msg, 'text/plain');
|
||||
// And optionally an alternative body
|
||||
$this->message->addPart($msg, 'text/html');
|
||||
$this->message->addPart(dol_nl2br($msg), 'text/html');
|
||||
}
|
||||
|
||||
if ($this->atleastonefile)
|
||||
|
||||
@ -98,7 +98,11 @@ class FormMargin
|
||||
|
||||
$pv = $line->total_ht;
|
||||
$pa_ht = ($pv < 0 ? - $line->pa_ht : $line->pa_ht); // We choosed to have line->pa_ht always positive in database, so we guess the correct sign
|
||||
$pa = $line->qty * $pa_ht;
|
||||
if ($object->type == Facture::TYPE_SITUATION) {
|
||||
$pa = $line->qty * $pa_ht * ($line->situation_percent / 100);
|
||||
} else {
|
||||
$pa = $line->qty * $pa_ht;
|
||||
}
|
||||
|
||||
// calcul des marges
|
||||
if (isset($line->fk_remise_except) && isset($conf->global->MARGIN_METHODE_FOR_DISCOUNT)) { // remise
|
||||
|
||||
@ -182,7 +182,7 @@ class modProduct extends DolibarrModules
|
||||
'p.accountancy_code_sell'=>"ProductAccountancySellCode", 'p.accountancy_code_sell_intra'=>"ProductAccountancySellIntraCode",
|
||||
'p.accountancy_code_sell_export'=>"ProductAccountancySellExportCode", 'p.accountancy_code_buy'=>"ProductAccountancyBuyCode",
|
||||
'p.note'=>"NotePrivate",'p.note_public'=>'NotePublic',
|
||||
'p.weight'=>"Weight", 'p.weight_units'=>"WeightUnits", 'p.length'=>"Length", 'p.width'=>"Width", 'p.height'=>"Height", 'p.length_units'=>"SizeUnits",
|
||||
'p.weight'=>"Weight", 'p.weight_units'=>"WeightUnits", 'p.length'=>"Length", 'p.length_units'=>"LengthUnits", 'p.width'=>"Width", 'p.width_units'=>"WidthUnits", 'p.height'=>"Height", 'p.height_units'=>"HeightUnits",
|
||||
'p.surface'=>"Surface", 'p.surface_units'=>"SurfaceUnits", 'p.volume'=>"Volume", 'p.volume_units'=>"VolumeUnits",
|
||||
'p.duration'=>"Duration",
|
||||
'p.finished' => 'Nature',
|
||||
@ -389,13 +389,13 @@ class modProduct extends DolibarrModules
|
||||
'p.weight' => "Weight",
|
||||
'p.weight_units' => "WeightUnits",
|
||||
'p.length' => "Length",
|
||||
'p.length_units' => "LengthUnit",
|
||||
'p.length_units' => "LengthUnits",
|
||||
'p.width' => "Width",
|
||||
'p.width_units' => "WidthUnits",
|
||||
'p.height' => "Height",
|
||||
'p.height_units' => "HeightUnit",
|
||||
'p.height_units' => "HeightUnits",
|
||||
'p.surface' => "Surface",
|
||||
'p.surface_units' => "SurfaceUnit",
|
||||
'p.surface_units' => "SurfaceUnits",
|
||||
'p.volume' => "Volume",
|
||||
'p.volume_units' => "VolumeUnits",
|
||||
'p.duration' => "Duration", //duration of service
|
||||
|
||||
@ -71,7 +71,7 @@ class modSociete extends DolibarrModules
|
||||
$this->requiredby = array("modExpedition", "modFacture", "modFournisseur", "modFicheinter", "modPropale", "modContrat", "modCommande"); // List of module ids to disable if this one is disabled
|
||||
$this->conflictwith = array(); // List of module class names as string this module is in conflict with
|
||||
$this->phpmin = array(5, 4); // Minimum version of PHP required by module
|
||||
$this->langfiles = array("companies", 'bills');
|
||||
$this->langfiles = array("companies", 'bills', "compta", "admin", "banks");
|
||||
|
||||
// Constants
|
||||
$this->const = array();
|
||||
@ -412,7 +412,7 @@ class modSociete extends DolibarrModules
|
||||
's.address' => "Address",
|
||||
's.zip' => "Zip",
|
||||
's.town' => "Town",
|
||||
's.fk_departement' => "StateId",
|
||||
's.fk_departement' => "StateCode",
|
||||
's.fk_pays' => "CountryCode",
|
||||
's.phone' => "Phone",
|
||||
's.fax' => "Fax",
|
||||
@ -583,7 +583,7 @@ class modSociete extends DolibarrModules
|
||||
's.address' => "Address",
|
||||
's.zip' => "Zip",
|
||||
's.town' => "Town",
|
||||
's.fk_departement' => "StateId",
|
||||
's.fk_departement' => "StateCode",
|
||||
's.fk_pays' => "CountryCode",
|
||||
's.birthday' => "BirthdayDate",
|
||||
's.poste' => "Role",
|
||||
|
||||
@ -69,7 +69,7 @@ class modUser extends DolibarrModules
|
||||
$this->requiredby = array(); // List of module ids to disable if this one is disabled
|
||||
$this->conflictwith = array(); // List of module class names as string this module is in conflict with
|
||||
$this->phpmin = array(5,4); // Minimum version of PHP required by module
|
||||
$this->langfiles = array("main","users","companies","members",'salaries');
|
||||
$this->langfiles = array("main","users","companies","members","salaries","hrm");
|
||||
$this->always_enabled = true; // Can't be disabled
|
||||
|
||||
// Constants
|
||||
@ -225,7 +225,7 @@ class modUser extends DolibarrModules
|
||||
'u.address'=>"Address",'u.zip'=>"Zip",'u.town'=>"Town",
|
||||
'u.office_phone'=>'Phone','u.user_mobile'=>"Mobile",'u.office_fax'=>'Fax',
|
||||
'u.email'=>"Email",'u.note'=>"Note",'u.signature'=>'Signature',
|
||||
'u.fk_user'=>'Supervisor','u.thm'=>'THM','u.tjm'=>'TJM','u.weeklyhours'=>'WeeklyHours',
|
||||
'u.fk_user'=>'HierarchicalResponsible','u.thm'=>'THM','u.tjm'=>'TJM','u.weeklyhours'=>'WeeklyHours',
|
||||
'u.dateemployment'=>'DateEmployment','u.salary'=>'Salary','u.color'=>'Color','u.api_key'=>'ApiKey',
|
||||
'u.birth'=>'BirthdayDate',
|
||||
'u.datec'=>"DateCreation",'u.tms'=>"DateLastModification",
|
||||
@ -281,7 +281,7 @@ class modUser extends DolibarrModules
|
||||
'u.fk_state'=>"StateId",'u.fk_country'=>"CountryCode",
|
||||
'u.office_phone'=>"Phone",'u.user_mobile'=>"Mobile",'u.office_fax'=>"Fax",
|
||||
'u.email'=>"Email",'u.note'=>"Note",'u.signature'=>'Signature',
|
||||
'u.fk_user'=>'Supervisor','u.thm'=>'THM','u.tjm'=>'TJM','u.weeklyhours'=>'WeeklyHours',
|
||||
'u.fk_user'=>'HierarchicalResponsible','u.thm'=>'THM','u.tjm'=>'TJM','u.weeklyhours'=>'WeeklyHours',
|
||||
'u.dateemployment'=>'DateEmployment','u.salary'=>'Salary','u.color'=>'Color','u.api_key'=>'ApiKey',
|
||||
'u.birth'=>'BirthdayDate',
|
||||
'u.datec'=>"DateCreation",
|
||||
|
||||
@ -1980,6 +1980,12 @@ class Expedition 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.'expedition SET fk_statut='.self::STATUS_CLOSED;
|
||||
|
||||
@ -943,8 +943,6 @@ class ProductFournisseur extends Product
|
||||
*/
|
||||
public function listProductFournisseurPriceLog($product_fourn_price_id, $sortfield = '', $sortorder = '', $limit = 0, $offset = 0)
|
||||
{
|
||||
global $conf;
|
||||
|
||||
$sql = "SELECT";
|
||||
$sql .= " pfpl.rowid, pfp.ref_fourn as supplier_ref, pfpl.datec, u.lastname,";
|
||||
$sql .= " pfpl.price, pfpl.quantity";
|
||||
@ -965,9 +963,17 @@ class ProductFournisseur extends Product
|
||||
{
|
||||
$retarray = array();
|
||||
|
||||
while ($record = $this->db->fetch_array($resql))
|
||||
while ($obj = $this->db->fetch_object($resql))
|
||||
{
|
||||
$retarray[] = $record;
|
||||
$tmparray = array();
|
||||
$tmparray['rowid'] = $obj->rowid;
|
||||
$tmparray['supplier_ref'] = $obj->supplier_ref;
|
||||
$tmparray['datec'] = $this->db->jdate($obj->datec);
|
||||
$tmparray['lastname'] = $obj->lastname;
|
||||
$tmparray['price'] = $obj->price;
|
||||
$tmparray['quantity'] = $obj->quantity;
|
||||
|
||||
$retarray[] = $tmparray;
|
||||
}
|
||||
|
||||
$this->db->free($resql);
|
||||
@ -995,7 +1001,7 @@ class ProductFournisseur extends Product
|
||||
$langs->load("suppliers");
|
||||
if (count($productFournLogList) > 0) {
|
||||
$out .= '<table class="nobordernopadding" width="100%">';
|
||||
$out .= '<tr><td class="liste_titre">'.$langs->trans("Date").'</td>';
|
||||
$out .= '<tr class="liste_titre"><td class="liste_titre">'.$langs->trans("Date").'</td>';
|
||||
$out .= '<td class="liste_titre right">'.$langs->trans("Price").'</td>';
|
||||
//$out .= '<td class="liste_titre right">'.$langs->trans("QtyMin").'</td>';
|
||||
$out .= '<td class="liste_titre">'.$langs->trans("User").'</td></tr>';
|
||||
@ -1036,7 +1042,7 @@ class ProductFournisseur extends Product
|
||||
|
||||
$logPrices = $this->listProductFournisseurPriceLog($this->product_fourn_price_id, 'pfpl.datec', 'DESC'); // set sort order here
|
||||
if (is_array($logPrices) && count($logPrices) > 0) {
|
||||
$label .= '<br>';
|
||||
$label .= '<br><br>';
|
||||
$label .= '<u>'.$langs->trans("History").'</u>';
|
||||
$label .= $this->displayPriceProductFournisseurLog($logPrices);
|
||||
}
|
||||
|
||||
@ -49,17 +49,13 @@ INSERT INTO llx_c_units (code, scale, label, short_label, unit_type, active) VAL
|
||||
INSERT INTO llx_c_units (code, scale, label, short_label, unit_type, active) VALUES ('L', '98','VolumeUnitlitre','L', 'volume', 1);
|
||||
INSERT INTO llx_c_units (code, scale, label, short_label, unit_type, active) VALUES ('GAL','99','VolumeUnitgallon','gal', 'volume', 1);
|
||||
|
||||
INSERT INTO llx_c_units (code, scale, label, short_label, unit_type, active) VALUES ('GAL','99','VolumeUnitgallon','gal', 'volume', 1);
|
||||
INSERT INTO llx_c_units (code, scale, label, short_label, unit_type, active) VALUES ('GAL','99','VolumeUnitgallon','gal', 'volume', 1);
|
||||
INSERT INTO llx_c_units (code, scale, label, short_label, unit_type, active) VALUES ('GAL','99','VolumeUnitgallon','gal', 'volume', 1);
|
||||
|
||||
INSERT INTO llx_c_units (code, scale, label, short_label, unit_type, active) VALUES ('P', '0','Piece','p', 'qty', 1);
|
||||
INSERT INTO llx_c_units (code, scale, label, short_label, unit_type, active) VALUES ('SET', '0','Set','set', 'qty', 1);
|
||||
|
||||
INSERT INTO llx_c_units (code, scale, label, short_label, unit_type, active) VALUES ('S', '0','second','s', 'time', 1);
|
||||
INSERT INTO llx_c_units (code, scale, label, short_label, unit_type, active) VALUES ('MI', '60','minute','i', 'time', 1);
|
||||
INSERT INTO llx_c_units (code, scale, label, short_label, unit_type, active) VALUES ('H', '3600','hour','h', 'time', 1);
|
||||
INSERT INTO llx_c_units (code, scale, label, short_label, unit_type, active) VALUES ('D','12960000','day','d', 'time', 1);
|
||||
INSERT INTO llx_c_units (code, scale, label, short_label, unit_type, active) VALUES ('D', '86400','day','d', 'time', 1);
|
||||
INSERT INTO llx_c_units (code, scale, label, short_label, unit_type, active) VALUES ('W', '604800','week','w', 'time', 1);
|
||||
INSERT INTO llx_c_units (code, scale, label, short_label, unit_type, active) VALUES ('MO','2629800','month','m', 'time', 1);
|
||||
INSERT INTO llx_c_units (code, scale, label, short_label, unit_type, active) VALUES ('Y','31557600','year','y', 'time', 1);
|
||||
|
||||
@ -285,7 +285,7 @@ CREATE TABLE llx_website_account(
|
||||
date_last_login datetime,
|
||||
date_previous_login datetime,
|
||||
date_creation datetime NOT NULL,
|
||||
tms timestamp NOT NULL,
|
||||
tms timestamp,
|
||||
fk_user_creat integer NOT NULL,
|
||||
fk_user_modif integer,
|
||||
import_key varchar(14),
|
||||
|
||||
@ -57,6 +57,7 @@ NatureOfThirdParty=Nature of Third party
|
||||
NatureOfContact=Nature of Contact
|
||||
Address=Address
|
||||
State=State/Province
|
||||
StateCode=State/Province code
|
||||
StateShort=State
|
||||
Region=Region
|
||||
Region-State=Region - State
|
||||
|
||||
@ -193,13 +193,38 @@ unitSET=Set
|
||||
unitS=Second
|
||||
unitH=Hour
|
||||
unitD=Day
|
||||
unitKG=Kilogram
|
||||
unitG=Gram
|
||||
unitM=Meter
|
||||
unitLM=Linear meter
|
||||
unitM2=Square meter
|
||||
unitM3=Cubic meter
|
||||
unitL=Liter
|
||||
unitT=ton
|
||||
unitKG=kg
|
||||
unitG=g
|
||||
unitMG=mg
|
||||
unitLB=pound
|
||||
unitOZ=ounce
|
||||
unitM=m
|
||||
unitDM=dm
|
||||
unitCM=cm
|
||||
unitMM=mm
|
||||
unitFT=ft
|
||||
unitIN=in
|
||||
unitM2=m²
|
||||
unitDM2=dm²
|
||||
unitCM2=cm²
|
||||
unitMM2=mm²
|
||||
unitFT2=ft²
|
||||
unitIN2=in²
|
||||
unitM3=m³
|
||||
unitDM3=dm³
|
||||
unitCM3=cm³
|
||||
unitMM3=mm³
|
||||
unitFT3=ft³
|
||||
unitIN3=in³
|
||||
unitOZ3=ounce
|
||||
unitgallon=gallon
|
||||
ProductCodeModel=Product ref template
|
||||
ServiceCodeModel=Service ref template
|
||||
CurrentProductPrice=Current price
|
||||
@ -292,6 +317,9 @@ ProductWeight=Weight for 1 product
|
||||
ProductVolume=Volume for 1 product
|
||||
WeightUnits=Weight unit
|
||||
VolumeUnits=Volume unit
|
||||
WidthUnits=Width unit
|
||||
LengthUnits=Length unit
|
||||
HeightUnits=Height unit
|
||||
SurfaceUnits=Surface unit
|
||||
SizeUnits=Size unit
|
||||
DeleteProductBuyPrice=Delete buying price
|
||||
@ -347,4 +375,4 @@ ErrorDestinationProductNotFound=Destination product not found
|
||||
ErrorProductCombinationNotFound=Product variant not found
|
||||
ActionAvailableOnVariantProductOnly=Action only available on the variant of product
|
||||
ProductsPricePerCustomer=Product prices per customers
|
||||
ProductSupplierExtraFields=Additional Attributes (Supplier Prices)
|
||||
ProductSupplierExtraFields=Additional Attributes (Supplier Prices)
|
||||
|
||||
@ -139,8 +139,8 @@ $sql .= " s.rowid as socid, s.nom as name, s.code_client, s.client,";
|
||||
$sql .= " u.rowid as agent, u.login, u.lastname, u.firstname,";
|
||||
$sql .= " sum(d.total_ht) as selling_price,";
|
||||
// Note: qty and buy_price_ht is always positive (if not your database may be corrupted, you can update this)
|
||||
$sql .= " sum(".$db->ifsql('d.total_ht < 0', 'd.qty * d.buy_price_ht * -1', 'd.qty * d.buy_price_ht').") as buying_price,";
|
||||
$sql .= " sum(".$db->ifsql('d.total_ht < 0', '-1 * (abs(d.total_ht) - (d.buy_price_ht * d.qty))', 'd.total_ht - (d.buy_price_ht * d.qty)').") as marge";
|
||||
$sql .= " sum(".$db->ifsql('d.total_ht < 0', 'd.qty * d.buy_price_ht * -1 * (d.situation_percent / 100)', 'd.qty * d.buy_price_ht * (d.situation_percent / 100)').") as buying_price,";
|
||||
$sql .= " sum(".$db->ifsql('d.total_ht < 0', '-1 * (abs(d.total_ht) - (d.buy_price_ht * d.qty * (d.situation_percent / 100)))', 'd.total_ht - (d.buy_price_ht * d.qty * (d.situation_percent / 100))').") as marge";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
|
||||
$sql .= ", ".MAIN_DB_PREFIX."facture as f";
|
||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."element_contact e ON e.element_id = f.rowid and e.statut = 4 and e.fk_c_type_contact = ".(empty($conf->global->AGENT_CONTACT_TYPE) ?-1 : $conf->global->AGENT_CONTACT_TYPE);
|
||||
|
||||
@ -204,8 +204,8 @@ $sql .= " s.rowid as socid, s.nom as name, s.code_client, s.client,";
|
||||
if ($client) $sql .= " f.rowid as facid, f.ref, f.total as total_ht, f.datef, f.paye, f.fk_statut as statut,";
|
||||
$sql .= " sum(d.total_ht) as selling_price,";
|
||||
// Note: qty and buy_price_ht is always positive (if not, your database may be corrupted, you can update this)
|
||||
$sql .= " sum(".$db->ifsql('d.total_ht < 0', 'd.qty * d.buy_price_ht * -1', 'd.qty * d.buy_price_ht').") as buying_price,";
|
||||
$sql .= " sum(".$db->ifsql('d.total_ht < 0', '-1 * (abs(d.total_ht) - (d.buy_price_ht * d.qty))', 'd.total_ht - (d.buy_price_ht * d.qty)').") as marge";
|
||||
$sql .= " sum(".$db->ifsql('d.total_ht < 0', 'd.qty * d.buy_price_ht * -1 * (d.situation_percent / 100)', 'd.qty * d.buy_price_ht * (d.situation_percent / 100)').") as buying_price,";
|
||||
$sql .= " sum(".$db->ifsql('d.total_ht < 0', '-1 * (abs(d.total_ht) - (d.buy_price_ht * d.qty * (d.situation_percent / 100)))', 'd.total_ht - (d.buy_price_ht * d.qty * (d.situation_percent / 100))').") as marge";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
|
||||
$sql .= ", ".MAIN_DB_PREFIX."facture as f";
|
||||
$sql .= ", ".MAIN_DB_PREFIX."facturedet as d";
|
||||
|
||||
@ -180,8 +180,8 @@ if ($id > 0) $sql .= " d.fk_product,";
|
||||
if ($id > 0) $sql .= " f.rowid as facid, f.ref, f.total as total_ht, f.datef, f.paye, f.fk_statut as statut,";
|
||||
$sql .= " SUM(d.total_ht) as selling_price,";
|
||||
// Note: qty and buy_price_ht is always positive (if not your database may be corrupted, you can update this)
|
||||
$sql .= " SUM(".$db->ifsql('d.total_ht < 0', 'd.qty * d.buy_price_ht * -1', 'd.qty * d.buy_price_ht').") as buying_price,";
|
||||
$sql .= " SUM(".$db->ifsql('d.total_ht < 0', '-1 * (abs(d.total_ht) - (d.buy_price_ht * d.qty))', 'd.total_ht - (d.buy_price_ht * d.qty)').") as marge";
|
||||
$sql .= " SUM(".$db->ifsql('d.total_ht < 0', 'd.qty * d.buy_price_ht * -1 * (d.situation_percent / 100)', 'd.qty * d.buy_price_ht * (d.situation_percent / 100)').") as buying_price,";
|
||||
$sql .= " SUM(".$db->ifsql('d.total_ht < 0', '-1 * (abs(d.total_ht) - (d.buy_price_ht * d.qty * (d.situation_percent / 100)))', 'd.total_ht - (d.buy_price_ht * d.qty * (d.situation_percent / 100))').") as marge";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
|
||||
$sql .= ", ".MAIN_DB_PREFIX."facture as f";
|
||||
$sql .= ", ".MAIN_DB_PREFIX."facturedet as d";
|
||||
|
||||
@ -137,8 +137,8 @@ if ($id > 0 || !empty($ref))
|
||||
if (!$user->rights->societe->client->voir && !$socid) $sql .= " sc.fk_soc, sc.fk_user,";
|
||||
$sql .= " sum(d.total_ht) as selling_price,"; // may be negative or positive
|
||||
$sql .= " ".$db->ifsql('f.type = 2', -1, 1)." * sum(d.qty) as qty,"; // not always positive in case of Credit note
|
||||
$sql .= " ".$db->ifsql('f.type = 2', -1, 1)." * sum(d.qty * d.buy_price_ht) as buying_price,"; // not always positive in case of Credit note
|
||||
$sql .= " ".$db->ifsql('f.type = 2', -1, 1)." * sum(abs(d.total_ht) - (d.buy_price_ht * d.qty)) as marge"; // not always positive in case of Credit note
|
||||
$sql .= " ".$db->ifsql('f.type = 2', -1, 1)." * sum(d.qty * d.buy_price_ht * (d.situation_percent / 100)) as buying_price,"; // not always positive in case of Credit note
|
||||
$sql .= " ".$db->ifsql('f.type = 2', -1, 1)." * sum(abs(d.total_ht) - (d.buy_price_ht * d.qty * (d.situation_percent / 100))) as marge"; // not always positive in case of Credit note
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
|
||||
$sql .= ", ".MAIN_DB_PREFIX."facture as f";
|
||||
$sql .= ", ".MAIN_DB_PREFIX."facturedet as d";
|
||||
|
||||
@ -147,8 +147,8 @@ if ($socid > 0)
|
||||
$sql .= " f.rowid as facid, f.ref, f.total as total_ht,";
|
||||
$sql .= " f.datef, f.paye, f.fk_statut as statut, f.type,";
|
||||
$sql .= " sum(d.total_ht) as selling_price,"; // may be negative or positive
|
||||
$sql .= " sum(d.qty * d.buy_price_ht) as buying_price,"; // always positive
|
||||
$sql .= " sum(abs(d.total_ht) - (d.buy_price_ht * d.qty)) as marge"; // always positive
|
||||
$sql .= " sum(d.qty * d.buy_price_ht * (d.situation_percent / 100)) as buying_price,"; // always positive
|
||||
$sql .= " sum(abs(d.total_ht) - (d.buy_price_ht * d.qty * (d.situation_percent / 100))) as marge"; // always positive
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
|
||||
$sql .= ", ".MAIN_DB_PREFIX."facture as f";
|
||||
$sql .= ", ".MAIN_DB_PREFIX."facturedet as d";
|
||||
|
||||
Loading…
Reference in New Issue
Block a user