Topic: Print Invoice Example

Dimitry,
I was wondering if I could ask a favor of you. In your Customer Invoice example, could you demonstrate how to do calculations in the group-footer of the print invoice design. For example, say you have a discount rate stored in your client table and a tax rate also stored on the client table. After your summation of the invoice items, can you show the calculations for discount amt (sum * discount rate) and tax amt (sum * tax rate) and then the invoice total (sum - discount amt + tax amt). Thanks a bunch.

Re: Print Invoice Example

I made an example for you:

Post's attachments

Attachment icon invoiceEx.zip 23.85 kb, 1081 downloads since 2016-01-26 

Dmitry.

Re: Print Invoice Example

Thank you Dimitry. I see how you calculated within the summation expression. Let me ask you this. Suppose the discount is an amount stored on the client record rather than a rate. How would you subtract the discount amount from the total sum of the bill line items?

Re: Print Invoice Example

Do you want to see how much discount have each item?

Dmitry.

5 (edited by ehwagner 2016-01-28 17:30:34)

Re: Print Invoice Example

No. Just a total discount amount. And that amount should be subtracted from the total of the bill line items in the group footer.

Re: Print Invoice Example

ehwagner wrote:

No. Just a total discount amount. And that amount should be subtracted from the total of the bill line items in the group footer.

Discount: [SUM( 
(<Report."cost">*<Report."countserv">) * (<Report."discount"> / 100)
,MasterData1)]
Dmitry.

Re: Print Invoice Example

No, that's not what I am talking about. That's what you had in your example and for a discount rate that works fine. What I'm looking for is to subtract a flat discount amount for the client on the bill group footer, not a rate or percentage that gets calculated in the summation expression. This flat amount gets subtracted from the summation of the bill line items. It's not a subtraction on each line item. It's a subtraction of the line items sum. Hope this helps in explaining what I am looking for. I just do not know how to write the expression in the Fast Report syntax. Thank you Dimitry.

Re: Print Invoice Example

ehwagner wrote:

No, that's not what I am talking about. That's what you had in your example and for a discount rate that works fine. What I'm looking for is to subtract a flat discount amount for the client on the bill group footer, not a rate or percentage that gets calculated in the summation expression. This flat amount gets subtracted from the summation of the bill line items. It's not a subtraction on each line item. It's a subtraction of the line items sum. Hope this helps in explaining what I am looking for. I just do not know how to write the expression in the Fast Report syntax. Thank you Dimitry.

I made some changes, please download project again:

Post's attachments

Attachment icon invoiceEx2.zip 24.28 kb, 1026 downloads since 2016-01-28 

Dmitry.

Re: Print Invoice Example

Well Dimitry, your example works perfectly, but for the life of me I cannot see how it works. The expression you have for "Total with Discount" shows the following:
[SUM(

(<Report."cost">*<Report."countserv">) - ((<Report."cost">*<Report."countserv">) * <Report."discount"> / 100)

,MasterData1)]

What I don't understand is that nowhere in this expression does it mention the "Discount_flat", so how does the flat amount get subtracted when the report runs? I tested it and the flat amount does indeed get subtracted, but I don't see the actual expression which subtracts this flat amount. Help me understand. Thank you.

Re: Print Invoice Example

ehwagner
Look in the script of report

procedure Memo10OnAfterData(Sender: TfrxComponent);
begin
   Memo10.Text :=  formatfloat ('#,##0.00', Memo10.Value - Reportdiscount_flat.Value);
end;

procedure Memo12OnAfterData(Sender: TfrxComponent);
begin
       Memo12.Text :=  formatfloat ('#,##0.00', Memo12.Value - Reportdiscount_flat.Value);  
end;
Dmitry.

Re: Print Invoice Example

Wow, very good Dimitry. I had no idea you can do scripts within Fast Report. That certainly did the trick. Thank you for shedding light in that direction.  One thing that I noticed when messing around with it a little is that in order to show or use a value in the groupfooter it must be defined in the header. Am I correct in that assumption? The reason I say that is because I tried to define the value in the groupfooter and it does not work. It shows as zero. When I place it in the header then I can show it or calculate with it using a script in the groupfooter. Since I didn't want to show it in two places, I turned the visible property to false for the value in the header. However when the visible property is false, it does not show or work in calculations in the groupfooter. So what I did is changed the font to white for the value in the header to hide it. With doing that I can show the value in the groupfooter and I can use it in calculations (using a script of course). Don't know if that's what one is suppose to do, but it works for what I'm doing. Maybe there is a way to use variables instead.

Re: Print Invoice Example

ehwagner
For report system I used third-party component FastReport, unfortunately I don't know another way how to use a value in the groupfooter without  define value in the header. I read documentation but can't find nothing about that.


Thanks.

Dmitry.

Re: Print Invoice Example

Thanks.

JUST LEARNING, O GOD HELP ME.