ASU6JUPD ; IHS/ITSC/LMH -PROCESS CREDIT ADJUSTMENTS -37 ;
;;4.2T2;Supply Accounting Mgmt. System;;JUN 30, 2000
;;This routine provides logic to post (process) ADJUSTMENT
;;transactions to the database.
S:$G(DDSREFT)']"" DDSREFT=$G(ASUV("DDSREFT"))
I ASUT("TRCD")="37" D
.S ASUS("CLCD")=0 ;Value entered in transaction flag
.S:ASUT(ASUT,"VAL")="" ASUS("CLCD")=1 ;Value to be set by program
.D CAJRSET Q:$D(DDSERROR) ;Update Station master from transaction variables
.S ASUT(ASUT,"ACC")=ASUMX("ACC"),ASUT(ASUT,"CALCED")=ASUS("CLCD")
I ASUT("TRCD")="3P" D
.D QVINCRE ;Update Station master from transaction variables
I ASUT("TRCD")="2P" D
.D CAJRSET ;Update station master from transaction variables
I ASUT("TRCD")="27" D
.D DAJRSET ;Update Station master from transaction variables
Q:$D(DDSERROR)
D ^ASUJHIST ;Move transaction to History file
Q
DAJRSET ;EP; -RESETS TOTAL VALUE & TOTAL QUANTITY ON DEBIT ADJUSTMENTS
I ASUT(ASUT,"QTY")=""&(ASUT(ASUT,"VAL")]"") G CALCMST
I ASUT(ASUT,"VAL")=""&(ASUT(ASUT,"QTY")]"") N X S X="" D MSUNCST(.X)
I ASUT(ASUT,"VAL")']"" S ASUT(ASUT,"VAL")=X*ASUT(ASUT,"QTY")
CALCMST ;CALCULATE MASTER TOTAL
D QVINCRE
Q
CAJRSET ;EP; RESETS TOTAL VALUE & TOTAL QUANTITY ON CREDIT ADJUSTMENTS
I ASUT(ASUT,"QTY")']"" G CACKCS
I ASUT(ASUT,"VAL")']"" G CACKQT
G CACKCB
CACKQT ;CHECK QTY
I ASUT(ASUT,"QTY")>ASUMS("QTY","O/H") G RJCRBAL
I ASUT(ASUT,"QTY")=ASUMS("QTY","O/H") S ASUT(ASUT,"VAL")=ASUMS("VAL","O/H") G CACKAL
N X S X="" D MSUNCST(.X)
S ASUT(ASUT,"VAL")=X*ASUT(ASUT,"QTY")
I ASUT(ASUT,"VAL")>ASUMS("VAL","O/H") S ASUT(ASUT,"VAL")=ASUMS("VAL","O/H")
G CACKAL
CACKCS ;CHECK IF ONLY COST ENTERED
I ASUT(ASUT,"VAL")']"" G RJNOENTR
CACKCB ;CHECK IF CREDIT BALANCE
I ASUT(ASUT,"VAL")>ASUMS("VAL","O/H") G RJCRBAL
CACKAL ;CHECK BALANCES
S ASUMS("QTY","O/H")=ASUMS("QTY","O/H")-ASUT(ASUT,"QTY")
S ASUMS("VAL","O/H")=ASUMS("VAL","O/H")-ASUT(ASUT,"VAL")
I ASUMS("QTY","O/H")=0 G CACKV0
I ASUMS("QTY","O/H")<0 G RJCRBAL
I ASUMS("VAL","O/H")=0!(ASUMS("VAL","O/H")<0) G REJBOH
G STAUPDT
CACKV0 ;CHECK VALUE ZERO
I ASUMS("VAL","O/H")=0 G STAUPDT
G REJBOH
MSUNCST(X) ;EP ;COMPUTE UNIT COST FROM MASTER
I 0=+ASUMS("VAL","O/H")!(0=+ASUMS("QTY","O/H")) D
.S X=0
E D
.S X=$FN(ASUMS("VAL","O/H")/ASUMS("QTY","O/H"),"-",2)
I ASUT("TRCD")=27 S:X=0 X=ASUMS("LPP")
Q
QVDECRE ;EP;.
S ASUMS("VAL","O/H")=ASUMS("VAL","O/H")-ASUT(ASUT,"VAL")
S ASUMS("QTY","O/H")=ASUMS("QTY","O/H")-ASUT(ASUT,"QTY")
I ASUT("TRCD")="2P" G QVDCK0
G STAUPDT
QVDCK0 ;
I ASUMS("VAL","O/H")<0 G RJCRBAL
I ASUMS("QTY","O/H")<0 G RJCRBAL
I ASUMS("VAL","O/H")=0&(ASUMS("QTY","O/H")>0) G REJBOH
I ASUMS("QTY","O/H")=0&(ASUMS("VAL","O/H")>0) G REJBOH
G STAUPDT
QVINCRE ;EP;.
S ASUMS("VAL","O/H")=ASUMS("VAL","O/H")+ASUT(ASUT,"VAL")
S ASUMS("QTY","O/H")=ASUMS("QTY","O/H")+ASUT(ASUT,"QTY")
STAUPDT ;
D MIX^ASUMSTWR
Q
REJBOH ;REJECT BALANCE ON HAND
N Z S Z="Master Balance on Hand" D MSG^ASUJHELP(.Z) S DDSERROR=1 ;DFM P1 9/1/98
G REJECT
RJCRBAL ;REJECT CREDIT BALANCE
N Z S Z="Would create Master Credit Balance" D MSG^ASUJHELP(.Z) S DDSERROR=2 ;DFM P1 9/1/98
G REJECT
RJNOENTR ;REJECT NO ENTRY
N Z S Z="NO QTY OR VAL" D MSG^ASUJHELP(.Z) S DDSERROR=3 ;DFM P1 9/1/98
REJECT ;REJECT REPORT
Q
ASU6JUPD ; IHS/ITSC/LMH -PROCESS CREDIT ADJUSTMENTS -37 ;
+1 ;;4.2T2;Supply Accounting Mgmt. System;;JUN 30, 2000
+2 ;;This routine provides logic to post (process) ADJUSTMENT
+3 ;;transactions to the database.
+4 IF $GET(DDSREFT)']""
SET DDSREFT=$GET(ASUV("DDSREFT"))
+5 IF ASUT("TRCD")="37"
Begin DoDot:1
+6 ;Value entered in transaction flag
SET ASUS("CLCD")=0
+7 ;Value to be set by program
IF ASUT(ASUT,"VAL")=""
SET ASUS("CLCD")=1
+8 ;Update Station master from transaction variables
DO CAJRSET
IF $DATA(DDSERROR)
QUIT
+9 SET ASUT(ASUT,"ACC")=ASUMX("ACC")
SET ASUT(ASUT,"CALCED")=ASUS("CLCD")
End DoDot:1
+10 IF ASUT("TRCD")="3P"
Begin DoDot:1
+11 ;Update Station master from transaction variables
DO QVINCRE
End DoDot:1
+12 IF ASUT("TRCD")="2P"
Begin DoDot:1
+13 ;Update station master from transaction variables
DO CAJRSET
End DoDot:1
+14 IF ASUT("TRCD")="27"
Begin DoDot:1
+15 ;Update Station master from transaction variables
DO DAJRSET
End DoDot:1
+16 IF $DATA(DDSERROR)
QUIT
+17 ;Move transaction to History file
DO ^ASUJHIST
+18 QUIT
DAJRSET ;EP; -RESETS TOTAL VALUE & TOTAL QUANTITY ON DEBIT ADJUSTMENTS
+1 IF ASUT(ASUT,"QTY")=""&(ASUT(ASUT,"VAL")]"")
GOTO CALCMST
+2 IF ASUT(ASUT,"VAL")=""&(ASUT(ASUT,"QTY")]"")
NEW X
SET X=""
DO MSUNCST(.X)
+3 IF ASUT(ASUT,"VAL")']""
SET ASUT(ASUT,"VAL")=X*ASUT(ASUT,"QTY")
CALCMST ;CALCULATE MASTER TOTAL
+1 DO QVINCRE
+2 QUIT
CAJRSET ;EP; RESETS TOTAL VALUE & TOTAL QUANTITY ON CREDIT ADJUSTMENTS
+1 IF ASUT(ASUT,"QTY")']""
GOTO CACKCS
+2 IF ASUT(ASUT,"VAL")']""
GOTO CACKQT
+3 GOTO CACKCB
CACKQT ;CHECK QTY
+1 IF ASUT(ASUT,"QTY")>ASUMS("QTY","O/H")
GOTO RJCRBAL
+2 IF ASUT(ASUT,"QTY")=ASUMS("QTY","O/H")
SET ASUT(ASUT,"VAL")=ASUMS("VAL","O/H")
GOTO CACKAL
+3 NEW X
SET X=""
DO MSUNCST(.X)
+4 SET ASUT(ASUT,"VAL")=X*ASUT(ASUT,"QTY")
+5 IF ASUT(ASUT,"VAL")>ASUMS("VAL","O/H")
SET ASUT(ASUT,"VAL")=ASUMS("VAL","O/H")
+6 GOTO CACKAL
CACKCS ;CHECK IF ONLY COST ENTERED
+1 IF ASUT(ASUT,"VAL")']""
GOTO RJNOENTR
CACKCB ;CHECK IF CREDIT BALANCE
+1 IF ASUT(ASUT,"VAL")>ASUMS("VAL","O/H")
GOTO RJCRBAL
CACKAL ;CHECK BALANCES
+1 SET ASUMS("QTY","O/H")=ASUMS("QTY","O/H")-ASUT(ASUT,"QTY")
+2 SET ASUMS("VAL","O/H")=ASUMS("VAL","O/H")-ASUT(ASUT,"VAL")
+3 IF ASUMS("QTY","O/H")=0
GOTO CACKV0
+4 IF ASUMS("QTY","O/H")<0
GOTO RJCRBAL
+5 IF ASUMS("VAL","O/H")=0!(ASUMS("VAL","O/H")<0)
GOTO REJBOH
+6 GOTO STAUPDT
CACKV0 ;CHECK VALUE ZERO
+1 IF ASUMS("VAL","O/H")=0
GOTO STAUPDT
+2 GOTO REJBOH
MSUNCST(X) ;EP ;COMPUTE UNIT COST FROM MASTER
+1 IF 0=+ASUMS("VAL","O/H")!(0=+ASUMS("QTY","O/H"))
Begin DoDot:1
+2 SET X=0
End DoDot:1
+3 IF '$TEST
Begin DoDot:1
+4 SET X=$FNUMBER(ASUMS("VAL","O/H")/ASUMS("QTY","O/H"),"-",2)
End DoDot:1
+5 IF ASUT("TRCD")=27
IF X=0
SET X=ASUMS("LPP")
+6 QUIT
QVDECRE ;EP;.
+1 SET ASUMS("VAL","O/H")=ASUMS("VAL","O/H")-ASUT(ASUT,"VAL")
+2 SET ASUMS("QTY","O/H")=ASUMS("QTY","O/H")-ASUT(ASUT,"QTY")
+3 IF ASUT("TRCD")="2P"
GOTO QVDCK0
+4 GOTO STAUPDT
QVDCK0 ;
+1 IF ASUMS("VAL","O/H")<0
GOTO RJCRBAL
+2 IF ASUMS("QTY","O/H")<0
GOTO RJCRBAL
+3 IF ASUMS("VAL","O/H")=0&(ASUMS("QTY","O/H")>0)
GOTO REJBOH
+4 IF ASUMS("QTY","O/H")=0&(ASUMS("VAL","O/H")>0)
GOTO REJBOH
+5 GOTO STAUPDT
QVINCRE ;EP;.
+1 SET ASUMS("VAL","O/H")=ASUMS("VAL","O/H")+ASUT(ASUT,"VAL")
+2 SET ASUMS("QTY","O/H")=ASUMS("QTY","O/H")+ASUT(ASUT,"QTY")
STAUPDT ;
+1 DO MIX^ASUMSTWR
+2 QUIT
REJBOH ;REJECT BALANCE ON HAND
+1 ;DFM P1 9/1/98
NEW Z
SET Z="Master Balance on Hand"
DO MSG^ASUJHELP(.Z)
SET DDSERROR=1
+2 GOTO REJECT
RJCRBAL ;REJECT CREDIT BALANCE
+1 ;DFM P1 9/1/98
NEW Z
SET Z="Would create Master Credit Balance"
DO MSG^ASUJHELP(.Z)
SET DDSERROR=2
+2 GOTO REJECT
RJNOENTR ;REJECT NO ENTRY
+1 ;DFM P1 9/1/98
NEW Z
SET Z="NO QTY OR VAL"
DO MSG^ASUJHELP(.Z)
SET DDSERROR=3
REJECT ;REJECT REPORT
+1 QUIT