swiss number format

Questions related to using nuBuilder Forte.

swiss number format

Postby paulkauz » Mon Nov 09, 2020 6:53 pm

How can I create following format: CHF 9’956’000
In the Form it's possible to exchange the $ trough CHF, but how can I change the 1.000 trough 1'000
If you like nuBuilder, please leave a review on SourceForge
paulkauz
 
Posts: 27
Joined: Sat Oct 31, 2020 3:38 am

Re: swiss number format

Postby Janusz » Mon Nov 09, 2020 7:53 pm

In browse form for example you can use Format:

FORMAT(ofe_cena,2,'rm_CH')

swiss.png
swiss.png (4.79 KiB) Viewed 227 times
If you like nuBuilder, please leave a review on SourceForge
Janusz
 
Posts: 399
Joined: Fri Dec 28, 2018 10:11 pm
Location: Krakow, Poland

Re: swiss number format

Postby paulkauz » Mon Nov 09, 2020 8:10 pm

Thanks for the proposal, but where can I put that Format in?
If you like nuBuilder, please leave a review on SourceForge
paulkauz
 
Posts: 27
Joined: Sat Oct 31, 2020 3:38 am

Re: swiss number format

Postby Janusz » Mon Nov 09, 2020 9:03 pm

Put it in the
From / Browse / Display field
for example if you have there: ofe_cena
then replace with: FORMAT(ofe_cena,2,'rm_CH')

(this is OK with MariaDB)
If you like nuBuilder, please leave a review on SourceForge
Janusz
 
Posts: 399
Joined: Fri Dec 28, 2018 10:11 pm
Location: Krakow, Poland

Re: swiss number format

Postby kev1n » Mon Nov 09, 2020 9:20 pm

BTW, "rm_CH" is the ICU Locale of “Romansh (Switzerland)
You might want to use "de_CH" instead (even though the grouping separator is ' for both of them)
If you like nuBuilder, please leave a review on SourceForge

nuBuilder Code Library (82)
Installation Guides
Updating nuBuilder

Join Discord to talk about nuBuilder!
kev1n
 
Posts: 1084
Joined: Mon Oct 15, 2018 2:13 am

Re: swiss number format

Postby paulkauz » Mon Nov 09, 2020 9:44 pm

thanks so far and what about the edit part of a form?
how can I set there the right format?

BR Paul
Attachments
Bildschirmfoto 2020-11-09 um 13.09.24.png
Bildschirmfoto 2020-11-09 um 13.09.24.png (15.66 KiB) Viewed 208 times
If you like nuBuilder, please leave a review on SourceForge
paulkauz
 
Posts: 27
Joined: Sat Oct 31, 2020 3:38 am

Re: swiss number format

Postby Janusz » Tue Nov 10, 2020 5:40 am

Hi,
Please find enclosed short movie how you can add your own format.
https://drive.google.com/file/d/1wzEzVw ... sp=sharing
If you like nuBuilder, please leave a review on SourceForge
Janusz
 
Posts: 399
Joined: Fri Dec 28, 2018 10:11 pm
Location: Krakow, Poland

Re: swiss number format

Postby paulkauz » Tue Nov 10, 2020 8:35 pm

Perfect, I'll try that and I'm sure it will work. :D
If you like nuBuilder, please leave a review on SourceForge
paulkauz
 
Posts: 27
Joined: Sat Oct 31, 2020 3:38 am

Re: swiss number format

Postby kev1n » Tue Nov 10, 2020 9:23 pm

Here's another solution (Advantage: No JavaScript required)

Run this query in your database
Code: Select all
INSERT INTO `zzzzsys_format` (`zzzzsys_format_id`, `srm_type`, `srm_format`) VALUES ('5f4759ef6e2cec9', 'Number', 'CHF 1\'000.00');


Then replace the function nuPunctuation() in nucommon.php with this one:

Code: Select all
function nuPunctuation($f){

   $c         = '';
   $d         = '';
      
   if(strpos($f , '1,' ) !== false){
      $c      = ',';
   }

   if(strpos($f , '1.' ) !== false){
      $c      = '.';
   }

   if(strpos($f , '0,' ) !== false){
      $d      = ',';
   }

   if(strpos($f , '0.' ) !== false){
      $d      = '.';
   }

   if(strpos($f , '0\'' ) !== false){
      $d      = '\'';
   }
   
   return [$c, $d];
   
}


PS: Other changes will have to be done in nuAddFormatting() to make it work with negative amounts.
If you like nuBuilder, please leave a review on SourceForge

nuBuilder Code Library (82)
Installation Guides
Updating nuBuilder

Join Discord to talk about nuBuilder!
kev1n
 
Posts: 1084
Joined: Mon Oct 15, 2018 2:13 am

Re: swiss number format

Postby paulkauz » Wed Nov 11, 2020 3:41 am

Thanks for the quick help. It works like a charm on forms and I really appreciate it.
The solution with the new code in function nuPunctuation($f) does not work on reports.
If you like nuBuilder, please leave a review on SourceForge
paulkauz
 
Posts: 27
Joined: Sat Oct 31, 2020 3:38 am

Next

Return to General