Solved

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

Posted on 2003-11-11
3
172 Views
Last Modified: 2013-12-18
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
0
Comment
Question by:adspmo
  • 2
3 Comments
 
LVL 24

Accepted Solution

by:
HemanthaKumar earned 300 total points
Comment Utility
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
 

Author Comment

by:adspmo
Comment Utility
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
 
LVL 24

Expert Comment

by:HemanthaKumar
Comment Utility
Yes that is what I did.. take care of CarriedOver leave first.. I will be mad if someone expires my CarriedOver leave :-)
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Problem "Can you help me recover my changes?  I double-clicked the attachment, made changes, and then hit Save before closing it.  But when I try to re-open it, my changes are missing!"    Solution This solution opens the Outlook Secure Temp Fold…
Notes Document Link used by IBM Notes is a link file which aids in the sharing of links to documents in email and webpages. The posts describe the importance and steps to create a Lotus Notes NDL file in brief.
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now