DONE = 0 * * Get month from date * DIDITLOCK = .F. WASLCKCLRD = .F. DO WHILE DIDITLOCK = .F. DIDITLOCK = FLOCK() && Attempt to fix novell posting problem IF (DIDITLOCK = .F.) WAIT WINDOW "Some user has locked the g/l file. Please get them out. Press Any Key!" DO WRITEMSG WITH "Problem locking glaccts in postplus.prg","" WASLCKCLRD = .T. ENDIF ENDDO IF (WASLCKCLRD = .T.) DO WRITEMSG WITH "There was a retry on locking glaccts in postplus.prg but we got through!","" ENDIF DO WHILE .T. IF (GLACCTS->ACCT_TYPE <> DB_OR_CR) TMP_TOTAL = - MTOTAL ENDIF DO CASE CASE THE_MONTH = 1 IF YEAR(MPOST_DATE) = MCUR_YEAR && If posting to current year * * Note the current value * TMPSUM = GLACCTS->JAN * * Update the value * REPLACE GLACCTS->JAN WITH GLACCTS->JAN + TMP_TOTAL * * This condition should never be true, but we find that for some reason some * times it is! * IF (GLACCTS->JAN <> TMPSUM + TMP_TOTAL) DO WRITEMSG WITH "Total was wrong in postplus.prg ","" ENDIF ELSE REPLACE GLACCTS->NEXT_JAN WITH GLACCTS->NEXT_JAN + TMP_TOTAL ENDIF FLUSH && Need this for multiusers CASE THE_MONTH = 2 IF YEAR(MPOST_DATE) = MCUR_YEAR && If posting to current year TMPSUM = GLACCTS->FEB REPLACE GLACCTS->FEB WITH GLACCTS->FEB + TMP_TOTAL IF (GLACCTS->FEB <> TMPSUM + TMP_TOTAL) DO WRITEMSG WITH "Total was wrong in postplus.prg ","" ENDIF ELSE REPLACE GLACCTS->NEXT_FEB WITH GLACCTS->NEXT_FEB + TMP_TOTAL ENDIF FLUSH && Need this for multiusers CASE THE_MONTH = 3 IF YEAR(MPOST_DATE) = MCUR_YEAR && If posting to current year TMPSUM = GLACCTS->MAR REPLACE GLACCTS->MAR WITH GLACCTS->MAR + TMP_TOTAL IF (GLACCTS->MAR <> TMPSUM + TMP_TOTAL) DO WRITEMSG WITH "Total was wrong in postplus.prg ","" ENDIF ELSE REPLACE GLACCTS->NEXT_MAR WITH GLACCTS->NEXT_MAR + TMP_TOTAL ENDIF FLUSH && Need this for multiusers CASE THE_MONTH = 4 IF YEAR(MPOST_DATE) = MCUR_YEAR && If posting to current year TMPSUM = GLACCTS->APR REPLACE GLACCTS->APR WITH GLACCTS->APR + TMP_TOTAL IF (GLACCTS->APR <> TMPSUM + TMP_TOTAL) DO WRITEMSG WITH "Total was wrong in postplus.prg ","" ENDIF ELSE REPLACE GLACCTS->NEXT_APR WITH GLACCTS->NEXT_APR + TMP_TOTAL ENDIF FLUSH && Need this for multiusers CASE THE_MONTH = 5 IF YEAR(MPOST_DATE) = MCUR_YEAR && If posting to current year TMPSUM = GLACCTS->MAY REPLACE GLACCTS->MAY WITH GLACCTS->MAY + TMP_TOTAL IF (GLACCTS->MAY <> TMPSUM + TMP_TOTAL) DO WRITEMSG WITH "Total was wrong in postplus.prg ","" ENDIF ELSE REPLACE GLACCTS->NEXT_MAY WITH GLACCTS->NEXT_MAY + TMP_TOTAL ENDIF FLUSH && Need this for multiusers CASE THE_MONTH = 6 IF YEAR(MPOST_DATE) = MCUR_YEAR && If posting to current year TMPSUM = GLACCTS->JUN REPLACE GLACCTS->JUN WITH GLACCTS->JUN + TMP_TOTAL IF (GLACCTS->JUN <> TMPSUM + TMP_TOTAL) DO WRITEMSG WITH "Total was wrong in postplus.prg ","" ENDIF ELSE REPLACE GLACCTS->NEXT_JUN WITH GLACCTS->NEXT_JUN + TMP_TOTAL ENDIF FLUSH && Need this for multiusers CASE THE_MONTH = 7 IF YEAR(MPOST_DATE) = MCUR_YEAR && If posting to current year TMPSUM = GLACCTS->JUL REPLACE GLACCTS->JUL WITH GLACCTS->JUL + TMP_TOTAL IF (GLACCTS->JUL <> TMPSUM + TMP_TOTAL) DO WRITEMSG WITH "Total was wrong in postplus.prg ","" ENDIF ELSE REPLACE GLACCTS->NEXT_JUL WITH GLACCTS->NEXT_JUL + TMP_TOTAL ENDIF FLUSH && Need this for multiusers CASE THE_MONTH = 8 IF YEAR(MPOST_DATE) = MCUR_YEAR && If posting to current year TMPSUM = GLACCTS->AUG REPLACE GLACCTS->AUG WITH GLACCTS->AUG + TMP_TOTAL IF (GLACCTS->AUG <> TMPSUM + TMP_TOTAL) DO WRITEMSG WITH "Total was wrong in postplus.prg ","" ENDIF ELSE REPLACE GLACCTS->NEXT_AUG WITH GLACCTS->NEXT_AUG + TMP_TOTAL ENDIF FLUSH && Need this for multiusers CASE THE_MONTH = 9 IF YEAR(MPOST_DATE) = MCUR_YEAR && If posting to current year TMPSUM = GLACCTS->SEP REPLACE GLACCTS->SEP WITH GLACCTS->SEP + TMP_TOTAL IF (GLACCTS->SEP <> TMPSUM + TMP_TOTAL) DO WRITEMSG WITH "Total was wrong in postplus.prg ","" ENDIF ELSE REPLACE GLACCTS->NEXT_SEP WITH GLACCTS->NEXT_SEP + TMP_TOTAL ENDIF FLUSH && Need this for multiusers CASE THE_MONTH = 10 IF YEAR(MPOST_DATE) = MCUR_YEAR && If posting to current year TMPSUM = GLACCTS->OCT REPLACE GLACCTS->OCT WITH GLACCTS->OCT + TMP_TOTAL IF (GLACCTS->OCT <> TMPSUM + TMP_TOTAL) DO WRITEMSG WITH "Total was wrong in postplus.prg ","" ENDIF ELSE REPLACE GLACCTS->NEXT_OCT WITH GLACCTS->NEXT_OCT + TMP_TOTAL ENDIF FLUSH && Need this for multiusers CASE THE_MONTH = 11 IF YEAR(MPOST_DATE) = MCUR_YEAR && If posting to current year TMPSUM = GLACCTS->NOV REPLACE GLACCTS->NOV WITH GLACCTS->NOV + TMP_TOTAL IF (GLACCTS->NOV <> TMPSUM + TMP_TOTAL) DO WRITEMSG WITH "Total was wrong in postplus.prg ","" ENDIF ELSE REPLACE GLACCTS->NEXT_NOV WITH GLACCTS->NEXT_NOV + TMP_TOTAL ENDIF FLUSH && Need this for multiusers CASE THE_MONTH = 12 IF YEAR(MPOST_DATE) = MCUR_YEAR && If posting to current year TMPSUM = GLACCTS->DEC REPLACE GLACCTS->DEC WITH GLACCTS->DEC + TMP_TOTAL IF (GLACCTS->DEC <> TMPSUM + TMP_TOTAL) DO WRITEMSG WITH "Total was wrong in postplus.prg ","" ENDIF ELSE REPLACE GLACCTS->NEXT_DEC WITH GLACCTS->NEXT_DEC + TMP_TOTAL ENDIF FLUSH && Need this for multiusers ENDCASE * * If current month and year * IF MONTH(MPOST_DATE) = MCUR_MONTH .AND. YEAR(MPOST_DATE) = MCUR_YEAR && If posting current month and year REPLACE THIS_MONTH WITH THIS_MONTH + TMP_TOTAL,; THIS_YEAR WITH THIS_YEAR + TMP_TOTAL FLUSH && Need this for multiusers ENDIF DO SETBALANCE && Put totals into balance field IF DONE = 1 SET INDEX TO DELETE FILE &FN_IDX && Delete the temporary index SET INDEX TO GLACCTS && Restore index after using temporary index SEEK MACCT_NBR && Need this for manual checks postings to glpost UNLOCK IN GLACCTS RETURN ENDIF * * Update General Accounts That This Detailed Account Belongs To. * ACCT_NBR1 = INT(ACCT_NBR/100) ACCT_NBR1 = ACCT_NBR1*100 IF ACCT_NBR1 = ACCT_NBR2 && We have not found the next level up yet ACCT_NBR1 = INT(ACCT_NBR/10000) ACCT_NBR1 = ACCT_NBR1*10000 IF ACCT_NBR1 = ACCT_NBR2 && We have not found the next level up yet ACCT_NBR1 = INT(ACCT_NBR/1000000) ACCT_NBR1 = ACCT_NBR1*1000000 IF ACCT_NBR1 = ACCT_NBR2 && We have not found the next level up yet ACCT_NBR1 = INT(ACCT_NBR/10000000) ACCT_NBR1 = ACCT_NBR1*10000000 SEEK ACCT_NBR1 IF (.NOT. FOUND()) DO WRITEMSG WITH "Error 1 in postplus.prg","" ENDIF DONE = 1 ELSE SEEK ACCT_NBR1 IF (.NOT. FOUND()) DO WRITEMSG WITH "Error 2 in postplus.prg","" ENDIF ENDIF ELSE SEEK ACCT_NBR1 IF (.NOT. FOUND()) DO WRITEMSG WITH "Error 3 in postplus.prg","" ENDIF ENDIF ELSE SEEK ACCT_NBR1 IF (.NOT. FOUND()) DO WRITEMSG WITH "Error 4 in postplus.prg","" ENDIF ENDIF ACCT_NBR2 = ACCT_NBR1 && Setup for the next level up ENDDO UNLOCK IN GLACCTS