We have a few needs to have a time field in Acumatica (PXDBInt as total minutes) to show the value to the user and allow the user to enter in a negative value. The standard formatting of the PXDBTimeSpanLong attribute doesn't allow a negative value to be entered or correctly displayed (db value or unbound formula value is negative already).
Has anyone created a custom class that inherits PXDBTimeSpanLongAttribute and been able to get a negative value to display and be entered? We are using the TimeSpanFormatType.ShortHoursMinutesCompact format which displays in hh:mm
Example user entries:
- "01:30" (1 hour and 30 minutes)
- "-02:45" (negative 2 hours and 45 minutes)
- "00:05" (5 minutes)
Sample DAC usage for PXDBTimeSpanLongAttribute:
public abstract class myTime : PX.Data.IBqlField
{
}
[PXDBTimeSpanLong(Format = TimeSpanFormatType.ShortHoursMinutesCompact)]
[PXUIField(DisplayName = "My Time")]
public virtual Int32? MyTime { get set; }
Testing the formatting using ShortHoursMinutesCompact
A positive value between "00:00" (int 0) and "23:59" (int 1439) works correctly
A negative number while stored in the database correctly is not correctly displayed (assuming the entry allows for negative entry). For example an expected "-02:45" (int -165) value results in a display of " 0:2 ". When I click in the field then click out the value is changed to "00:02" without entering any new value.
There is no field restriction from entering in a value greater than 24 hours even though the intent of the ShortHoursMinutesCompact format is a 24 hour entry. The field will allow and accept any value that fits the hh:mm format (values between "00:00" and "99:99"). When the user enters for example "29:00" the displayed value is changed to "05:00" but the database value is 1740 (29 hours as total minutes).