Merge pull request #8082 from atm-maxime/new_order_min_amount

NEW order minimum amount
This commit is contained in:
Laurent Destailleur 2018-02-08 14:21:29 +01:00 committed by GitHub
commit e2cabd9be7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 72 additions and 5 deletions

View File

@ -176,6 +176,15 @@ if (empty($reshook))
$result=$object->update($object->id, $user);
if ($result < 0) setEventMessages($object->error, $object->errors, 'errors');
}
// update order min amount
if ($action == 'setorder_min_amount')
{
$object->fetch($id);
$object->order_min_amount=GETPOST('order_min_amount');
$result=$object->update($object->id, $user);
if ($result < 0) setEventMessages($object->error, $object->errors, 'errors');
}
if ($action == 'update_extras') {
$object->fetch($id);
@ -401,9 +410,19 @@ if ($object->id > 0)
print $form->editfieldval("OutstandingBill",'outstanding_limit',$object->outstanding_limit,$object,$user->rights->societe->creer,$limit_field_type,($object->outstanding_limit != '' ? price($object->outstanding_limit) : ''));
//if (empty($object->outstanding_limit)) print $langs->trans("NoLimit");
print '</td>';
print '</tr>';
print '<tr class="nowrap">';
print '<td>';
print $form->editfieldkey("OrderMinAmount",'order_min_amount',$object->order_min_amount,$object,$user->rights->societe->creer);
print '</td><td>';
print $form->editfieldval("OrderMinAmount",'order_min_amount',$object->order_min_amount,$object,$user->rights->societe->creer,$limit_field_type,($object->order_min_amount != '' ? price($object->order_min_amount) : ''));
print '</td>';
print '</tr>';
}
// Multiprice level
if (! empty($conf->global->PRODUIT_MULTIPRICES))

View File

@ -2391,8 +2391,12 @@ if ($action == 'create' && $user->rights->commande->creer)
}
// Total HT
$alert = '';
if($object->total_ht < $object->thirdparty->order_min_amount) {
$alert = ' ' . img_warning($langs->trans('OrderMinAmount').': '.price($object->thirdparty->order_min_amount));
}
print '<tr><td class="titlefieldmiddle">' . $langs->trans('AmountHT') . '</td>';
print '<td>' . price($object->total_ht, 1, '', 1, - 1, - 1, $conf->currency) . '</td>';
print '<td>' . price($object->total_ht, 1, '', 1, - 1, - 1, $conf->currency) . $alert . '</td>';
// Total VAT
print '<tr><td>' . $langs->trans('AmountVAT') . '</td><td>' . price($object->total_tva, 1, '', 1, - 1, - 1, $conf->currency) . '</td></tr>';

View File

@ -101,6 +101,16 @@ if (empty($reshook))
$result=$object->setPaymentMethods(GETPOST('mode_reglement_supplier_id','int'));
if ($result < 0) dol_print_error($db,$object->error);
}
// update supplier order min amount
if ($action == 'setsupplier_order_min_amount')
{
$object->fetch($id);
$object->supplier_order_min_amount=GETPOST('supplier_order_min_amount');
$result=$object->update($object->id, $user);
if ($result < 0) setEventMessages($object->error, $object->errors, 'errors');
}
if ($action == 'update_extras') {
$object->fetch($id);
@ -245,6 +255,16 @@ if ($object->id > 0)
}
print "</td>";
print '</tr>';
print '<tr class="nowrap">';
print '<td>';
print $form->editfieldkey("OrderMinAmount",'supplier_order_min_amount',$object->supplier_order_min_amount,$object,$user->rights->societe->creer);
print '</td><td>';
$limit_field_type = (! empty($conf->global->MAIN_USE_JQUERY_JEDITABLE)) ? 'numeric' : 'amount';
print $form->editfieldval("OrderMinAmount",'supplier_order_min_amount',$object->supplier_order_min_amount,$object,$user->rights->societe->creer,$limit_field_type,($object->supplier_order_min_amount != '' ? price($object->supplier_order_min_amount) : ''));
print '</td>';
print '</tr>';
// Categories
if (! empty($conf->categorie->enabled))

View File

@ -2052,8 +2052,12 @@ elseif (! empty($object->id))
}
// Total
$alert = '';
if($object->total_ht < $object->thirdparty->supplier_order_min_amount) {
$alert = ' ' . img_warning($langs->trans('OrderMinAmount').': '.price($object->thirdparty->supplier_order_min_amount));
}
print '<tr><td class="titlefieldmiddle">'.$langs->trans("AmountHT").'</td>';
print '<td>'.price($object->total_ht,'',$langs,1,-1,-1,$conf->currency).'</td>';
print '<td>'.price($object->total_ht,'',$langs,1,-1,-1,$conf->currency).$alert.'</td>';
print '</tr>';
// Total VAT

View File

@ -1,7 +1,7 @@
--
-- Be carefull to requests order.
-- This file must be loaded by calling /install/index.php page
-- when current version is 7.0.0 or higher.
-- when current version is 8.0.0 or higher.
--
-- To rename a table: ALTER TABLE llx_table RENAME TO llx_table_new;
-- To add a column: ALTER TABLE llx_table ADD COLUMN newcol varchar(60) NOT NULL DEFAULT '0' AFTER existingcol;
@ -23,11 +23,15 @@
-- Note: fields with type BLOB/TEXT can't have default value.
-- -- VPGSQL8.2 DELETE FROM llx_usergroup_user WHERE fk_user NOT IN (SELECT rowid from llx_user);
-- -- VMYSQL4.1 DELETE FROM llx_usergroup_user WHERE fk_usergroup NOT IN (SELECT rowid from llx_usergroup);
-- For 8.0
ALTER TABLE llx_societe ADD COLUMN fk_entrepot integer DEFAULT 0;
ALTER TABLE llx_projet ADD COLUMN bill_time integer DEFAULT 0;
ALTER TABLE llx_societe ADD COLUMN order_min_amount double(24,8) DEFAULT NULL AFTER outstanding_limit;
ALTER TABLE llx_societe ADD COLUMN supplier_order_min_amount double(24,8) DEFAULT NULL AFTER order_min_amount;
ALTER TABLE llx_projet ADD COLUMN bill_time integer DEFAULT 0;

View File

@ -92,6 +92,8 @@ create table llx_societe
fk_barcode_type integer NULL DEFAULT 0, -- barcode type
price_level integer NULL, -- level of price for multiprices
outstanding_limit double(24,8) DEFAULT NULL, -- allowed outstanding limit
order_min_amount double(24,8) DEFAULT NULL, -- min amount for orders
supplier_order_min_amount double(24,8) DEFAULT NULL, -- min amount for supplier orders
default_lang varchar(6), -- default language
logo varchar(255) DEFAULT NULL,
canvas varchar(32) DEFAULT NULL, -- type of canvas if used (null by default)

View File

@ -406,6 +406,7 @@ ProductsIntoElements=List of products/services into %s
CurrentOutstandingBill=Current outstanding bill
OutstandingBill=Max. for outstanding bill
OutstandingBillReached=Max. for outstanding bill reached
OrderMinAmount=Minimum amount for order
MonkeyNumRefModelDesc=Return numero with format %syymm-nnnn for customer code and %syymm-nnnn for supplier code where yy is year, mm is month and nnnn is a sequence with no break and no return to 0.
LeopardNumRefModelDesc=The code is free. This code can be modified at any time.
ManagingDirectors=Manager(s) name (CEO, director, president...)

View File

@ -334,6 +334,12 @@ class Societe extends CommonObject
*/
var $price_level;
var $outstanding_limit;
/**
* Min order amounts
*/
var $order_min_amount;
var $supplier_order_min_amount;
/**
* Id of sales representative to link (used for thirdparty creation). Not filled by a fetch, because we can have several sales representatives.
@ -785,6 +791,8 @@ class Societe extends CommonObject
$this->idprof6 = (! empty($this->idprof6)?trim($this->idprof6):'');
$this->prefix_comm = trim($this->prefix_comm);
$this->outstanding_limit = price2num($this->outstanding_limit);
$this->order_min_amount = price2num($this->order_min_amount);
$this->supplier_order_min_amount = price2num($this->supplier_order_min_amount);
$this->tva_assuj = trim($this->tva_assuj);
$this->tva_intra = dol_sanitizeFileName($this->tva_intra,'');
@ -960,6 +968,8 @@ class Societe extends CommonObject
$sql .= ",default_lang = ".(! empty($this->default_lang)?"'".$this->db->escape($this->default_lang)."'":"null");
$sql .= ",logo = ".(! empty($this->logo)?"'".$this->db->escape($this->logo)."'":"null");
$sql .= ",outstanding_limit= ".($this->outstanding_limit!=''?$this->outstanding_limit:'null');
$sql .= ",order_min_amount= ".($this->order_min_amount!=''?$this->order_min_amount:'null');
$sql .= ",supplier_order_min_amount= ".($this->supplier_order_min_amount!=''?$this->supplier_order_min_amount:'null');
$sql .= ",fk_prospectlevel='".$this->db->escape($this->fk_prospectlevel)."'";
$sql .= ",webservices_url = ".(! empty($this->webservices_url)?"'".$this->db->escape($this->webservices_url)."'":"null");
@ -1137,6 +1147,7 @@ class Societe extends CommonObject
$sql .= ', s.mode_reglement_supplier, s.cond_reglement_supplier, s.localtax1_assuj, s.localtax1_value, s.localtax2_assuj, s.localtax2_value, s.fk_prospectlevel, s.default_lang, s.logo';
$sql .= ', s.fk_shipping_method';
$sql .= ', s.outstanding_limit, s.import_key, s.canvas, s.fk_incoterms, s.location_incoterms';
$sql .= ', s.order_min_amount, s.supplier_order_min_amount';
$sql .= ', s.fk_multicurrency, s.multicurrency_code';
$sql .= ', fj.libelle as forme_juridique';
$sql .= ', e.libelle as effectif';
@ -1285,6 +1296,8 @@ class Societe extends CommonObject
$this->webservices_key = $obj->webservices_key;
$this->outstanding_limit = $obj->outstanding_limit;
$this->order_min_amount = $obj->order_min_amount;
$this->supplier_order_min_amount = $obj->supplier_order_min_amount;
// multiprix
$this->price_level = $obj->price_level;