Help with script to meet date and content requirements(used to be imjamesw)

Hello All

I have a new handle
ADSPMO

In the continuing saga the requiements are getting tricky

http://www.experts-exchange.com/Applications/Email/Lotus_Notes/Q_20791200.html

The above link will take you to the previous question around this issue

One of the reuirements is for a field on the Leave Tracking named CarriedOverAH to contain any days off that maybe left over from the previous year.
The issue around this is it may not exceed five days and must be used by June 30

So when a new year starts and vacation is booked the first five or less days must come off the CarriedOverAH field after that it will subtract from the regular TotalAH field

I have included the script that I have thus far

If Not doc Is Nothing Then
 If note.type(0) = "Vac" Then
 doc.TotalDaysOffCalc = note.TotalDaysOff(0)
 doc.RemainingCalc = doc.TotalAH(0) - doc.TotalDaysOffCalc(0)
 End If
            
If note.type(0) = "Per" Then
 tmpPersonalDays =doc.PersonalDaysAH(0) - note.NewDaysTotal(0)      
 doc.PersonalDaysAH = tmpPersonalDays
 doc.TotalDaysOffCalc = note.TotalDaysOff(0)
 doc.RemainingCalc = doc.TotalAH(0) - doc.TotalDaysOffCalc(0)  
 End If

If note.type(0) = "WFH" Then
End If


Also I have come up with the following, I am note sure about how to add the requirements of subtracting the carried overdays first and they must be gone before July 1

tmpCarriedOver = doc.CarriedOverAH(0) - note.NewDaysTotal(0)      
doc.CarriedOverAH = tmpCarriedOver
doc.TotalDaysOffCalc = note.TotalDaysOff(0)
doc.RemainingCalc = doc.TotalAH(0) - doc.TotalDaysOffCalc(0)

Best Regards

James

formerly imjamesw
adspmoAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

HemanthaKumarCommented:
James

In previous question we did reduce total vaccation when leave is approved, we have to do some manipulation to accomodate the carriedover leave

I am still confused with your calculcation but anyway I will try

eg:
     If note.ApprovalStatus(0) = "Cancelled" Then  
          note.NewDaysTotal = 0    'This is the number of new days booked--- which will be 0 if it is not approved
          tmpTotal = 0
          Goto CalcIT
     End If

     tmpTotal = note.NewDaysTotal(0)

     if month(note.StartDate(0)) > 6 then
          tmpHolidaysAH = doc.HolidaysAH(0) 'This is the number of days used
     else
          if doc.CarriedOverAH(0) >= note.NewDaysTotal(0) then
               doc.CarriedOverAH = doc.CarriedOverAH(0) - note.NewDaysTotal(0)
               Goto SaveIt      ' Skip normal calc and save the doc
          else
               doc.CarriedOverAH = 0
               tmpTotal = note.NewDaysTotal(0) - doc.CarriedOverAH(0)
          end if
     end if

CalcIT:
          tmpNew = tmpHolidaysAH - tmpTotal  'This will reset the value removing the value that was added when approved
          tmpRemainingAH = doc.RemainingAH(0) ' This is the number of days remaining
          tmpRemain = tmpTotal + tmpRemainingAH ' This adds the number that was subtracted when the leave was approved
          doc.TotalDaysOffCalc = tmpNew 'This resets the Total days used    
          doc.RemainingCalc = tmpRemain 'This resets the remainig days to what it was prior to the new leave being approved
          doc.RemainingAH = doc.RemaingCalc 'See above
SaveIT:
     doc.ComputeWithForm True, False  
     doc.save True, False

~Hemanth
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
adspmoAuthor Commented:
Hi
What I did is in the queryave I put my conditions

bla bla bla Then Approve

Bla Bla Bla the Cancelled
In the Global I created Approved and Cancelled

I will modify the approve with what we CarriedOver first and then get to the cancelled

I will paste in the Approved script thus far

It is really important that he carried over days are used first and then from there the balance of available days will bee in the TotalAH field. I think you have adressed that with the script you provided

If note.type(0) = "Vac" And  Month(note.StartDate(0)) > 6 Then
                  doc.TotalDaysOffCalc = note.TotalDaysOff(0)
                  doc.RemainingCalc = doc.TotalAH(0) - doc.TotalDaysOffCalc(0)
            Else
                  If doc.CarriedOverAH(0) >= note.NewDaysTotal(0) Then
                        doc.CarriedOverAH = doc.CarriedOverAH(0) - note.NewDaysTotal(0)
                        Goto SaveIt      ' Skip normal calc and save the doc
                  End If
            End If
            
            If note.type(0) = "Per" Then
                  tmpPersonalDays =doc.PersonalDaysAH(0) - note.NewDaysTotal(0)      
                  doc.PersonalDaysAH = tmpPersonalDays
                  doc.TotalDaysOffCalc = note.TotalDaysOff(0)
                  doc.RemainingCalc = doc.TotalAH(0) - doc.TotalDaysOffCalc(0)  
            End If
            
            If note.type(0) = "WFH" Then
            End If
            
SaveIT:
            doc.ComputeWithForm True, False  
            doc.save True, False
0
HemanthaKumarCommented:
Yes that is what I did.. take care of CarriedOver leave first.. I will be mad if someone expires my CarriedOver leave :-)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Lotus IBM

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.