Fix price on takepos thumb must include vat

This commit is contained in:
Laurent Destailleur 2022-11-01 23:23:42 +01:00
parent b405caa96c
commit 75d784a6eb
5 changed files with 51 additions and 41 deletions

View File

@ -127,19 +127,23 @@ class Product extends CommonObject
public $type = self::TYPE_PRODUCT; public $type = self::TYPE_PRODUCT;
/** /**
* Selling price * Selling price without tax
* *
* @var float * @var float
*/ */
public $price; // Price net public $price;
public $price_formated; // used by takepos/ajax/ajax.php
/** /**
* Price with tax * Selling price with tax
* *
* @var float * @var float
*/ */
public $price_ttc; public $price_ttc;
public $price_ttc_formated; // used by takepos/ajax/ajax.php
/** /**
* Minimum price net * Minimum price net
* *

View File

@ -115,7 +115,7 @@ print '<tr class="oddeven"><td>';
print $langs->trans("NumberOfLinesToShow"); print $langs->trans("NumberOfLinesToShow");
print '<td colspan="2">'; print '<td colspan="2">';
$array = array(1=>"1", 2=>"2", 3=>"3", 4=>"4", 5=>"5", 6=>"6"); $array = array(1=>"1", 2=>"2", 3=>"3", 4=>"4", 5=>"5", 6=>"6");
print $form->selectarray('TAKEPOS_LINES_TO_SHOW', $array, (empty($conf->global->TAKEPOS_LINES_TO_SHOW) ? '2' : $conf->global->TAKEPOS_LINES_TO_SHOW), 0); print $form->selectarray('TAKEPOS_LINES_TO_SHOW', $array, getDolGlobalInt('TAKEPOS_LINES_TO_SHOW', 2), 0);
print "</td></tr>\n"; print "</td></tr>\n";
// D'ont display category // D'ont display category

View File

@ -84,7 +84,10 @@ if ($action == 'getProducts') {
} }
unset($prod->fields); unset($prod->fields);
unset($prod->db); unset($prod->db);
$prod->price_formated=price(price2num($prod->price, 'MU'), 1, $langs, 1, -1, -1, $conf->currency);
$prod->price_formated = price(price2num($prod->price, 'MT'), 1, $langs, 1, -1, -1, $conf->currency);
$prod->price_ttc_formated = price(price2num($prod->price_ttc, 'MT'), 1, $langs, 1, -1, -1, $conf->currency);
$res[] = $prod; $res[] = $prod;
} }
} }
@ -158,7 +161,7 @@ if ($action == 'getProducts') {
if (isset($barcode_value_list['ref'])) { if (isset($barcode_value_list['ref'])) {
// search product from reference // search product from reference
$sql = "SELECT rowid, ref, label, tosell, tobuy, barcode, price"; $sql = "SELECT rowid, ref, label, tosell, tobuy, barcode, price, price_ttc";
$sql .= " FROM " . $db->prefix() . "product as p"; $sql .= " FROM " . $db->prefix() . "product as p";
$sql .= " WHERE entity IN (" . getEntity('product') . ")"; $sql .= " WHERE entity IN (" . getEntity('product') . ")";
$sql .= " AND ref = '" . $db->escape($barcode_value_list['ref']) . "'"; $sql .= " AND ref = '" . $db->escape($barcode_value_list['ref']) . "'";
@ -207,6 +210,7 @@ if ($action == 'getProducts') {
'tobuy' => $obj->tobuy, 'tobuy' => $obj->tobuy,
'barcode' => $obj->barcode, 'barcode' => $obj->barcode,
'price' => $obj->price, 'price' => $obj->price,
'price_ttc' => $obj->price_ttc,
'object' => 'product', 'object' => 'product',
'img' => $ig, 'img' => $ig,
'qty' => $qty, 'qty' => $qty,
@ -223,7 +227,7 @@ if ($action == 'getProducts') {
} }
} }
$sql = 'SELECT p.rowid, p.ref, p.label, p.tosell, p.tobuy, p.barcode, p.price' ; $sql = 'SELECT p.rowid, p.ref, p.label, p.tosell, p.tobuy, p.barcode, p.price, p.price_ttc' ;
if (getDolGlobalInt('TAKEPOS_PRODUCT_IN_STOCK') == 1) { if (getDolGlobalInt('TAKEPOS_PRODUCT_IN_STOCK') == 1) {
$sql .= ', ps.reel'; $sql .= ', ps.reel';
} }
@ -299,10 +303,12 @@ if ($action == 'getProducts') {
'tobuy' => $obj->tobuy, 'tobuy' => $obj->tobuy,
'barcode' => $obj->barcode, 'barcode' => $obj->barcode,
'price' => $obj->price, 'price' => $obj->price,
'price_ttc' => $obj->price_ttc,
'object' => 'product', 'object' => 'product',
'img' => $ig, 'img' => $ig,
'qty' => 1, 'qty' => 1,
'price_formated' => price(price2num($obj->price, 'MU'), 1, $langs, 1, -1, -1, $conf->currency) 'price_formated' => price(price2num($obj->price, 'MT'), 1, $langs, 1, -1, -1, $conf->currency),
'price_ttc_formated' => price(price2num($obj->price_ttc, 'MT'), 1, $langs, 1, -1, -1, $conf->currency)
); );
// Add entries to row from hooks // Add entries to row from hooks
$parameters=array(); $parameters=array();

View File

@ -477,7 +477,7 @@ p.description_content{
div.description_content { div.description_content {
display: -webkit-box; display: -webkit-box;
-webkit-box-orient: vertical; -webkit-box-orient: vertical;
-webkit-line-clamp: <?php echo $conf->global->TAKEPOS_LINES_TO_SHOW; ?>; -webkit-line-clamp: <?php echo getDolGlobalInt('TAKEPOS_LINES_TO_SHOW', 2); ?>;
overflow: hidden; overflow: hidden;
padding-left: 2px; padding-left: 2px;
padding-right: 2px; padding-right: 2px;
@ -587,11 +587,11 @@ div#moreinfo, div#infowarehouse {
background: var(--colorbackhmenu1); background: var(--colorbackhmenu1);
color: var(--colortextbackhmenu); color: var(--colortextbackhmenu);
font-size: 2em; font-size: 2em;
padding: 5px; padding: 4px;
border-radius: 2px; border-radius: 2px;
opacity: 0.9; opacity: 0.9;
padding-left: 8px; padding-left: 6px;
padding-right: 8px; padding-right: 6px;
} }

View File

@ -367,7 +367,7 @@ function LoadProducts(position, issubcat) {
?> ?>
if (data[parseInt(idata)]['price_formated']) { if (data[parseInt(idata)]['price_formated']) {
$("#proprice"+ishow).attr("class", "productprice"); $("#proprice"+ishow).attr("class", "productprice");
$("#proprice"+ishow).html(data[parseInt(idata)]['price_formated']); $("#proprice"+ishow).html(data[parseInt(idata)]['price_ttc_formated']);
} }
console.log("#prodiv"+ishow+".data(rowid)="+data[idata]['id']); console.log("#prodiv"+ishow+".data(rowid)="+data[idata]['id']);
console.log($("#prodiv"+ishow)); console.log($("#prodiv"+ishow));
@ -449,7 +449,7 @@ function MoreProducts(moreorless) {
$("#probutton"+ishow).show(); $("#probutton"+ishow).show();
if (data[parseInt(idata)]['price_formated']) { if (data[parseInt(idata)]['price_formated']) {
$("#proprice"+ishow).attr("class", "productprice"); $("#proprice"+ishow).attr("class", "productprice");
$("#proprice"+ishow).html(data[parseInt(idata)]['price_formated']); $("#proprice"+ishow).html(data[parseInt(idata)]['price_ttc_formated']);
} }
$("#proimg"+ishow).attr("src","genimg/index.php?query=pro&id="+data[idata]['id']); $("#proimg"+ishow).attr("src","genimg/index.php?query=pro&id="+data[idata]['id']);
$("#prodiv"+ishow).data("rowid",data[idata]['id']); $("#prodiv"+ishow).data("rowid",data[idata]['id']);
@ -657,7 +657,7 @@ function Search2(keyCodeForEnter, moreorless) {
$("#probutton" + i).show(); $("#probutton" + i).show();
if (data[i]['price_formated']) { if (data[i]['price_formated']) {
$("#proprice" + i).attr("class", "productprice"); $("#proprice" + i).attr("class", "productprice");
$("#proprice" + i).html(data[i]['price_formated']); $("#proprice" + i).html(data[i]['price_ttc_formated']);
} }
$("#proimg" + i).attr("title", titlestring); $("#proimg" + i).attr("title", titlestring);
if( undefined !== data[i]['img']) { if( undefined !== data[i]['img']) {