VirtueMart Forum

VirtueMart 2 + 3 => Administration & Configuration => Topic started by: Za42 on November 23, 2015, 14:37:53 pm

Title: Round to nearest 5 / 10
Post by: Za42 on November 23, 2015, 14:37:53 pm
Hello there,

I was wondering if there is a way to round the discounted final sales price to the nearest 5 THB or nearest 10 THB.

Using the discount calculation is great, but I would prefer the final sales price to be in multiples of 5 THB.

Site is www.divegearthailand.com

Using Joomla 3.4.3, VM 3.0.9.4

All help much appreciated!
Title: Re: Round to nearest 5 / 10
Post by: GJC Web Design on November 23, 2015, 14:47:06 pm
never tried but heard a rumour that the VM config setting -> Use the Rappenrundung for Swiss CHF  -- rounds to 5/10..
Title: Re: Round to nearest 5 / 10
Post by: Milbo on November 27, 2015, 14:26:34 pm
to .00 or .05, yes
Title: Re: Round to nearest 5 / 10
Post by: GJC Web Design on November 28, 2015, 02:00:09 am
Did a bit of work on this...   Use the Rappenrundung for Swiss CHF  only affects the display

to get it to work on the actual amounts being used in calc (tax, the stored amounts etc) it needed a hack to the the administrator\components\com_virtuemart\helpers\calculationh.php

only use if $this->vendorCurrency_numeric==756 if Swiss francs

function roundInternal($value,$name = 0) {
if(!$this->_roundindig and $name!==0){
if($this->vendorCurrency_numeric==756 and VmConfig::get('rappenrundung',FALSE)=="1"){
//vmdebug('roundInternal rounding using rappenrundung');
return round((float)$value * 2,1) * 0.5;
}elseif(isset($this->_currencyDisplay->_priceConfig[$name][1])){
vmdebug('roundInternal rounding use '.$this->_currencyDisplay->_priceConfig[$name][1].' digits');
return round($value,$this->_currencyDisplay->_priceConfig[$name][1]);
} else {
vmdebug('roundInternal rounding not found for '.$name,$this->_currencyDisplay->_priceConfig[$name]);
return round($value, $this->_internalDigits);
}
} else {
return round($value, $this->_internalDigits);
}
}