source: WorldVistAEHR/trunk/r/IFCAP-PRC-PRX--PRCA--PRCN/PRCHSF3.m@ 1093

Last change on this file since 1093 was 613, checked in by George Lilly, 15 years ago

initial load of WorldVistAEHR

File size: 3.9 KB
Line 
1PRCHSF3 ;WISC/DJM-UPDATING THE LINE ITEM DISCOUNTS ON THE 'AMENDED' 443.6 RECORD ;8/31/95 11:29 AM
2V ;;5.1;IFCAP;;Oct 20, 2000
3 ;Per VHA Directive 10-93-142, this routine should not be modified.
4 ;GO THROUGH ALL LINE ITEMS AND CREATE 'PRCH("AM",PRCHCN)' ARRAY
5 ;PRCHCN CAN BE A 'CONTRACT NUMBER' OR '.OM'.
6 ;PRCH("AM",PRCHCN) HAS 3 "^" PARTS.
7 ; PART 1 = NUMBER OF LINE ITEMS IN THIS ARRAY ELEMENT.
8 ; PART 2 = TOTAL $AMOUNT OF ALL LINE ITEMS IN ARRAY ELEMENT.
9 ; PART 3 = LISTING OF ALL LINE NUMBERS IN THIS ARRAY ELEMENT.
10 ;THE LISTING IS SAVED IN THE FORMAT NEEDED TO USE WITHIN A MUMPS
11 ;'FOR' COMMAND. FOR EXAMPLE: 1:1:2,4,6,8:11,
12 ;
13 ;LOOP THROUGH ALL LINE ITEM ENTRIES AND ADD/UPDATE THE 'PRCH("AM",PRCHCN)' ARRAY.
14 N PRCH,PRCHEC,I,PRCHAMX,PRCHCN,PRCHLI,PRCHLCNT,K,TOT,K2,SHIP,OTOT,DIF,PRCHL0,PRCHL3,J,PRCHL1,PRCHL2,PRCHAC,PRCHACT,PRCHP,PRCHAMT,Y,PRCHN,PRCHD,PRCHDA,PRCHX
15 S PRCHPO=$S($D(PRCHPO):PRCHPO,1:D0),PRCHAM=$S($D(PRCHAM):PRCHAM,1:D1)
16 D MVDIS^PRCHMA3
17 S (PRCH,PRCHEC)=0
18 F I=1:1 S PRCH=$O(^PRC(443.6,PRCHPO,2,PRCH)) Q:PRCH=""!(PRCH'>0) D
19 .S PRCHAMX=$G(^PRC(443.6,PRCHPO,2,PRCH,2)) I PRCHAMX]"" D
20 ..S $P(PRCHAMX,U,6)="",^PRC(443.6,PRCHPO,2,PRCH,2)=PRCHAMX
21 ..S PRCHCN=$P(PRCHAMX,U,2),PRCHAMX=+$P(PRCHAMX,U),PRCHLI=I
22 ..D CN:PRCHCN]"",OM:PRCHCN=""
23 ..Q
24 .Q
25 S PRCHLCNT=I-1 S:$D(^PRC(443.6,PRCHPO,2,0)) $P(^(0),U,3,4)="1^"_PRCHLCNT
26 D UP
27TOT ;NOW LETS GET THE TOTAL FOR THIS DOCUMENT.
28 S (K,TOT)=0 F S K=$O(^PRC(443.6,PRCHPO,2,K)) Q:K'>0 S K2=^(K,2) I K2]"" S TOT=TOT+$P(K2,U)-$P(K2,U,6)
29 S SHIP=$P(^PRC(443.6,PRCHPO,0),U,13),TOT=TOT+SHIP,OTOT=$P(^PRC(442,PRCHPO,0),U,15),DIF=TOT-OTOT
30 S $P(^PRC(443.6,PRCHPO,6,PRCHAM,0),U,3)=DIF
31 S $P(^PRC(443.6,PRCHPO,0),U,15)=TOT
32 Q
33 ;
34LI ;CREAT THE ENTRY FOR THE 3rd "^" PIECE OF PRCH("AM",PRCHCN) HERE.
35 S PRCHL0=$P(PRCH("AM",PRCHL3),U,3) Q:PRCHL0="" F J=1:1 S PRCHL1=$E(PRCHL0,$L(PRCHL0)-J) Q:PRCHL1'=+PRCHL1
36 S PRCHL2=$E(PRCHL0,$L(PRCHL0)-J+1,$L(PRCHL0)-1),PRCHL2=PRCHL2+1 I PRCHL2'=PRCHLI S PRCHLI=PRCHL0_PRCHLI Q
37 I PRCHL1=":" S PRCHLI=$E(PRCHL0,1,$L(PRCHL0)-J)_PRCHLI Q
38 S PRCHLI=$E(PRCHL0,1,$L(PRCHL0)-1)_":1:"_PRCHLI
39 Q
40 ;
41CN ;CREATE THE 'PRCH("AM",PRCHCN)' ARRAY ELEMENT HERE, ALL THREE PARTS, FOR LINE ITEMS WITH A CONTRACT NUMBER.
42 S:'$D(PRCH("AM",PRCHCN)) PRCH("AM",PRCHCN)="",PRCHEC=PRCHEC+1 S PRCHL3=PRCHCN
43 D LI S PRCH("AM",PRCHCN)=($P(PRCH("AM",PRCHCN),U,1)+1)_U_($P(PRCH("AM",PRCHCN),U,2)+PRCHAMX)_U_PRCHLI_",",^PRC(443.6,PRCHPO,2,"AC",$E(PRCHCN,1,30),PRCH)=""
44 Q
45 ;
46OM ;CREATE THE 'PRCH("AM",PRCHCN)' ARRAY ELEMENT HERE, ALL THREE PARTS, FOR LINE ITEMS WITHOUT A CONTRACT NUMBER.
47 S:'$D(PRCH("AM",".OM")) PRCH("AM",".OM")="",PRCHEC=PRCHEC+1 S PRCHL3=".OM" D LI S PRCH("AM",".OM")=($P(PRCH("AM",".OM"),U,1)+1)_U_($P(PRCH("AM",".OM"),U,2)+PRCHAMX)_U_PRCHLI_","
48 Q
49 ;
50UP ;NOW LETS DO THE ACTUAL UPDATING OF THE DISCOUNT FOR EACH LINE ITEM.
51 ;
52 S PRCH=0
53 F I=1:1 S PRCH=$O(^PRC(443.6,PRCHPO,3,PRCH)) Q:PRCH=""!(PRCH'>0) S PRCHCN=$S($P(^(PRCH,0),U,5)]"":$P(^(0),U,5),1:".OM"),PRCHAC=$P(^(0),U,1),PRCHACT=$P(^(0),U,4),PRCHP=$P(^(0),U,2) D SET
54 Q
55 ;
56SET ;DECIDE THE LINE ITEM NUMBERS TO DO THE DISCOUNT ADJUSTMENT.
57 G:PRCHAC="Q" PCTQ
58 I PRCHAC[":" S PRCHAC=$P(PRCHAC,":",1)_":1:"_$P(PRCHAC,":",2)
59 ;
60PCT ;FOR EACH 'LINE ITEM NUMBER' WITH A DISCOUNT DO IT HERE.
61 S PRCHAMT=0,Y="F J="_PRCHAC_" S PRCHN=J D PCT1" X Y
62 S PRCHAMT=PRCHAMT*100+.5\1/100,$P(PRCH("AM",PRCHCN),U,2)=$P(PRCH("AM",PRCHCN),U,2)-PRCHAMT
63 Q
64 ;
65PCT1 S PRCHN=$O(^PRC(443.6,PRCHPO,2,"B",PRCHN,0)),PRCHD=+$P($G(^PRC(443.6,PRCHPO,2,PRCHN,2)),U,1)
66 I $E(PRCHP,1)="$" S PRCHDA=$P(PRCHP,"$",2)/PRCHACT
67 E S PRCHDA=$J(PRCHD*(PRCHP/100),0,2)
68 S PRCHAMT=PRCHAMT+PRCHDA,$P(^PRC(443.6,PRCHPO,2,PRCHN,2),U,6)=PRCHDA
69 Q
70 ;
71PCTQ ;COME HERE IF THE USER SELECTED A 'QUANTITY' DISCOUNT.
72 ;
73 S (PRCHAMT,PRCHCN,PRCHX)=0,PRCHACT=PRCHLCNT F K=0:0 S PRCHCN=$O(PRCH("AM",PRCHCN)) Q:PRCHCN="" S PRCHAC=$E($P(PRCH("AM",PRCHCN),U,3),1,$L($P(PRCH("AM",PRCHCN),U,3))-1) D PCT S PRCHX=PRCHX+PRCHAMT
74 S $P(^PRC(443.6,PRCHPO,3,PRCH,0),U,3)=PRCHX
75 Q
Note: See TracBrowser for help on using the repository browser.