Skip to main content
Solved

Summing time data in Acumatica


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

Best answer by darylbowman

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>))]

 

View original
Did this topic help you find an answer to your question?

4 replies

darylbowman
Captain II
Forum|alt.badge.img+13

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>))]

 


aaghaei
Captain II
Forum|alt.badge.img+10
  • Captain II
  • 1204 replies
  • June 2, 2023

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


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings