AronGahagan / cpt-dev

Code repository for the ClearPlan Toolbar
https://www.ClearPlanConsulting.com
3 stars 1 forks source link

cptCostRateTables - handle when OvtRate or CostPerUse are empty #350

Closed AronGahagan closed 11 months ago

AronGahagan commented 11 months ago

Problem:

If OvertimeRate or CostPerUse are empty on the first PayRate item in a CostRateTable collection, the code fails.

299     If CDate(vEffectiveDate) > #1/1/1984# Then
300       oCostRateTable.PayRates.Add vEffectiveDate, vStdRate, vOvtRate, vCostPerUse
301     Else
302       oCostRateTable.PayRates(1).StandardRate = vStdRate
303       If Not IsEmpty(vOvtRate) Then oCostRateTable.PayRates(1).OvertimeRate = vOvtRate
304       If Not IsEmpty(vCostPerUse) Then oCostRateTable.PayRates(1).CostPerUse = vCostPerUse
305     End If

Solution:

    If CDate(vEffectiveDate) > #1/1/1984# Then
      Set oPayRate = oCostRateTable.PayRates.Add(vEffectiveDate, vStdRate)
    Else
      Set oPayRate = oCostRateTable.PayRates(1)
      oPayRate.StandardRate = vStdRate
    End If
    If Not IsEmpty(vOvtRate) Then oPayRate.OvertimeRate = vOvtRate
    If Not IsEmpty(vCostPerUse) Then oPayRate.CostPerUse = vCostPerUse

Todo: