Lazarus

Programming => General => Topic started by: J-G on January 10, 2017, 05:41:43 pm

Title: Accountancy format of 'Floats'
Post by: J-G on January 10, 2017, 05:41:43 pm
This is not an 'Error' that I can't work around, just a question as to the possibility of adding a facility to FPC.

It is the practice of accountants to put negative values in brackets   viz.  -£20.00  would be listed as (20.00)  -  often in Red as well.

I'm writing an invoicing package and a credit is naturally negative so I wrote a procedure to format the value, (bracketed)  -   but of course conversion from real life to display on screen needs a FloatToStr(Value) and '(20.00)' is an invalid 'Float'.

I haven't done an extensive search so it is possible that there is already a function other than FloatToStr that will handle this. If not, is it a worthwhile addition?
Title: Re: Accountancy format of 'Floats'
Post by: molly on January 10, 2017, 06:00:57 pm
Indeed brackets around a number make it a non number by default (being it float or otherwise).

Try to look at it from the other end, namely the component that displays the value. What are you currently using for that ?

If those are simple numeric display components then you might be able to tweak those to display the number(s) as you'd like them to be displayed.

In the case of your floattostr example, you can replace that with your own function, make the negative check and return the value bracketed. The opposite can also be done in case you wish to stay consistent. Easier would be to create your own (record) type and use operators to convert from your format to a real float (and back again).
Title: Re: Accountancy format of 'Floats'
Post by: Eugene Loza on January 10, 2017, 06:29:21 pm
Maybe, trying StringReplace would do nice and easy?
I.e. (pseudocode)
Code: Pascal  [Select][+][-]
  1. function MyStrToFloat(inp: string): double;
  2. var s: string;
  3. begin
  4.   if pos('(',inp)>0 then begin
  5.     s := inp;
  6.     stringReplace(s,'(','',[rfReplaceAll]);
  7.     stringReplace(s,')','',[rfReplaceAll]);
  8.     result := - StrToFloat(s);
  9.   end
  10.   else
  11.     result := StrToFloat(inp);
  12. end;
Or a little more simple but less input error-proof :
Code: Pascal  [Select][+][-]
  1. function MyStrToFloat(inp: string): double;
  2. var s: string;
  3. begin
  4.   s := trim(inp)
  5.   if copy(inp,1,1)='(' then
  6.     result := - StrToFloat(copy(s,2,length(s)-2));
  7.   else
  8.     result := StrToFloat(s);
  9. end;
However, I see that http://www.freepascal.org/docs-html/rtl/sysutils/formatfloat.html can also work here, thou I've never used it for the exact task.
Title: Re: Accountancy format of 'Floats'
Post by: J-G on January 10, 2017, 06:33:08 pm
Indeed brackets around a number make it a non number by default (being it float or otherwise).

Try to look at it from the other end, namely the component that displays the value. What are you currently using for that ?
Indeed Molly - turn it on it's head  :)    - - -   I'm using a TEdit

If those are simple numeric display components then you might be able to tweak those to display the number(s) as you'd like them to be displayed.
Your phrase 'simple numeric display components' makes me think that there ARE edit components that don't use strings, but numbers, as the displayable property (ie, .text or .caption) but I've yet to discover any. (I have only been using Laz since mid August as you know  :) )

I do know about the 'NumbersOnly' property of TEdit but that doesn't work for me since I also consider '.', '-','+' and ' ' to be valid in numeric fields; and that property doesn't. In any case it still needs a string to display.

In the case of your floattostr example, you can replace that with your own function, make the negative check and return the value bracketed. The opposite can also be done in case you wish to stay consistent.
That is my 'work-around';

Easier would be to create your own (record) type and use operators to convert from your format to a real float (and back again).
That's an interesting possibility - - -  not that I have any real idea as to how to go about it!

Title: Re: Accountancy format of 'Floats'
Post by: Bart on January 10, 2017, 06:36:10 pm
Your phrase 'simple numeric display components' makes me think that there ARE edit components that don't use strings, but numbers, as the displayable property (ie, .text or .caption) but I've yet to discover any. (I have only been using Laz since mid August as you know  :) )

TFloatSpinEdit or TFloatSpinEditEx.

Bart
Title: Re: Accountancy format of 'Floats'
Post by: derek.john.evans on January 10, 2017, 06:47:28 pm
http://www.delphibasics.co.uk/RTL.asp?Name=NegCurrFormat

Code: Pascal  [Select][+][-]
  1.   DefaultFormatSettings.NegCurrFormat := 0;
  2.  
  3.   Format('%m', [-100.0]);
  4.  
  5.   FloatToStrF(-100.0, ffCurrency, 15, 0);    
  6.  

It doesn't work with FloatToStr() because the FloatFormat is set to ffGeneral:

From sysutils:
Code: Pascal  [Select][+][-]
  1. Function FloatToStr(Value: Currency; Const FormatSettings: TFormatSettings): String;
  2. Begin
  3.   Result := FloatToStrFIntl(Value, ffGeneral, 15, 0, fvCurrency,FormatSettings);
  4. End;  
  5.  

Unsure if this is a bug since I haven't got Delphi to test the "standard" behavior.
Title: Re: Accountancy format of 'Floats'
Post by: molly on January 10, 2017, 07:15:16 pm
I'm using a TEdit
In that case i am confused a little.

Why ? because that would mean, following your reasoning, that in case user inputs -15,00 it should be automagically displayed as (15,00) ?

That is confusing for end-user, to say the least.

But, perhaps you only want to allow different input (e.g. brackets would be automatically converted into the correct internal storage).

Quote
Your phrase 'simple numeric display components' makes me think that there ARE edit components that don't use strings
Don't worry about being new to Lazarus, we all were at one point :-) (i still am for that matter).

I asked because there are many 3th party components out there. For all i know you are just using a grid to display your values (which requires a somewhat different scenario).

Quote
In any case it still needs a string to display.
Of course but, it was not clear from your original question that you required both input and output. Different circumstance, different approach  :)

Just like Eugene, i never used formatfloat, but that seems like a good starting point (at least for displaying).

Quote
That's an interesting possibility - - -  not that I have any real idea as to how to go about it!
I'm still stuck with the need to do an explicit conversion. I thought that implicit conversion worked for record class operators (in opposite to global operators) so i must be (doing something) wrong there.

e.g. the best i can do atm would be something alike:
Code: Pascal  [Select][+][-]
  1. var
  2.   x : TAccountancyNumber;
  3. begin
  4.   WriteLn('x := ', String(x));
  5. end.
  6.  
Were the number x automatically displayed in brackets when negative and without brackets when positive. Also a string can be assigned to such TAccountacynumber and act on brackets being present (or not present).

In case you already are using your own conversion functions then there would be not much to gain. Stuffing things into your own (record) type helps a little with regards to 'hiding' things from plain sight but, that is all it does (and in hindsight i just could have use global operators for that).

Code: Pascal  [Select][+][-]
  1. program test;
  2.  
  3. {$MODE OBJFPC}{$H+}
  4. {$MODESWITCh ADVANCEDRECORDS}
  5.  
  6. Uses
  7.   SysUtils, StrUtils;
  8.  
  9. Type
  10.   TAccountancyNumber = record
  11.     class operator := (source: Double): TAccountancyNumber;
  12.     class operator := (source: TAccountancyNumber): String;
  13.     class operator := (source: String): TAccountancyNumber;
  14.    private
  15.     Number : Double;
  16.    public
  17.   end;
  18.  
  19. class operator TAccountancyNumber.:= (source: Double): TAccountancyNumber;
  20. begin
  21.   Result.Number := Source;
  22. end;
  23.  
  24. class operator TAccountancyNumber.:= (source: TAccountancyNumber): String;
  25. begin
  26.   if (Source.number < 0.0)
  27.   then Result := '(' + FloatToStr(Source.number) + ')'
  28.   else Result :=       FloatToStr(Source.number);
  29. end;
  30.  
  31. class operator TAccountancyNumber.:= (source: string): TAccountancyNumber;
  32. begin
  33.   if ( (LeftStr(source,1) = '(') and (RightStr(source,1) = ')') )
  34.   then Result.Number := -StrToFloat(TrimSet(source, ['(',')'] ) )
  35.   else Result.Number :=  StrToFloat(source)
  36. end;
  37.  
  38. var
  39.   k : double;
  40.   l : double;
  41.  
  42.   x : TAccountancyNumber;
  43.   y : TAccountancyNumber;
  44. begin
  45.   k := -25.00;
  46.   l := 30.00;
  47.   x := -15.00;
  48.   y := 138.00;
  49.   WriteLn('k := ', k);
  50.   WriteLn('l := ', l);
  51.   WriteLn('x := ', String(x));
  52.   WriteLn('y := ', String(y));
  53.   x := '(40)';
  54.   WriteLn('x := ', String(x));
  55. end.
  56.  
There are no details on precision as that is yours to decide. At least it shows a little how to go about such a thing (at least, i hope it does)

With regards tio your inputting. Perhaps a tmaskedit (http://lazarustutorials.blogspot.nl/2014/03/mask-edit-tutorial.html) would be able to help you out with regards to allowed input characters (at least it is one thing less to worry about).

edit: copy-paste error -> forgot to show switch and uses clause
Title: Re: Accountancy format of 'Floats'
Post by: J-G on January 10, 2017, 07:23:56 pm
Pretty much how I've done the work-around but you've taught me some new tricks Eugene, thanks
Code: Pascal  [Select][+][-]
  1.   if pos('(',inp)>0 then begin
I'm still using 
Code: Pascal  [Select][+][-]
  1. p := pos('(',inp);
  2. if p > 0 then  begin
which I remember from my TP days
Quote from: Eugene Loza
Or a little more simple but less input error-proof :
I don't have a problem with input checking, it would normally be '-20' rather than '(20)' and in fact that last would display an error. Once checked the display would change to £(20.00)
I did consider allowing '(20)' but that is 66% more work than '-20' and ease of use is more important than covering all potential input formats.
Quote from: Eugene Loza
However, I see that http://www.freepascal.org/docs-html/rtl/sysutils/formatfloat.html can also work here, thou I've never used it for the exact task.
That looks as if it would be OK but doesn't address the return to a value; which is where my issue really is.
Title: Re: Accountancy format of 'Floats'
Post by: J-G on January 10, 2017, 07:33:02 pm
Your phrase 'simple numeric display components' makes me think that there ARE edit components that don't use strings, but numbers, as the displayable property

TFloatSpinEdit TFloatSpinEditEx.

Bart

Ah  ---  I see that   TFloatSpinEdit   has 'Value' as a property but there is no way to not display the up/dn arrows which would look 'ugly' on an invoice form.

I can't find a component  TFloatSpinEditEx  to view the properties but I anticipate that the same issue would be present.
Title: Re: Accountancy format of 'Floats'
Post by: J-G on January 10, 2017, 07:52:15 pm
@ Molly
As usual a very fulsome reply thanks and some very useful pointers in there.

Perhaps my other replies (the forum responses are coming thick and fast - faster than I can evaluate and respond !! )  will give you a better insight as to what I'm attempting to achieve.

The point I was making about only using Laz since August was just that I haven't had time to evaluate all potential components - I'm working at it  :D

Your code regarding creating class operators is certainly interesting and does give me food for thought. It's way beyond my current knowledge but at one time so was printing - and I cracked that in a few hours!

I did look at TMaskEdit but again that looks 'ugly' on the screen with underlines and I don't really have a problem with input checking anyway, just recovering a value from a 'prettily' formatted TEdit.text  -  and that is only because I allow the freedom to input changes at any time and the conversions take place 'OnEditingDone'.

Title: Re: Accountancy format of 'Floats'
Post by: bylaardt on January 10, 2017, 08:53:06 pm
I am an accountant here in Brazil and and i prefer entry accounting data with two differents Tedits. It's reduce entry errors when doesn't need to input negative values.

Rethink the possibility of creating separate entry fields between debit and credit without negative entrys.

And the output formatting can be done by the difference of this fields.
Title: Re: Accountancy format of 'Floats'
Post by: J-G on January 10, 2017, 09:41:59 pm
I am an accountant here in Brazil and and i prefer entry accounting data with two differents Tedits. It's reduce entry errors when doesn't need to input negative values.

Rethink the possibility of creating separate entry fields between debit and credit without negative entrys.

And the output formatting can be done by the difference of this fields.

Your logic is very sound bylaardt and I would generally agree with you were I writing a program to be used in general commerce. In that case there certainly should be separate routines for Invoices and Credit Notes  -  and nere the twain should meet - but in this instance it's just for my own company use and I doubt that I'll raise more than 20 Invoices during a fiscal year. (I'm semi-retired).   It just happens that I made an error on an Invoice for a customer last year and only discovered it when they placed a new order yesterday. So, rather than spend time creating a 'Credit Note' process, I simply added a Credit Item with negative value to the new Invoice.

It was easy to show the value on the printed Invoice as £(20.00) since output to a printer is string anyway but I also wanted the screen to look 'right' - (in my opinion  :) ) - and that started my steep decent into negative float formatting !
Title: Re: Accountancy format of 'Floats'
Post by: GAN on January 10, 2017, 10:43:43 pm
I am an accountant here in Brazil and and i prefer entry accounting data with two differents Tedits. It's reduce entry errors when doesn't need to input negative values.

Rethink the possibility of creating separate entry fields between debit and credit without negative entrys.

And the output formatting can be done by the difference of this fields.

I do the same ;D

J-G I use jujiboutils package and could help you because have a value and format properties, take a look http://wiki.lazarus.freepascal.org/jujiboutils (http://wiki.lazarus.freepascal.org/jujiboutils)
Title: Re: Accountancy format of 'Floats'
Post by: J-G on January 11, 2017, 12:42:01 am
J-G I use jujiboutils package and could help you because have a value and format properties
I already have the jujiboutils package and have looked at the offerings there but all the FloatEdit components have a label which can't be hidden so totally useless for this application.
Title: Re: Accountancy format of 'Floats'
Post by: GAN on January 11, 2017, 12:54:47 am
J-G I use jujiboutils package and could help you because have a value and format properties
I already have the jujiboutils package and have looked at the offerings there but all the FloatEdit components have a label which can't be hidden so totally useless for this application.

To hide de label:

Code: Pascal  [Select][+][-]
  1. JLabeledFloatEdit1.EditLabel.Caption:='';

You can see the label in the form on desing time but when you run the program the label is hidden.
Title: Re: Accountancy format of 'Floats'
Post by: jujibo on January 11, 2017, 10:04:37 am
I already have the jujiboutils package and have looked at the offerings there but all the FloatEdit components have a label which can't be hidden so totally useless for this application.

To hide the label in code:

Code: Pascal  [Select][+][-]
  1. JLabeledFloatEdit1.EditLabel.Visible:= False;

To hide the label in design mode, simply type a blank space in property editor (Editlabel->Caption)

To read and set values, use the property Value:

Code: Pascal  [Select][+][-]
  1. JLabeledFloatEdit1.Value:= 10.5;
  2. f:= JLabeledFloatEdit2.Value;  
Title: Re: Accountancy format of 'Floats'
Post by: J-G on January 11, 2017, 12:28:29 pm
To hide the label in code:
Code: Pascal  [Select][+][-]
  1. JLabeledFloatEdit1.EditLabel.Visible:= False;
To hide the label in design mode, simply type a blank space in property editor (Editlabel->Caption)
Thanks for your input jujibo.
I thought I'd tried all the possibilities but not that one - yes it removes the Label
Quote from: jujibo
To read and set values, use the property Value:
Code: Pascal  [Select][+][-]
  1. JLabeledFloatEdit1.Value:= 10.5;
  2. f:= JLabeledFloatEdit2.Value;  
At design time it seems that there is no 'Value'  property so it cannot be set to 0.00 and although I've set the 'Decimals' to 2 and the DisplayFormat to '9999.99' or '####.##' , at run time, the display is [    nil] and although the component takes focus, it doesn't take keyboard entry. I've tried both FloatEdit and CurrencyEdit.

This is all very interesting for potential future development but it doesn't actually address the issue of taking the string (20.00) and converting it to the value -20 ... but Molly has addressed that very effectively  (even though I'm still working on the 'Understanding' of that code  :D )
Title: Re: Accountancy format of 'Floats'
Post by: jujibo on January 11, 2017, 12:57:55 pm
At design time it seems that there is no 'Value'  property so it cannot be set to 0.00 and although I've set the 'Decimals' to 2 and the DisplayFormat to '9999.99' or '####.##' , at run time, the display is [    nil] and although the component takes focus, it doesn't take keyboard entry. I've tried both FloatEdit and CurrencyEdit.
:D )

Yes, Value property is available at design time (see attached image).

This is all very interesting for potential future development but it doesn't actually address the issue of taking the string (20.00) and converting it to the value -20 ... but Molly has addressed that very effectively  (even though I'm still working on the 'Understanding' of that code  :D )

Do you want to display negative numbers like "(20)" for -20? or you really want to type (20) and being translated to -20?  For the first case would be easy to implement a new display property for negative numbers. For the second case, I don't see the utility but could be managed too.

Title: Re: Accountancy format of 'Floats'
Post by: jujibo on January 11, 2017, 01:40:05 pm

At design time it seems that there is no 'Value'  property so it cannot be set to 0.00 and although I've set the 'Decimals' to 2 and the DisplayFormat to '9999.99' or '####.##' , at run time, the display is [    nil] and although the component takes focus, it doesn't take keyboard entry. I've tried both FloatEdit and CurrencyEdit.
:D )

Are you sure you are using non DB components?  JLabeledFloatEdit instead of TJDBLabeledFloatEdit?

JujiboDB palette  components are DB Aware components.
We are talking about Jujibo palette components (non DB).
Title: Re: Accountancy format of 'Floats'
Post by: J-G on January 11, 2017, 01:44:12 pm
At design time it seems that there is no 'Value'  property
Yes, Value property is available at design time (see attached image).
Apologies, jujibo,  I had inadvertantly selected from the DB Version. Now I've checked the 'normal' package the components do work as expected and I can set the default value to 0.00.
Quote from: jujibo
Quote from: J-G
This is all very interesting for potential future development but it doesn't actually address the issue of taking the string (20.00) and converting it to the value -20 )

Do you want to display negative numbers like "(20)" for -20? or you really want to type (20) and being translated to -20?  For the first case would be easy to implement a new display property for negative numbers. For the second case, I don't see the utility but could be managed too.

The first case is exactly what I would like - and if the colour could also be set to red that would also be useful. There would be a small matter of display alignment since the trailing bracket should protrude beyond the 'pence' to keep the decimal point aligned.

 
Title: Re: Accountancy format of 'Floats'
Post by: jujibo on January 11, 2017, 01:54:17 pm
Quote from: J-G
The first case is exactly what I would like - and if the colour could also be set to red that would also be useful. There would be a small matter of display alignment since the trailing bracket should protrude beyond the 'pence' to keep the decimal point aligned. 

Well, I can implement two properties:

NegativeDisplayFormat (if empty it usesDisplayformat)
NegativeFontColor

About the gap because the parenthesis is not so easy... probably adding a space to DisplayFormat may be enough

Does this fit your needs?


Title: Re: Accountancy format of 'Floats'
Post by: J-G on January 11, 2017, 02:32:19 pm
Quote from: J-G
The first case is exactly what I would like - and if the colour could also be set to red that would also be useful. There would be a small matter of display alignment since the trailing bracket should protrude beyond the 'pence' to keep the decimal point aligned. 

Well, I can implement two properties:

NegativeDisplayFormat (if empty it usesDisplayformat)
NegativeFontColor

About the gap because the parenthesis is not so easy... probably adding a space to DisplayFormat may be enough

Does this fit your needs?
Mostly yes. 

The position could be left to the programmer - it would be a matter of setting the 'width' property of the component dependent upon the value being negative. That way the amount of 'shift' could be set in pixels rather than characters. It might be useful to make mention of this in the hints when the NegativeDisplayFormat is active.

The major issue I see is that taking a StrToFloat when the brackets are present should not be an error and I doubt that that is within your control and would still need a new version of StrToFloat.

Title: Re: Accountancy format of 'Floats'
Post by: jujibo on January 11, 2017, 06:13:23 pm
I have implemented in JLabeledCurrencyEdit  (just for testing)

Property: NegativeDisplayFormat
Property: NegativeColor

You can get it in latest lazarus-ccr svn code (rev 5629) . Get, compile and install.

Example to use it:

New Application. Drop two JLabeledCurrencyEdit components in the form.
Set DisplayFormat to: #,0.00€
Set NegativeDisplayFormat to:  (#,0.00)€
Set NegativeColor to: clRed
Set Alignment to: taRightJustify

Run the program. It will display 0.00€
type -5 after updated it will display in red: (5.00)€

You also can change default font color.

As you can see, there is no need for special StrToFloat.  :)
Title: Re: Accountancy format of 'Floats'
Post by: J-G on January 11, 2017, 07:19:46 pm
You can get it in latest lazarus-ccr svn code (rev 5629) . Get, compile and install.

As you can see, there is no need for special StrToFloat.  :)   

That looks to be a result  :)

Only problem I have is that I have no idea how to 'Get' rev 5629
Title: Re: Accountancy format of 'Floats'
Post by: molly on January 11, 2017, 08:11:27 pm
Only problem I have is that I have no idea how to 'Get' rev 5629
In case not using svn, you can point your browser to lazarus ccr svn on sourceforge (https://sourceforge.net/p/lazarus-ccr/svn/HEAD/tree/), then press the link "download snapshot" which will let sf generate a zip file for you which includes the latest (my time of writing that was rev. 5630).

fwiw:having a separate component is/was another option that would help your case the best way possible (i' just did not had the time to do it myself, so thank you very much jujibo).
Title: Re: Accountancy format of 'Floats'
Post by: J-G on January 11, 2017, 09:09:06 pm
Only problem I have is that I have no idea how to 'Get' rev 5629
In case not using svn, you can point your browser to lazarus ccr svn on sourceforge (https://sourceforge.net/p/lazarus-ccr/svn/HEAD/tree/), then press the link "download snapshot" which will let sf generate a zip file for you which includes the latest (my time of writing that was rev. 5630).

fwiw:having a separate component is/was another option that would help your case the best way possible (i' just did not had the time to do it myself, so thank you very much jujibo).

Thanks Molly.  That partially moves me forward but I'm now a little confused. (It's my age you know  ::)  )

I am downloading the snapshot but I was anticipating an update to the jujiboutils package which I could simply add to my existing installation of Laz 1.6 whereas I feel that I will have a new version of Lazarus.

Am I being a 'wuss' ?? :)
Title: Re: Accountancy format of 'Floats'
Post by: jujibo on January 11, 2017, 09:22:06 pm
I am downloading the snapshot but I was anticipating an update to the jujiboutils package which I could simply add to my existing installation of Laz 1.6 whereas I feel that I will have a new version of Lazarus.
Am I being a 'wuss' ?? :)

Sorry. I'll revert part of the commit.

The negative number display format was working in the earlier version (the version you had).

You only have to set the negative format as explained in the docs: http://www.freepascal.org/docs-html/rtl/sysutils/formatfloat.html    positiveformat;negativeformat;zeroformat

In this case, set DisplayFormat to: #,0.00€;(#,0.00)€
 :D

I'll modify all the components to allow custom color for negative values.

Title: Re: Accountancy format of 'Floats'
Post by: molly on January 11, 2017, 09:35:48 pm
I am downloading the snapshot but I was anticipating an update to the jujiboutils package which I could simply add to my existing installation of Laz 1.6 whereas I feel that I will have a new version of Lazarus.

Am I being a 'wuss' ?? :)
Either you know what version control does or you don't. Nothing "wuss" about that  :)

In case you have a svn client installed on your computer, you literally have a set of (commandline-)tools that allow you to download specific portions of the source-tree.

By downloading a snapshot, you've literally downloaded the complete source-tree. This includes all those other components that are present in the lazasrus ccr (and that are probably of no direct interest for you).

So, that makes up for the (relative) ridiculous huge size of the zip file (in case you only require jujibo's changes) :-)

The trick here is to extract only those portion from the zp file that you are interested in.

In case of jujiboutils, you can do with only extracting the folder lazarus-ccr-svn-5630\components\jujiboutils from the zip file and install the component from that sources, as any other package./component (at least it should. I am a bit confused about jujibo's reaction as that would indicate my directions won't work ?).
Title: Re: Accountancy format of 'Floats'
Post by: jujibo on January 11, 2017, 09:49:08 pm
...(at least it should. I am a bit confused about jujibo's reaction as that would indicate my directions won't work ?).

No Molly, your indications are ok  :).  I mean one of the new added properties is not needed because the functionality was there. I'll remove NegativeDisplayFormat property.

Title: Re: Accountancy format of 'Floats'
Post by: J-G on January 11, 2017, 10:00:01 pm
I am downloading the snapshot but I was anticipating an update to the jujiboutils package which I could simply add to my existing installation of Laz 1.6 whereas I feel that I will have a new version of Lazarus.

Am I being a 'wuss' ?? :)
Either you know what version control does or you don't. Nothing "wuss" about that  :)
Ah - a kindred spirit :)   even though I might feel like a wuss.

I often tell people "the only silly question is one that you already know the answer to"
Quote from: molly
In case you have a svn client installed on your computer, you literally have a set of (commandline-)tools that allow you to download specific portions of the source-tree.

By downloading a snapshot, you've literally downloaded the complete source-tree. This includes all those other components that are present in the lazasrus ccr (and that are probably of no direct interest for you).
Once I'd unzipped the download I could better see what I had and now have an understanding of the concept of version control.

I actually do have Tortoise installed but I've only used it once at the behest of lainz so I could have fired that up - if I had functioning grey-matter  :)

Quote from: molly
In case of jujiboutils, you can do with only extracting the folder lazarus-ccr-svn-5630\components\jujiboutils from the zip file and install the component from that sources, as any other package./component

I've found the jujiboutils folder so can simply re-add that package which I think will just over-write the existing version.

Quote from: molly
(at least it should. I am a bit confused about jujibo's reaction as that would indicate my directions won't work ?).
I've re-read jujibo's reaction (and the second response) and suspect that the version I now have may not be the best. Since there is no time pressure, I think my best bet is to wait 'til tomorrow and download again.

Title: Re: Accountancy format of 'Floats'
Post by: molly on January 11, 2017, 10:02:10 pm
@jujibo:
Thanks for the clarification. I did not took the time to see how you got things implemented, so was oblivious to portions that are already present or not.

@J-G:
I forgot to mention: make sure you've un-installed the previous version of jujibo utils before attempting to install the updated version from source.
Title: Re: Accountancy format of 'Floats'
Post by: J-G on January 11, 2017, 10:09:17 pm
@J-G:
I forgot to mention: make sure you've un-installed the previous version of jujibo utils before attempting to install the updated version from source.
Thanks Molly  -  that's a timely warning, I wouldn't have considered looking for an 'Uninstall Packages' option but I've now found it.
Title: Re: Accountancy format of 'Floats'
Post by: jujibo on January 12, 2017, 11:32:58 am
@J-G:

I have implemented custom color for negative values in every jujiboutils numeric component DB aware and non DB aware (integer, float and currency). Mask for negative value format was already working. You can download latest code from lazarus-ccr SVN

In your case, set DisplayFormat to: #,0.00€;(#,0.00)€  and NegativeColor to cl_red to get the desired result.

I suggest you to use currency components to deal with currency values instead of float one.
Title: Re: Accountancy format of 'Floats'
Post by: J-G on January 12, 2017, 12:09:16 pm
@J-G:
I have implemented custom color for negative values in every jujiboutils numeric component DB aware and non DB aware (integer, float and currency). Mask for negative value format was already working. You can download latest code from lazarus-ccr SVN
Thanks jujibo, I'm sure that will be useful for all users. When writing components of this nature it is difficult to foresee what other users may think is useful and great that you are in a position to take suggestions on board.

Quote from: jujibo
In your case, set DisplayFormat to: #,0.00€;(#,0.00)€  and NegativeColor to cl_red to get the desired result.

Since I am UK based and using the £ preceding the value, I presume that  £#,0.00;£(#,0.00) will work as well.

Quote from: jujibo
I suggest you to use currency components to deal with currency values instead of float one.
That would have been my intention as well, thanks.
Title: Re: Accountancy format of 'Floats'
Post by: jujibo on January 12, 2017, 12:35:27 pm
Thanks jujibo, I'm sure that will be useful for all users. When writing components of this nature it is difficult to foresee what other users may think is useful and great that you are in a position to take suggestions on board.

I'm open to suggestions to make it better.  ;)

Since I am UK based and using the £ preceding the value, I presume that  £#,0.00;£(#,0.00) will work as well.

Yes, look at the images.

The last one is using the mask: £#,0.00;£-(#,0.00)
Title: Re: Accountancy format of 'Floats'
Post by: GAN on January 12, 2017, 09:38:18 pm
@jujibo where i can download the last version? Thank you.

*Spanish: Hola, uso constantemente el componente que has desarrollado, podría decirse que son un fan de los componentes jujibo  :D y la verdad no entiendo nada ni de SVN ni trunk y quisiera contar con la última versión, uso Lazarus 1.6. Gracias por el excelente trabajo.
Saludos.
Title: Re: Accountancy format of 'Floats'
Post by: jujibo on January 13, 2017, 10:46:03 am
@jujibo where i can download the last version? Thank you.

You can download from Lazarus-CCR sourceforge page: https://sourceforge.net/p/lazarus-ccr/svn/HEAD/tree/  (Click on 'Download snapshot')

or click on this link:
https://sourceforge.net/code-snapshots/svn/l/la/lazarus-ccr/svn/lazarus-ccr-svn-5633.zip

It will dowload a 97,7Mb archive. Extract it. Components are in /lazarus-ccr-svn-5633/components/jujiboutils/ folder.

*Spanish: Hola, uso constantemente el componente que has desarrollado, podría decirse que son un fan de los componentes jujibo  :D y la verdad no entiendo nada ni de SVN ni trunk y quisiera contar con la última versión, uso Lazarus 1.6. Gracias por el excelente trabajo.
Saludos.

Hola GAN. Me alegro que te sean de utilidad los componentes. Cualquier consulta sobre su uso y sugerencias, no dudes en preguntar  :)

¡Un saludo!

Title: Re: Accountancy format of 'Floats'
Post by: GAN on January 13, 2017, 09:53:54 pm
Thanks a lot. I've downloaded from this link  https://sourceforge.net/p/lazarus-ccr/svn/HEAD/tree/  (https://sourceforge.net/p/lazarus-ccr/svn/HEAD/tree/) (The other link gives me 404 error).

Los componentes funcionan perfectos, como sugerencia se me ocurre valor máximo y mínimo tanto para fechas como para numéricos.

Saludos!
TinyPortal © 2005-2018