home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / database / 8777 < prev    next >
Encoding:
Internet Message Format  |  1993-01-04  |  4.0 KB

  1. Path: sparky!uunet!hotmomma!brent!seth.esrig
  2. From: seth.esrig@brent.uucp (Seth Esrig) 
  3. Newsgroups: comp.databases
  4. Subject: Pls help: algorithm wante
  5. Message-ID: <2605.303.uupcb@brent.uucp>
  6. Date: 3 Jan 93 12:44:00 GMT
  7. Distribution: world
  8. Organization: The Brentwood BBS Harrison, NY  914-835-7898
  9. Reply-To: seth.esrig@brent.uucp (Seth Esrig) 
  10. Lines: 113
  11.  
  12. DV>I have an application that keeps track of subcontracts issued to outsiders.
  13. DV>For every subcontract, we have to receive various rate agreements.  The
  14. DV>subcontracts we issue usually span across multi years, but the rate
  15. DV>agreement we receive is always for one year, and renewed every year for the
  16. DV>duration of the contract.  The rate agreements can be provisional or
  17. DV>final.  We should at least have a provisional agreement on file, in order
  18. DV>to issue subcontract.  The rate agreement can be according the vendor's
  19. DV>fiscal year.
  20.  
  21. DV>When the user enters the subcontract start and end dates, the system has to
  22. DV>check the available rate agreements for the period, and summarize how the
  23. DV>various rate agreements cover the subcontract.
  24.  
  25. DV>For example, I have a subcontract for the period 01/01/92 - 12/31/94 (3
  26. DV>years).  I have the following rate agreements:
  27.  
  28. DV>Final  07/01/91 - 06/30/92
  29. DV>Final  07/01/92 - 06/30/93
  30. DV>Provl  07/01/93 - 12/31/93
  31. DV>Final  01/01/94 - 06/30/94
  32.  
  33. DV>The coverage report should look as follows:
  34.  
  35. DV>Subcontract Period: 01/01/92 - 12/31/94
  36.  
  37. DV>How Covered ?
  38.  
  39. DV>01/01/92 - 06/30/92 Final
  40. DV>07/01/92 - 06/30/93 Final
  41. DV>07/01/93 - 12/31/93 Provl
  42. DV>01/01/94 - 06/30/94 Final
  43. DV>07/01/94 - 12/31/94 Uncovered
  44.  
  45. DV>My problem:
  46. DV>I have all the individual agreements on a database.  When the user enters a
  47. DV>new subcontract, the system compares the contract period with the agreement
  48. DV>period to establish coverage or otherwise.  I am using foxpro, and a command
  49.  
  50. I haven't been using FoxPro for a couple of years, so I could only give
  51. you my R:Base program, using database CONTR and table AGREEMENTS. It
  52. works, and if you know anyone who knows both SQL or R:Base, and Foxpro,
  53. maybe they can create a Foxpro translation. I saw the posted FP code,
  54. and was surprised how compact and elegant it is. Maybe the database
  55. gurus raves were right:
  56.  
  57. cls
  58. set messages off
  59. connect contr
  60. set var vcont_start_date date
  61. set var vcont_end_date date
  62. fillin vcont_start_date=8 using ' subcontract start date: '
  63. fillin vcont_end_date=8 using ' subcontract end date: '
  64.  
  65. create view subagree as +
  66.   select agree_start_date, agree_end_date, status +
  67.     from agreements +
  68.       where agree_start_date < .vcont_end_date and +
  69.             agree_end_date > .vcont_start_date +
  70.         order by agree_start_date
  71.  
  72. declare datevars cursor for select agree_start_date, +
  73.   agree_end_date, status +
  74.     from subagree
  75. open datevars
  76.  
  77. set var vstart = .vcont_start_date
  78. set var vend = .vcont_end_date
  79. set var vrow = 1
  80. cls
  81. while sqlcode = 0 then
  82.    fetch datevars into vagree_start_date, vagree_end_date, +
  83.      vagree_status
  84.  
  85.    if sqlcode = 100 then
  86.      if vstart < .vcont_end_date then
  87.        write .vstart at .vrow, 5
  88.        write .vcont_end_date at .vrow, 15
  89.        write 'Uncovered at End' at .vrow, 25
  90.      endif
  91.      break
  92.    endif
  93.  
  94.    if vagree_start_date > .vstart then
  95.       write .vstart at .vrow, 5
  96.       set var vst = (.vagree_start_date - 1)
  97.       write .vst at .vrow, 15
  98.       write 'Uncovered' at .vrow, 25
  99.       set var vrow = (.vrow + 1)
  100.    endif
  101.  
  102.    if vagree_start_date < .vcont_start_date then
  103.       write .vcont_start_date at .vrow, 5
  104.    else
  105.       write .vagree_start_date at .vrow, 5
  106.    endif
  107.    if vagree_end_date > .vcont_end_date then
  108.       write .vcont_end_date at .vrow, 15
  109.    else
  110.       write .vagree_end_date at .vrow, 15
  111.    endif
  112.    write .vagree_status at .vrow, 25
  113.  
  114.    set var vrow = (.vrow + 1)
  115.    set var vstart = (.vagree_end_date + 1)
  116. endwhile
  117.  
  118. pause
  119. drop cursor datevars
  120. drop view subagree
  121.  
  122. ---
  123.  . SLMR 2.1a . Real programmers use CS majors at $4.25/hr.
  124.                                                                                                       
  125.