Add blank column, rename column.
[capital-apms-progress.git] / process / report / monthly-gst.p
blob54ca6419d7a038b08f80f296b6e6da71f8054be6
1 &ANALYZE-SUSPEND _VERSION-NUMBER UIB_v8r12
2 &ANALYZE-RESUME
3 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _DEFINITIONS Procedure
4 /*--------------------------------------------------------------------------
5 Approved Vouchers Report
6 ------------------------------------------------------------------------*/
7 DEF INPUT PARAMETER report-options AS CHAR NO-UNDO.
9 DEF VAR preview AS LOGI NO-UNDO INIT No.
10 DEF VAR month-code AS INT NO-UNDO INIT 0.
11 RUN parse-parameters.
13 DEF VAR make-new-document AS LOGI NO-UNDO.
14 DEF VAR user-name AS CHAR NO-UNDO.
15 DEF VAR timeStamp AS CHAR FORMAT "X(44)" NO-UNDO.
17 DEF VAR title-font AS CHAR NO-UNDO INITIAL "proportional,helv,point,12,bold".
18 DEF VAR time-font AS CHAR NO-UNDO INITIAL "proportional,helv,point,6,normal".
19 DEF VAR break1-font AS CHAR NO-UNDO INITIAL "proportional,helv,point,12,bold".
20 DEF VAR break2-font AS CHAR NO-UNDO INITIAL "proportional,helv,point,8,bold".
21 DEF VAR line1-font AS CHAR NO-UNDO INITIAL "fixed,courier,cpi,18,lpi,9,bold".
22 DEF VAR line2-font AS CHAR NO-UNDO INITIAL "fixed,courier,cpi,18,lpi,9,normal".
23 DEF VAR amt-fmt AS CHAR INIT "(>>,>>>,>>9.99)" NO-UNDO.
24 DEF VAR i AS INT NO-UNDO.
26 DEF VAR pr-line AS CHAR NO-UNDO.
28 {inc/ofc-this.i}
29 {inc/ofc-acct.i "GST-IN" "gst-in"}
30 {inc/ofc-acct.i "GST-OUT" "gst-out"}
31 {inc/ofc-acct.i "GST-BAD" "gst-bad"}
32 {inc/ofc-acct.i "GST-SUSPENSE" "suspense-account"}
33 DEF VAR suspense-entity AS INT NO-UNDO.
34 suspense-entity = OfficeControlAccount.EntityCode.
36 /* scope newbatch record */
37 FIND LAST NewBatch NO-LOCK NO-ERROR.
38 FIND NEXT NewBatch NO-LOCK NO-ERROR.
40 FIND Month WHERE Month.MonthCode = month-code NO-LOCK NO-ERROR.
42 /* _UIB-CODE-BLOCK-END */
43 &ANALYZE-RESUME
46 &ANALYZE-SUSPEND _UIB-PREPROCESSOR-BLOCK
48 /* ******************** Preprocessor Definitions ******************** */
50 &Scoped-define PROCEDURE-TYPE Procedure
54 /* _UIB-PREPROCESSOR-BLOCK-END */
55 &ANALYZE-RESUME
58 /* ************************ Function Prototypes ********************** */
60 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION-FORWARD get-account-balance Procedure
61 FUNCTION get-account-balance RETURNS DECIMAL
62 ( INPUT et AS CHAR, INPUT ec AS INT, INPUT ac AS DEC, INPUT mc AS INT ) FORWARD.
64 /* _UIB-CODE-BLOCK-END */
65 &ANALYZE-RESUME
67 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION-FORWARD transfer-gst-account Procedure
68 FUNCTION transfer-gst-account RETURNS DECIMAL
69 ( INPUT ac AS DEC ) FORWARD.
71 /* _UIB-CODE-BLOCK-END */
72 &ANALYZE-RESUME
75 /* *********************** Procedure Settings ************************ */
77 &ANALYZE-SUSPEND _PROCEDURE-SETTINGS
78 /* Settings for THIS-PROCEDURE
79 Type: Procedure
80 Allow:
81 Frames: 0
82 Add Fields to: Neither
83 Other Settings: CODE-ONLY COMPILE
85 &ANALYZE-RESUME _END-PROCEDURE-SETTINGS
87 /* ************************* Create Window ************************** */
89 &ANALYZE-SUSPEND _CREATE-WINDOW
90 /* DESIGN Window definition (used by the UIB)
91 CREATE WINDOW Procedure ASSIGN
92 HEIGHT = .08
93 WIDTH = 40.
94 /* END WINDOW DEFINITION */
96 &ANALYZE-RESUME
100 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _INCLUDED-LIB Procedure
101 /* ************************* Included-Libraries *********************** */
103 {inc/method/m-txtrep.i}
105 /* _UIB-CODE-BLOCK-END */
106 &ANALYZE-RESUME
110 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _MAIN-BLOCK Procedure
113 /* *************************** Main Block *************************** */
115 OUTPUT TO VALUE( txtrep-print-file ) KEEP-MESSAGES PAGE-SIZE 0.
116 RUN pclrep-start( preview, "portrait,tm,2,a4,lm,6," + line1-font).
118 RUN transfer-gst-residual.
120 OUTPUT CLOSE.
122 RUN pclrep-finish.
123 MESSAGE "Batch Creation Complete" VIEW-AS ALERT-BOX INFORMATION TITLE "Finished".
125 /* _UIB-CODE-BLOCK-END */
126 &ANALYZE-RESUME
129 /* ********************** Internal Procedures *********************** */
131 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE inst-page-footer Procedure
132 PROCEDURE inst-page-footer :
133 /*------------------------------------------------------------------------------
134 Purpose:
135 ------------------------------------------------------------------------------*/
137 END PROCEDURE.
139 /* _UIB-CODE-BLOCK-END */
140 &ANALYZE-RESUME
143 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE inst-page-header Procedure
144 PROCEDURE inst-page-header :
145 /*------------------------------------------------------------------------------
146 Purpose:
147 ------------------------------------------------------------------------------*/
148 {inc/username.i "user-name"}
149 timeStamp = STRING( TODAY, "99/99/9999") + ", " + STRING( TIME, "HH:MM:SS") + " for " + user-name.
151 pr-line = timeStamp.
152 pr-line = pr-line + CHR(13) + SPC(275) + "Page: " + STRING( pclrep-page-number ).
153 RUN pclrep-line( time-font, pr-line).
155 RUN pclrep-line( ?, "").
156 RUN pclrep-line( ?, "").
157 RUN pclrep-line( title-font, SPC(45) + "Monthly GST Generation" ).
158 RUN pclrep-line( time-font, "").
159 RUN pclrep-line( time-font, "").
162 END PROCEDURE.
164 /* _UIB-CODE-BLOCK-END */
165 &ANALYZE-RESUME
168 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE make-transaction Procedure
169 PROCEDURE make-transaction :
170 /*------------------------------------------------------------------------------
171 Purpose:
172 ------------------------------------------------------------------------------*/
173 DEF INPUT PARAMETER et AS CHAR NO-UNDO.
174 DEF INPUT PARAMETER ec AS INT NO-UNDO.
175 DEF INPUT PARAMETER ac AS DEC NO-UNDO.
176 DEF INPUT PARAMETER amt AS DEC NO-UNDO.
177 DEF INPUT PARAMETER xdesc AS CHAR NO-UNDO.
179 IF NOT AVAILABLE(NewBatch) THEN DO TRANSACTION:
180 CREATE NewBatch.
181 NewBatch.Description = "Monthly GST".
182 END.
184 FIND LAST NewDocument OF NewBatch NO-LOCK NO-ERROR.
185 DO TRANSACTION:
186 IF make-new-document OR NOT AVAILABLE(NewDocument) THEN DO:
187 CREATE NewDocument.
188 NewDocument.BatchCode = NewBatch.BatchCode.
189 END.
190 ELSE
191 FIND LAST NewDocument OF NewBatch EXCLUSIVE-LOCK NO-ERROR.
193 NewDocument.DocumentType = "XGST".
194 NewDocument.Reference = "GST " + STRING( YEAR(Month.EndDate), "9999") + "/" + STRING( MONTH(Month.EndDate), "99").
195 NewDocument.Description = xdesc.
196 make-new-document = No.
197 END.
199 DO TRANSACTION:
200 CREATE NewAcctTrans.
201 NewAcctTrans.BatchCode = NewBatch.BatchCode.
202 NewAcctTrans.DocumentCode = NewDocument.DocumentCode.
203 NewAcctTrans.EntityType = et.
204 NewAcctTrans.EntityCode = ec.
205 NewAcctTrans.AccountCode = ac.
206 NewAcctTrans.MonthCode = Month.MonthCode.
207 NewAcctTrans.Date = Month.EndDate.
208 NewAcctTrans.Amount = amt.
209 END.
211 END PROCEDURE.
213 /* _UIB-CODE-BLOCK-END */
214 &ANALYZE-RESUME
217 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE parse-parameters Procedure
218 PROCEDURE parse-parameters :
219 /*------------------------------------------------------------------------------
220 Purpose:
221 ------------------------------------------------------------------------------*/
222 DEF VAR token AS CHAR NO-UNDO.
223 DEF VAR i AS INT NO-UNDO.
225 {inc/showopts.i "report-options"}
227 DO i = 1 TO NUM-ENTRIES( report-options, "~n" ):
228 token = ENTRY( i, report-options, "~n" ).
230 CASE ENTRY( 1, token ):
231 WHEN "Preview" THEN preview = Yes.
232 WHEN "Month" THEN month-code = INT( ENTRY( 2,token )).
233 END CASE.
235 END.
237 END PROCEDURE.
239 /* _UIB-CODE-BLOCK-END */
240 &ANALYZE-RESUME
243 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE transfer-gst-residual Procedure
244 PROCEDURE transfer-gst-residual :
245 /*------------------------------------------------------------------------------
246 Purpose:
247 ------------------------------------------------------------------------------*/
248 DEF VAR line AS CHAR NO-UNDO.
249 DEF VAR journal-total AS DEC NO-UNDO INITIAL 0.0 .
251 journal-total = transfer-gst-account( gst-in ).
252 journal-total = journal-total + transfer-gst-account( gst-out ).
253 journal-total = journal-total + transfer-gst-account( gst-bad ).
255 make-new-document = Yes.
256 RUN make-transaction( "L", suspense-entity, suspense-account, - journal-total, "GST Total" ).
258 END PROCEDURE.
260 /* _UIB-CODE-BLOCK-END */
261 &ANALYZE-RESUME
264 /* ************************ Function Implementations ***************** */
266 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION get-account-balance Procedure
267 FUNCTION get-account-balance RETURNS DECIMAL
268 ( INPUT et AS CHAR, INPUT ec AS INT, INPUT ac AS DEC, INPUT mc AS INT ) :
269 /*------------------------------------------------------------------------------
270 Purpose:
271 Notes:
272 ------------------------------------------------------------------------------*/
273 DEF VAR balance AS DEC NO-UNDO INITIAL 0.0 .
275 FIND AccountSummary WHERE AccountSummary.EntityType = et
276 AND AccountSummary.EntityCode = ec
277 AND AccountSummary.AccountCode = ac
278 NO-LOCK NO-ERROR.
279 IF AVAILABLE(AccountSummary) THEN balance = AccountSummary.Balance.
281 FOR EACH AccountBalance WHERE AccountBalance.EntityType = et
282 AND AccountBalance.EntityCode = ec
283 AND AccountBalance.AccountCode = ac
284 AND AccountBalance.MonthCode > mc
285 AND AccountBalance.Balance <> 0 NO-LOCK:
286 balance = balance - AccountBalance.Balance .
287 END.
289 RETURN balance.
291 END FUNCTION.
293 /* _UIB-CODE-BLOCK-END */
294 &ANALYZE-RESUME
297 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION transfer-gst-account Procedure
298 FUNCTION transfer-gst-account RETURNS DECIMAL
299 ( INPUT ac AS DEC ) :
300 /*------------------------------------------------------------------------------
301 Purpose:
302 Notes:
303 ------------------------------------------------------------------------------*/
304 DEF VAR account-total AS DEC NO-UNDO INITIAL 0.0 .
305 DEF VAR account-balance AS DEC NO-UNDO INITIAL 0.0 .
307 make-new-document = Yes.
308 FOR EACH Company NO-LOCK:
309 account-balance = get-account-balance( "L", Company.CompanyCode, ac, month-code ).
310 IF account-balance <> 0 THEN DO:
311 RUN make-transaction( "L", Company.CompanyCode, ac, - account-balance,
312 "Clear GST Balance, A/C " + STRING( ac, "9999.99") ).
313 account-total = account-total - account-balance .
314 END.
315 END.
317 RETURN account-total .
319 END FUNCTION.
321 /* _UIB-CODE-BLOCK-END */
322 &ANALYZE-RESUME