Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: BARPST4

BARPST4.m

Go to the documentation of this file.
BARPST4 ; IHS/SD/LSL - POSTING AND ADJUSTMENTS CONTINUED ; 12/29/2008
 ;;1.8;IHS ACCOUNTS RECEIVABLE;**3,4,6,10,20,23**;OCT 26, 2005
 ;
 ; *********************************************************************
 ;
EN ;EP
 I '$D(BARTR(BARLIN)) D  G ASKCOM^BARPST3
 .W *7,!!,"No transactions to Edit."
 .D EOP^BARUTL(1)
 N BARSEL
 S (BARSEL,BARJ)=0
 S BARSEL=$$DSPLY(BARLIN)
 W !
 K DIR  ;IHS/SD/TPF BAR*1.8*3 FOUND DURING BETA TESTING
 S DIR(0)="N^1:"_BARSEL
 D ^DIR
 I $D(DUOUT)!$D(DTOUT) G ASKCOM^BARPST3  ;IHS/SD/TPF BAR*1.8*3 FOUND DURING BETA TESTING
 S BARSEL=Y
 ; -------------------------------
PARSE ;
 S BARLIN=$O(BARSEL(BARSEL,""))
 Q:'BARLIN
 S BARV=$O(BARSEL(BARSEL,BARLIN,""))
 Q:'BARV
 N BARREC
 S BARREC=BARTR(BARLIN,BARV)
 S BARTYP=$P(BARREC,U,1)
 S (BAROAMT,BARAMT)=$P(BARREC,U,2)
 S BARCAT=$P(BARREC,U,3)
 S BARATYP=$P(BARREC,U,4)
 ; -------------------------------
 ;
ASKAMT ;
 S BARASK=$S(BARTYP="P":"Payment ",BARTYP="A":"Adjustment ",1:"")_"Amount: "
 W !!,BARASK_$J(BARAMT,0,2)_"// " R X:DTIME
 I X="" S X=BARAMT
 S X=$$AMT^BARPSTU(X)
 I X="^" G ASKCOM^BARPST3
 I X="?" W *7,"  Must be a valid number!" G ASKAMT
 I BARTYP="P",X<0,$$IHS^BARUFUT(DUZ(2)) D STOP^BARFPST1 G ASKAMT  ;MRS:BAR*1.8*10 D158-3 OTT
 ;;;I BARTYP="P",X<0,$$IHSERA^BARUFUT(DUZ(2)) D STOP^BARFPST1 G ASKAMT  ;MRS:BAR*1.8*10 D158-3 OTT
 S BARAMT=X
 ;
 I BARTYP="P" G S1
 ;
 ;** adjustment category/type dialog
 S DIC("B")=BARCAT
 S DIC=90052.01
 S DIC(0)="AEMNQZ"
 S DIC("A")="Adjustment Category: "
 S DIC("S")="I Y=3!(Y=4)!(Y=13)!(Y=14)!(Y=15)!(Y=16)!(Y=20)!(Y=21)!(Y=22)"
 K DD,DO
 D ^DIC
 K DIC
 I +Y<0 W *7 W !! G ASKAMT
 S BARCAT=+Y
 S:BARCAT=16 BARAMT=-BARAMT
 S BARX=0,BARJ=0
 K BARK
 F  S BARX=$O(^BARTBL("D",BARCAT,BARX)) Q:'BARX  D  Q:BARJ>1
 .S BARJ=BARJ+1
 .Q:BARJ>1
 .S BARK=BARX
 I BARJ=1,$G(BARK) S BARATYP=BARK G S1
 S DIC("B")=BARATYP
 S DIC=90052.02
 S DIC(0)="AEMNQZ"
 S DIC("A")="Adjustment Type: "
 S DIC("S")="I $P(^(0),U,2)=BARCAT"
 K DD,DO
 D ^DIC
 K DIC
 I +Y<0 W *7,!! G ASKAMT
 S BARATYP=+Y
 ;--------------------------------
 ;
S1 ;
 D SETTMP(BARTYP,BARAMT,BARLIN,BARCAT,BARATYP,BAROAMT)
 G ASKCOM^BARPST3
 ; *********************************************************************
 ;
SETTMP(BARTYP,BARAMT,BARLIN,BARCAT,BARATYP,BAROAMT) ;HEAVILY MODIFIED; BAR*1.8*4 DD 4.1.7.2
 ;SEE SETTMPO BELOW FOR ORIGINAL CODING
 N BARBBAL,BARCLV17,BARITV19,BAREOV4
 K BARFLG("BARWARN")
 S BARSTOP=0
 S BARDA=$O(^BARTMP($J,"B",BARLIN,""))
 S BARBBAL=$P(^BARTMP($J,BARDA,BARLIN),U,5)
 I BARCAT'=21&(BARCAT'=22) D
 .S BARBBAL=BARBBAL+BAROAMT  ;ADD BACK TO BAL IF NOT PENDING/GENERAL INFO
 .D CKNEG(BARBBAL,BAROAMT,BARAMT)      ;CHECK FOR NEGATIVE BALANCES
 Q:BARSTOP
 ;Begin old code;MRS:BAR*1.8*6 IM28960
 ;I BARTYP="P" D  Q:BARSTOP
 ;.S $P(^BARTMP($J,BARDA,BARLIN),U,6)=$P($G(^BARTMP($J,BARDA,BARLIN)),U,6)+BARAMT-BAROAMT
 ;.S BARPMT=BARPMT+BARAMT-BAROAMT
 ;I BARTYP="A" D
 ;.S $P(^BARTMP($J,BARDA,BARLIN),U,7)=$P($G(^BARTMP($J,BARDA,BARLIN)),U,7)+BARAMT-BAROAMT
 ;.S BARADJ=BARADJ+BARAMT-BAROAMT
 ;I BARCAT'=21&(BARCAT'=22) D
 ;.S $P(^BARTMP($J,BARDA,BARLIN),U,5)=$P(^BARTMP($J,BARDA,BARLIN),U,5)-BARAMT+BAROAMT
 ;Begin new code;MRS:BAR*1.8*6 IM28960
 S BARBBAL=BARBBAL-BARAMT
 I BARTYP="P" D
 .Q:BAROAMT=BARAMT
 .S BARPMT=BARPMT+BARAMT-BAROAMT
 .S $P(^BARTMP($J,BARDA,BARLIN),U,6)=BARPMT
 .S $P(^BARTMP($J,BARDA,BARLIN),U,5)=BARBBAL
 ;
 I BARTYP="A" D
 .Q:BAROAMT=BARAMT
 .S BARADJ=BARADJ+BARAMT-BAROAMT
 .S $P(^BARTMP($J,BARDA,BARLIN),U,7)=BARADJ
 .S:BARCAT'=21&(BARCAT'=22) $P(^BARTMP($J,BARDA,BARLIN),U,5)=BARBBAL
 ;End changes;MRS:BAR*1.8*6 IM28960
 ;
 S BARTR(BARLIN,BARV)=BARTYP_U_BARAMT_U_BARCAT_U_BARATYP
 K BAROAMT
 Q
 ;
CKNEG(BARBBAL,BAROAMT,BARAMT) ;EP;CHECK FOR NEGATIVE BALANCES;BAR*1.8*4 DD 4.1.7.2
 ;
 I BARBBAL-BARAMT<0 D  I BARTYP'="P" D SURE Q  ;BILL BALANCE
 .D WARN(4,(BARBBAL-BARAMT))
 .I $G(BARZZZZ) D SURE Q        ;ENTERING FROM PUC;MRS:BAR*1.8*6 DD 4.2.5
 Q:$G(BARZZZZ)                  ;ENTERING FROM PUC;MRS:BAR*1.8*6 DD 4.2.5
 Q:BARTYP'="P"                  ;ONLY PAYMENTS CHECK BATCH/ITEM
 N BARCLV17,BARITV19,BAREOV4
 I $G(BARCLV(17))]"" D          ;COLLECTION BATCH BALANCE
 .;S BARCLV17=BARCLV(17)+BAROAMT
 .;IHS/OIT/CASSevern/Pieran ran 01/21/2011 bar*1.8*20 BARPMT tracks payments made this session but not posted
 .S BARCLV17=BARCLV(17)+BAROAMT-BARPMT
 .I BARCLV17-BARAMT<0 D WARN(1,(BARCLV17-BARAMT))
 I $G(BARITV(19))]"" D          ;ITEM BALANCE
 .;S BARITV19=BARITV(19)+BAROAMT
 .;IHS/OIT/CASSevern/Pieran ran 01/21/2011 bar*1.8*20 BARPMT tracks payments made this session but not posted
 .S BARITV19=BARITV(19)+BAROAMT-BARPMT
 .I BARITV19-BARAMT<0 D WARN(2,(BARITV19-BARAMT))
 I +$G(BAREOB) D                ;VISIT LOCATION BALANCE
 .;S BAREOV4=BAREOV(4)+BAROAMT
 .;IHS/OIT/CASSevern/Pieran ran 01/21/2011 bar*1.8*20 BARPMT tracks payments made this session but not posted
 .S BAREOV4=BAREOV(4)+BAROAMT-BARPMT
 .I BAREOV4-BARAMT<0 D WARN(3,(BAREOV4-BARAMT))
 ;
SURE ;EP; WARNING MESSAGE
 Q:$G(BARZZZZ)="P"              ;CHECK CALLED FROM PUC ;BAR*1.8*6 DD 4.2.5
 Q:'$G(BARFLG("BARWARN"))
 W !
 K BARFLG("BARWARN")
 K DIR
 S DIR(0)="Y"
 S DIR("A")="ARE YOU SURE"
 S DIR("B")="NO"
 D ^DIR
 K DIR
 I Y'=1 S BARSTOP=1
 Q
 ;
 ; *********************************************************************
WARN(BARLVL,BARDIF)       ;EP - warner MOVED FROM BARPST3A ;BAR*1.8*4 DD 4.1.7.2
 I BARLVL=4,'$$IHS^BARUFUT(DUZ(2)) K BARFLG("BARWARN") Q  ;BAR*1.8*4 DD 4.1.7.2
 ;;;I BARLVL=4,'$$IHSERA^BARUFUT(DUZ(2)) K BARFLG("BARWARN") Q  ;BAR*1.8*4 DD 4.1.7.2 OTT
 I '$G(BARFLG("BARWARN")) W !
 W *7,!,"Warning - Posted amount exceeds the "
 W $S(BARLVL=1:"BATCH",BARLVL=2:"ITEM",BARLVL=3:"LOCATION",1:"BILL")_" balance" ;BAR*1.8*4 DD 4.1.7.2
 W " by "_BARDIF_" amount"              ;BAR*1.8*4 DD 4.1.7.2
 S BARFLG("BARWARN")=1
 Q
 ;
 ; *********************************************************************
 ;
DSPLY(BARLIN) ;EP - display temporary buffer
 N BARPG,BARJ
 S BARPG=0
 D HEAD
 S (BARJ,BARSEL)=0
 F  S BARJ=$O(BARTR(BARLIN,BARJ)) Q:'BARJ  D
 .S BARSEL=BARSEL+1
 .W !,?1,BARSEL_"."
 .W ?8,$P(BARTR(BARLIN,BARJ),U,1)
 .W ?13,$J($P(BARTR(BARLIN,BARJ),U,2),8,2)
 .S Y=$P(BARTR(BARLIN,BARJ),U,3)
 .I Y W ?25,$E($P(^BAR(90052.01,Y,0),U,1),1,23)
 .S Y=$P(BARTR(BARLIN,BARJ),U,4)
 .I Y W ?50,$E($P(^BARTBL(Y,0),U,1),1,28)
 .S BARSEL(BARSEL,BARLIN,BARJ)=""
 Q BARSEL
 ; *********************************************************************
 ;
 W $$EN^BARVDF("IOF"),!
 S BARPG=BARPG+1
 W "Transactions for "_$P(^DPT(+BARPASS,0),U,1)_"  from "_$$SDT^BARDUTL($P(BARPASS,U,2))_" to "_$$SDT^BARDUTL($P(BARPASS,U,3))
 W ?(IOM-15),"Page: "_BARPG
 W !!
 W "Trans",?8,"Type",?15,"Amount",?25,"Category",?50,"Adj. Type"
 S BARDSH=""
 S $P(BARDSH,"-",IOM)=""
 W !,BARDSH
 Q
 ;
SETTMPO(BARTYP,BARAMT,BARLIN,BARCAT,BARATYP) ;OLD SETTMP; BAR*1.8*4 DD 4.1.7.2
 K BARFLG("BARWARN")
 S BARSTOP=0
 S BARDA=$O(^BARTMP($J,"B",BARLIN,""))
B1O ;
 I BARTYP="P" D  Q:BARSTOP
 .I (BARCLV(17)-(BARPMT+BARAMT-BAROAMT))<0 D WARN(1)
 .I (BARITV(19)-(BARPMT+BARAMT-BAROAMT))<0 D WARN(2)
 .I +$G(BAREOB),(BAREOV(4)-(BARPMT+BARAMT-BAROAMT))<0 D WARN(3)
 .I $G(BARFLG("BARWARN")) D  Q:BARSTOP
 ..K BARFLG("BARWARN")
 ..W *7,!!,"Sorry - Exceeding Limits Not Allowed",!!
 ..D EOP^BARUTL(1)
 ..S BARSTOP=1
 .S $P(^BARTMP($J,BARDA,BARLIN),U,6)=$P($G(^BARTMP($J,BARDA,BARLIN)),U,6)+BARAMT-BAROAMT
 .S BARPMT=BARPMT+BARAMT-BAROAMT
 I BARTYP="A" D
 .S $P(^BARTMP($J,BARDA,BARLIN),U,7)=$P($G(^BARTMP($J,BARDA,BARLIN)),U,7)+BARAMT-BAROAMT
 .S BARADJ=BARADJ+BARAMT-BAROAMT
 S $P(^BARTMP($J,BARDA,BARLIN),U,5)=$P(^BARTMP($J,BARDA,BARLIN),U,5)-BARAMT+BAROAMT
 S BARTR(BARLIN,BARV)=BARTYP_U_BARAMT_U_BARCAT_U_BARATYP
 K BAROAMT
 Q