Really, this should be it, for the passing income.
[capital-apms-progress.git] / process / one-off / db-chng / uniqline.p
blob4a8067f03fa437bcb91a2185efa000082bb68f8e
1 &ANALYZE-SUSPEND _VERSION-NUMBER UIB_v8r12
2 &ANALYZE-RESUME
3 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _DEFINITIONS Procedure
4 /*--------------------------------------------------------------------------
5 File :
6 Purpose :
8 Syntax :
10 Description :
12 Author(s) :
13 Created :
14 Notes :
15 ------------------------------------------------------------------------*/
16 /* This .W file was created with the Progress UIB. */
17 /*----------------------------------------------------------------------*/
19 /* *************************** Definitions ************************** */
21 /* _UIB-CODE-BLOCK-END */
22 &ANALYZE-RESUME
25 &ANALYZE-SUSPEND _UIB-PREPROCESSOR-BLOCK
27 /* ******************** Preprocessor Definitions ******************** */
29 &Scoped-define PROCEDURE-TYPE Procedure
33 /* _UIB-PREPROCESSOR-BLOCK-END */
34 &ANALYZE-RESUME
38 /* *********************** Procedure Settings ************************ */
40 &ANALYZE-SUSPEND _PROCEDURE-SETTINGS
41 /* Settings for THIS-PROCEDURE
42 Type: Procedure
43 Allow:
44 Frames: 0
45 Add Fields to: Neither
46 Other Settings: CODE-ONLY COMPILE
48 &ANALYZE-RESUME _END-PROCEDURE-SETTINGS
50 /* ************************* Create Window ************************** */
52 &ANALYZE-SUSPEND _CREATE-WINDOW
53 /* DESIGN Window definition (used by the UIB)
54 CREATE WINDOW Procedure ASSIGN
55 HEIGHT = .25
56 WIDTH = 39.57.
57 /* END WINDOW DEFINITION */
59 &ANALYZE-RESUME
64 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _MAIN-BLOCK Procedure
67 /* *************************** Main Block *************************** */
68 DEF VAR i AS INT NO-UNDO.
69 DEF VAR j AS INT NO-UNDO.
71 {inc/ofc-this.i}
72 FIND OfficeSetting OF Office NO-LOCK WHERE OfficeSetting.SetName = "UNIQLINE.P" NO-ERROR.
73 DO TRANSACTION:
74 IF NOT AVAILABLE(OfficeSetting) THEN DO:
75 CREATE OfficeSetting.
76 OfficeSetting.OfficeCode = Office.OfficeCode.
77 OfficeSetting.SetName = "UNIQLINE.P".
78 OfficeSetting.SetValue = "Voucher,0".
79 END.
80 END.
81 FIND OfficeSetting OF Office NO-LOCK WHERE OfficeSetting.SetName = "UNIQLINE.P" NO-ERROR.
83 IF ENTRY(1, OfficeSetting.SetValue) = "Voucher" THEN DO:
84 j = INT(ENTRY(2,OfficeSetting.SetValue)).
85 DEF VAR this-id AS CHAR NO-UNDO.
86 DEF VAR recids AS CHAR NO-UNDO.
87 j = 0.
89 DEF BUFFER NextLine FOR VoucherLine.
90 ON WRITE OF VoucherLine OVERRIDE DO: END.
92 Voucher-loop:
93 FOR EACH Voucher NO-LOCK:
94 FIND FIRST VoucherLine OF Voucher NO-LOCK NO-ERROR.
95 IF NOT AVAILABLE(VoucherLine) THEN NEXT Voucher-loop.
96 IF CAN-FIND( FIRST NextLine OF Voucher WHERE RECID(NextLine) <> RECID(VoucherLine) ) THEN DO:
97 i = 1.
98 recids = "".
99 Inv-line-loop:
100 FOR EACH VoucherLine OF Voucher EXCLUSIVE-LOCK:
101 this-id = STRING( RECID(VoucherLine)).
102 IF LOOKUP( this-id, recids) <> 0 THEN NEXT Inv-line-loop.
103 recids = recids + this-id + ",".
104 IF VoucherLine.LineSeq <> i THEN VoucherLine.LineSeq = i.
105 IF j MOD 100 = 0 THEN
106 MESSAGE Voucher.VoucherSeq VoucherLine.LineSeq .
107 j = j + 1.
108 i = i + 1.
109 END.
110 END.
111 END.
112 END.
114 IF ENTRY(1, OfficeSetting.SetValue) = "Voucher" THEN DO:
115 DO TRANSACTION:
116 FIND CURRENT OfficeSetting EXCLUSIVE-LOCK.
117 OfficeSetting.SetValue = "Invoice,0".
118 FIND CURRENT OfficeSetting NO-LOCK.
119 END.
120 END.
123 IF ENTRY(1, OfficeSetting.SetValue) = "Invoice" THEN DO:
124 j = INT(ENTRY(2,OfficeSetting.SetValue)).
125 ON WRITE OF InvoiceLine OVERRIDE DO: END.
126 FOR EACH Invoice NO-LOCK WHERE Invoice.InvoiceNo > j:
127 IF CAN-FIND( FIRST InvoiceLine OF Invoice ) THEN DO TRANSACTION:
128 i = 1.
129 FOR EACH InvoiceLine OF Invoice:
130 IF InvoiceLine.LineSeq > i THEN
131 i = InvoiceLine.LineSeq.
132 ELSE IF InvoiceLine.LineSeq < i THEN
133 InvoiceLine.LineSeq = i.
135 i = i + 1.
136 END.
137 END.
138 IF (Invoice.InvoiceNo MOD 10) = 0 THEN DO TRANSACTION:
139 FIND CURRENT OfficeSetting EXCLUSIVE-LOCK.
140 OfficeSetting.SetValue = "Invoice," + STRING( Invoice.InvoiceNo ).
141 FIND CURRENT OfficeSetting NO-LOCK.
142 END.
143 END.
144 ON WRITE OF InvoiceLine REVERT.
145 END.
147 DO TRANSACTION:
148 FIND CURRENT OfficeSetting EXCLUSIVE-LOCK.
149 OfficeSetting.SetValue = "Completed".
150 FIND CURRENT OfficeSetting NO-LOCK.
151 END.
153 /* _UIB-CODE-BLOCK-END */
154 &ANALYZE-RESUME