Solved

Summing time data in Acumatica

  • 1 June 2023
  • 4 replies
  • 153 views

Hi everyone,

Just recently learned how to customize projects in Acumatica. Have done a few things successfully; however, I’m currently stumped on summing time fields in acumatica. 

Currently trying to have a Total Mon,tues,wed,thurs,friday field displayed in the timecard screen.

I tried using the following PXFormula attribute to sum the hours in Mon field and place it into Monday total.

What I used:

[PXTimeList]
        [PXDBInt]
[PXFormula(typeof(SumCalc<EPTimeCardExt.usrMondayTotal>))]
[PXUIField(DisplayName = "Mon")]

I tried using this and well it completely broke the timecard screen. I tried this out based off what I saw online, but clearly I did something wrong.

On acumatica web page there is the following:

[PXFormula(
    null,
    typeof(SumCalc<Document.totalCost>))]
public virtual Decimal? ExtPrice { get; set; }
public abstract class extPrice : PX.Data.BQL.BqlDecimal.Field<extPrice> { }}

 

This was used to calculate total cost so I’m not sure if I should have used the PXFormula attribute below as a base instead.

Any help regarding this topic would be much appreciated :)

Kind regards,

 

Jacob

icon

Best answer by darylbowman 1 June 2023, 18:12

View original

4 replies

Badge +10

If I’m understanding the itellisense prompt correctly, the first parameter is used for simple math, while the second parameter is used in aggregate situations.

 

So try

[PXFormula(null, typeof(SumCalc<EPTimeCardExt.usrMondayTotal>))]

 

Userlevel 7
Badge +8

The first parameter works in the scope of the same DAC and its extensions but the second parameter aggregates from a child DAC field and puts the child DAC total to the parent DAC equivalent. I personally do not like the whole idea of creating messy headers with too many fields. When I have this much of fields in your case 7 (I have had much more closure to 60)  then I write a view delegate and at the end through the code I insert a dummy record to the grid that shows the total right under each column. It requires a bit of technicality but gives a very nice and neat presentation. If you search for PXView delegates in the source you can find a few sample but if you are new as I guess, then you will need to stick to adding that many fields to the header.

[PXFormula(null, typeof(SumCalc<EPTimeCardExt.usrMondayTotal>))]

@darylbowman Thanks for the advice with this, I was able to do what I wanted :)

@aaghaei Thanks for the response, I will keep this in mind.

I spoke a little too soon I did get it to work; however, I kept on running into an error message that I thought I could fix. Error message that says: An error occurred Specified cast is not valid..

Mon Field:

[PXTimeList]
        [PXDBInt]
[PXFormula(null, typeof(SumCalc<EPTimeCardExt.usrMondayTotal>))]
[PXUIField(DisplayName = "Mon")]

Monday Hours:

[PXInt]
[PXTimeList(30, 335, ExclusiveValues = false)]
[PXUIField(DisplayName = "Monday Hours", Enabled = false)]

Also tried PXDBInt for Monday hours.

After looking stuff up on the internet I think it might be because the Summary Dac doesn’t allow any customizations and that is why I keep getting an error message.

 

Reply


About Acumatica ERP system
Acumatica Cloud ERP provides the best business management solution for transforming your company to thrive in the new digital economy. Built on a future-proof platform with open architecture for rapid integrations, scalability, and ease of use, Acumatica delivers unparalleled value to small and midmarket organizations. Connected Business. Delivered.
© 2008 — 2024  Acumatica, Inc. All rights reserved