diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php
index 49f351be4c3..82a3c621db8 100644
--- a/htdocs/comm/card.php
+++ b/htdocs/comm/card.php
@@ -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 '';
+ print '';
+
+ print '
';
+ print '| ';
+ print $form->editfieldkey("OrderMinAmount",'order_min_amount',$object->order_min_amount,$object,$user->rights->societe->creer);
+ print ' | ';
+ 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 ' | ';
print '
';
}
+
// Multiprice level
if (! empty($conf->global->PRODUIT_MULTIPRICES))
diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php
index 24ab03c831a..6e1d411d55e 100644
--- a/htdocs/commande/card.php
+++ b/htdocs/commande/card.php
@@ -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 '| ' . $langs->trans('AmountHT') . ' | ';
- print '' . price($object->total_ht, 1, '', 1, - 1, - 1, $conf->currency) . ' | ';
+ print '' . price($object->total_ht, 1, '', 1, - 1, - 1, $conf->currency) . $alert . ' | ';
// Total VAT
print '
| ' . $langs->trans('AmountVAT') . ' | ' . price($object->total_tva, 1, '', 1, - 1, - 1, $conf->currency) . ' |
';
diff --git a/htdocs/fourn/card.php b/htdocs/fourn/card.php
index 724f90af228..6096ff03f9f 100644
--- a/htdocs/fourn/card.php
+++ b/htdocs/fourn/card.php
@@ -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 "";
print '';
+
+ print '';
+ print '| ';
+ print $form->editfieldkey("OrderMinAmount",'supplier_order_min_amount',$object->supplier_order_min_amount,$object,$user->rights->societe->creer);
+ print ' | ';
+ $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 ' | ';
+ print '
';
// Categories
if (! empty($conf->categorie->enabled))
diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php
index 617039f25da..81ea1a0f951 100644
--- a/htdocs/fourn/commande/card.php
+++ b/htdocs/fourn/commande/card.php
@@ -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 '| '.$langs->trans("AmountHT").' | ';
- print ''.price($object->total_ht,'',$langs,1,-1,-1,$conf->currency).' | ';
+ print ''.price($object->total_ht,'',$langs,1,-1,-1,$conf->currency).$alert.' | ';
print '
';
// Total VAT
diff --git a/htdocs/install/mysql/migration/7.0.0-8.0.0.sql b/htdocs/install/mysql/migration/7.0.0-8.0.0.sql
index 498d9226b2e..9bfe0bd2915 100644
--- a/htdocs/install/mysql/migration/7.0.0-8.0.0.sql
+++ b/htdocs/install/mysql/migration/7.0.0-8.0.0.sql
@@ -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;
\ No newline at end of file
diff --git a/htdocs/install/mysql/tables/llx_societe.sql b/htdocs/install/mysql/tables/llx_societe.sql
index f6ee1f39220..9ffb9734d7f 100644
--- a/htdocs/install/mysql/tables/llx_societe.sql
+++ b/htdocs/install/mysql/tables/llx_societe.sql
@@ -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)
diff --git a/htdocs/langs/en_US/companies.lang b/htdocs/langs/en_US/companies.lang
index c5bc84acaf8..77332a23d4b 100644
--- a/htdocs/langs/en_US/companies.lang
+++ b/htdocs/langs/en_US/companies.lang
@@ -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...)
diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php
index 44e95f4159b..fa3a6118672 100644
--- a/htdocs/societe/class/societe.class.php
+++ b/htdocs/societe/class/societe.class.php
@@ -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;