-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathModule1.tmp
More file actions
4954 lines (4211 loc) · 189 KB
/
Copy pathModule1.tmp
File metadata and controls
4954 lines (4211 loc) · 189 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
'apos;// Module1Hdr.bas
REM ***** BASIC *****
'apos;// Module1Hdr - BadAss Library Module1 header.
'apos;// Module1 (Beta Release) - Local macros for Chase Activity Download Spreadsheet and
'apos;// transaction processing in Production Alpha Clean Accounting spreadsheet.
'apos;// 8/22/22. wmk. 'apos;/**/ and // <module-name>.bas bracketing lines added; application
'apos;// extended to general banking activity in Accounting subsystem.
'apos;// Legacy Mods.
'apos;// 5/14/20. wmk. original code with mods
'apos;// 5/16/20. wmk. new functions and subs to span sheets for
'apos;// transaction mapping to accounts sheets
'apos;// 5/17/20. wmk. correct test constant EXPSHEET to match this
'apos;// document 'apos;Expense Accounts_2'apos;
'apos;// 5/18/20. wmk. row data processing constants added.
'apos;// 5/19/20. wmk. sheet name constants changed to match production
'apos;// 5/20/20. wmk. added OPTION EXPLICIT for code control
'apos;// 5/22/20. wmk. added PlaceSplitTrans function.
'apos;// 5/23/20. wmk. added BeanField function; bug fix with ASTSHEET
'apos;// 5/25/20. wmk. added errhandling.bas and associated subs
'apos;// 5/26/20. wmk. errhandling.bas update resinserted
'apos;// 6/28/20. wmk. Beta Release to BadAss Library
'apos;// Code protection.
OPTION EXPLICIT 'apos;// every variable must be declared before use
'apos;/**/
'apos;// errhandling.bas
'apos;//---------------------------------------------------------------
'apos;// errhandling.bas - Definitions for development error handling.
'apos;// wmk. 5/26/20. 17:30
'apos;//---------------------------------------------------------------
'apos;//
'apos;// Header Description.
'apos;// -------------------
'apos;// errhandling.bas contains definitions that may be inserted in any
'apos;// OOoBasic Module for handing error conditions. This is intended for
'apos;// use with development modules, and should be removed for Production
'apos;// spreadsheets. This will ensure clean code released into the
'apos;// Production environment.
'apos;//
'apos;// error handling interface methods.
'apos;// ErrLogSetup - set up error logging (gbErrLogging, goCellRangeAddress, gsErrModule)
'apos;// ErrLogDisable() - disable error logging by setting gbErrLogging = false
'apos;// ErrLogGetCellInfo(lColumn, lRow) - get error focus cell column, row
'apos;// ErrLogSetCellInfo(lColumn, lRow) - set error focus cell column, row
'apos;// ErrLogGetCellName() - get error focus cell alphanumeric name
'apos;// ErrLogGetDisplay() - get error message box enabled status
'apos;// ErrLogSetDisplay(bDisplayOn) - set error message box enabled status
'apos;// ErrLogGetModule() - get current module name gsErrModule
'apos;// ErrLogSetModule(sName) - set current module name gsErrModule
'apos;// ErrLogGetRecording - Get error recording status from error log globals
'apos;// ErrLogSetRecording - Set error recording status in error log globals
'apos;// ErrLogGetSheet - Get sheet index from error log globals.
'apos;// ErrLogSetSheet - Set sheet index in error log globals.
'apos;// LogError - make error log entry([goCellRangeAddress], psErrName, psErrMsg)
'apos;// global constants.
'apos;// public constants.
public const ERRLOGSHEET="quot;Error Log"quot; 'apos;// error logging sheet name
public const ERRLOGINSROW=5 'apos;// insertion row for log messages
'apos;// global variables.
'apos;// global variables.
global gbErrDisplay As Boolean 'apos;// msgBox on/off flag
global gbErrLogging as Boolean 'apos;// logging on/off flag; LogSetup sets/clears
global gbErrRecording As Boolean 'apos;// log sheet recording on/off flag
global gsErrSheet As String 'apos;// name of sheet error thrown on
global gsErrModule As String 'apos;// sub/function throwing error
global gsErrName As String 'apos;// name of error code
global gsErrMsg As String 'apos;// error message
global goErrRangeAddress As Object 'apos;// cell range address
'apos;// public variables.
'apos;//
'apos;// error handling interface methods.
'apos;// ErrLogSetup - set up error logging (gbErrLogging, goCellRangeAddress, gsErrModule)
'apos;// ErrLogDisable() - disable error logging by setting gbErrLogging = false
'apos;// ErrLogGetCellInfo(lColumn, lRow) - get error focus cell column, row
'apos;// ErrLogSetCellInfo(lColumn, lRow) - set error focus cell column, row
'apos;// ErrLogGetCellName() - get error focus cell alphanumeric name
'apos;// ErrLogGetDisplay() - get error message box enabled status
'apos;// ErrLogSetDisplay(bDisplayOn) - set error message box enabled status
'apos;// ErrLogGetModule() - get current module name gsErrModule
'apos;// ErrLogSetModule(sName) - set current module name gsErrModule
'apos;// ErrLogGetRecording - Get error recording status from error log globals
'apos;// ErrLogSetRecording - Set error recording status in error log globals
'apos;// ErrLogGetSheet - Get sheet index from error log globals.
'apos;// ErrLogSetSheet - Set sheet index in error log globals.
'apos;// LogError - make error log entry([goCellRangeAddress], psErrName, psErrMsg)
'apos;//-----------------end errhandling.bas header--------------------------
'apos;/**/
'apos;// publics.bas
'apos;//---------------------------publics.bas----------------------------------------------
'apos;// 6/6/20. wmk.
'apos;// publics.bas - module-wide vars for Module1 code in accounts sheets
'apos;// module-wide constants. (used in processing bank download sheets)
'apos;// (mirrored in file publics.bas)
'apos;// Modification History.
'apos;// ---------------------
'apos;// 5/??/20. wmk. Original code
'apos;// 5/20/20. wmk. Released as Production into Alpha Clean Accounting.ods
'apos;// 5/23/20. wmk. ASTSHEET, LIASHEET, INCSHEET, corrected to match
'apos;// Production spreadsheet; RJUST corrected
'apos;// 5/27/20. wmk. DEVDEBUG constant added
'apos;// 5/28/20. wmk. ERRUNKNOWN universal error code value added
'apos;// 6/6/20. wmk. FMTDATETIME, DATEROW constants added
'apos;//
'apos;// Note. The Module1 functions D and E are referenced in cells for executing test
'apos;// cases against the General Ledger sheet. autocalc MUST BE OFF if these two
'apos;// functions are active (DEVDEBUG=true), since both functions fire on the current
'apos;// user selection. They really go haywire with recalc or autocalc since the current
'apos;// user row/column range may have nothing to do with their intended reference.
'apos;//
'apos;// debugging control.
public const DEVDEBUG=true 'apos;// true if functions D(), E() activated
'apos;public const DEVDEBUG=false 'apos;// false if functions D(), E() de-activated
'apos;// universal error code(s).
public const ERRUNKNOWN=-9999 'apos;// universal unknown error code
'apos;// production sheet names
public const GLSHEET = "quot;General Ledger"quot; 'apos;// General Ledger Sheet.Name
public const ASTSHEET = "quot;Asset Accounts"quot; 'apos;// (Production) Assets Sheet.Name
public const LIASHEET = "quot;Liability Accounts"quot; 'apos;// (Production) Liabilities Sheet.Name
public const INCSHEET = "quot;Income Accounts"quot; 'apos;// (Production) Income Sheet.Name
public const EXPSHEET = "quot;Expense Accounts"quot; 'apos;// Expense Accounts Sheet.Name
'apos;// development sheet names
'apos;public const ASTSHEET = "quot;Assets"quot; 'apos;// Assets Sheet.Name
'apos;Public const LIASHEET = "quot;Liabilities"quot; 'apos;// Liabilities Sheet.Name
'apos;public const INCSHEET = "quot;Income"quot; 'apos;// Income Sheet.Name
'apos;public const EXPSHEET = "quot;Expense Accounts_2"quot; 'apos;// mod051720
public const MON1="quot;January"quot;
public const MON2="quot;February"quot;
public const MON3="quot;March"quot;
public const MON4="quot;April"quot;
public const MON5="quot;May"quot;
public const MON6="quot;June"quot;
public const MON7="quot;July"quot;
public const MON8="quot;August"quot;
public const MON9="quot;September"quot;
public const MON10="quot;October"quot;
public const MON11="quot;November"quot;
public const MON12="quot;December"quot;
public const YELLOW=16776960 'apos;// decimal value of YELLOW color
public const LTGREEN=10092390 'apos;// decimal value of LTGREEN color
'apos;// column index values and string lengths for column data
public const INSBIAS=3 'apos;// insert line count bias
public const COALEN=4 'apos;// length of COA field strings
public const COLDATE=0 'apos;// Date - column A
public const COLTRANS=1 'apos;// Transaction - column B
public const COLDEBIT=2 'apos;// Debit - column C
public const COLCREDIT=3 'apos;// Credit - column D
public const COLACCT=4 'apos;// COA Account - column E
public const COLREF=5 'apos;// Reference - column F
public const DATEROW=1 'apos;// Sheet date row index 'apos;// mod060620
'apos;// cell formatting constants.
public const DEC2=123 'apos;// number format for (x,xxx.yy) 'apos;// mod052020
public const MMDDYY=37 'apos;// date format mm/dd/y 'apos;// mod052020
public const FMTDATETIME=50 'apos;// date/time format mm/dd/yyy hh:mm:ss 'apos;// mod060620
public const LJUST=1 'apos;// left-justify HoriJustify 'apos;// mod052020
public const CJUST=2 'apos;// center HoriJustify 'apos;// mod052020
public const RJUST=3 'apos;// right-justify HoriJustify 'apos;// mod052320
public const MAXTRANSL=50 'apos;// maximum transaction text length 'apos;// mod052020
'apos;//----------------------end publics.bas---------------------------------------------
'apos;/**/
'apos;// Main.bas
'apos;//---------------------------------------------------------------
'apos;// Main - generic Main sub for module.
'apos;// wmk. 5/15/20.
'apos;//---------------------------------------------------------------
Sub Main
End Sub
'apos;/**/
'apos;// CheckDoubleEntry.bas
'apos;//---------------------------------------------------------------
'apos;// CheckDoubleEntry - Check double entry transaction fields.
'apos;// 7/3/20. wmk.
'apos;//---------------------------------------------------------------
public function CheckDoubleEntry(poTransRange As Object, rpsMonth As String,_
rpsAcct1 As String, rpsAcct2 As String) As Integer
'apos;// Usage. iVal = CheckDoubleEntry(oTransRange, rpsMonth, rpsAcct1,
'apos;// rpsAcct2)
'apos;//
'apos;// oTransRange = RangeAddress of double-entry transaction
'apos;// rpsMonth = Month name string (e.g. "quot;January"quot;)
'apos;// rpsAcct1 = (returned)
'apos;// rpsAcct2 = (returned)
'apos;//
'apos;// Entry. &'apos;lt;entry conditions&'apos;gt;
'apos;//
'apos;// Exit. iVal = 0 if no error,
'apos;// ERRCONTINUE (-1) if error; skip to next transaction
'apos;// ERRSTOP (-2) if error; end processing user selction
'apos;// rpsAcct1 = COA from first line of transaction
'apos;// rpsAcct2 = COA from 2nd line of transaction
'apos;//
'apos;// Calls. GetMonthName
'apos;//
'apos;// Modification history.
'apos;// ---------------------
'apos;// 6/1/20. wmk. original code
'apos;// 6/2/20. wmk. error handling setup added
'apos;// 6/3/20. wmk. csERRBADDATE constant added
'apos;// 6/5/20. wmk. bug fix; was not detecting 2nd line Debit and Credit empty
'apos;// 7/3/20. wmk. sERRCOANOTFOUND corrected to csERRCOANOTFOUND
'apos;// Notes.
'apos;//
const csERRCOANOTFOUND="quot;ERRCOANOTFOUND"quot;
const csERROUTOFROOM="quot;ERROUTOFROOM"quot;
const csERRCOACHANGED="quot;ERRCOACHANGED"quot;
'apos;//----------in Module error handling setup-------------------------------
'apos;// LogError setup snippet.
const csERRUNKNOWN="quot;ERRUNKNOWN"quot;
const sMyName="quot;CheckDoubleEntry"quot;
'apos;// add additional error code strings here...
Dim sErrName as String 'apos;// error name for LogError
Dim sErrMsg As String 'apos;// error message for LogError
'apos;//*---------error handling setup---------------------------
'apos;// ErrLogGetModule() - get current module name gsErrModule
'apos;// ErrLogSetModule(sName) - set current module name gsErrModule
'apos;// ErrLogGetCellInfo(lColumn, lRow) - get error focus cell column, row
'apos;// ErrLogSetCellInfo(lColumn, lRow) - set error focus cell column, row
'apos;// ErrLogGetSheet - Get sheet index from error log globals.
'apos;// ErrLogSetSheet - Set sheet index in error log globals.
dim iErrSheetIx as Integer
dim lErrColumn as Long
dim lErrRow as Long
dim sErrCurrentMod As String
'apos;//----------end in Module error handling setup---------------------------
'apos;// constants.
'apos;// process control constants.
const ERRCONTINUE=-1 'apos;// error, but continue with next transaction
const ERRSTOP=-2 'apos;// error, stop processing transactions
const csERRBADDATE="quot;ERRBADDATE"quot; 'apos;// bad date error name
'apos;// local variables.
dim iRetValue As Integer
dim iBrkPt As Integer 'apos;// easy breakpoint
dim iStatus As Integer 'apos;// general status var
'apos;//------------ CheckDoubleEntry code begins here---------------------------
'apos;// Usage. iVal = CheckDoubleEntry(oTransRange, rpsMonth, rpsAcct1,
'apos;// rpsAcct2)
dim Doc As Object
dim oSheets as Object
dim oGLSheet as Object 'apos;// ledger sheet
dim iSheetIx As Integer 'apos;// sheet index of ledger
dim bTransValid As Boolean 'apos;// transaction is valid flag
dim bADEmpty As Boolean 'apos;// 1st Debit/2nd Credit empty flag
dim bBCEmpty As Boolean 'apos;// 1st Credit/2nd Debit empty flag
'apos;// Cell access objects for first transaction line.
dim oCellDate as Object 'apos;// Date cell
dim oCellTrans As Object 'apos;// Transaction cell
dim oCellDebit As Object 'apos;// Debit cell
dim oCellCredit As Object 'apos;// Credit cell
dim oCellAcct As Object 'apos;// COA cell
dim oCellRef As Object 'apos;// Reference cell
dim sDate as String 'apos;// Date string
dim sTrans as String 'apos;// Transaction string
dim sStyle as String 'apos;// Style property
dim lDateFormat As Long 'apos;// date format code
dim sMonth As String 'apos;// month name
dim lGLCurrRow As Long 'apos;// first row of double entry
dim lGLNextRow As Long 'apos;// 2nd row of double entry
dim lGLEndRow As Long 'apos;// end of ledger selection by user
dim sDebit As String 'apos;// Debit field
dim sCredit As String 'apos;// Credit field
dim sAcct As String 'apos;// COA field
'apos;// Cell access objects for 2nd transaction line.
dim oCellDateB as Object 'apos;// Date cell
dim oCellTransB As Object 'apos;// Transaction cell
dim oCellDebitB As Object 'apos;// Debit cell
dim oCellCreditB As Object 'apos;// Credit cell
dim oCellAcctB As Object 'apos;// COA cell
dim oCellRefB As Object 'apos;// Reference cell
dim sDateB As String
dim sTransB As String
dim sStyleB As String
dim lDateBFormat As Long
dim sDebitB As String
dim sCreditB As String
dim sAcctB As String
'apos;// code.
'apos;//*------------error handling code initialization---------------
'apos;// preserve entry error settings.
iErrSheetIx = ErrLogGetSheet()
ErrLogGetCellInfo(lErrColumn, lErrRow)
sErrCurrentMod = ErrLogGetModule()
'apos;//*
'apos;// set local error settings.
ErrLogSetModule(sMyName)
ErrLogSetSheet(poTransRange.Sheet)
ErrLogSetCellInfo(COLDATE, poTransRange.StartRow)
ErrLogSetRecording(true) 'apos;// enable log entries
'apos;//*----------end error handling code initialization-------------
iRetValue = 0
iStatus = 0
'apos; poTransRange.Sheet = iSheetIx of ledger spreadsheet
'apos; poTransRange.StartColumn = COLDATE
'apos; poTransRange.StartRow = lGLCurrRow
'apos; poTransRange.EndColumn = COLREF
'apos; poTransRange.EndRow = lGLCurrRow + 1
'apos;// Access ledger sheet from passed information
iSheetIx = poTransRange.Sheet
Doc = ThisComponent
oSheets = Doc.getSheets()
oGLSheet = oSheets.GetByIndex(iSheetIx)
lGLCurrRow = poTransRange.StartRow
lGLEndRow = poTransRange.EndRow
'apos;// load 1st transaction line row from GL sheet
oCellDate = oGLSheet.getCellByPosition( COLDATE, lGLCurrRow)
oCellTrans = oGLSheet.getCellByPosition( COLTRANS, lGLCurrRow)
oCellDebit = oGLSheet.getCellByPosition( COLDEBIT, lGLCurrRow)
oCellCredit = oGLSheet.getCellByPosition( COLCREDIT, lGLCurrRow)
oCellAcct = oGLSheet.getCellByPosition( COLACCT, lGLCurrRow)
oCellRef = oGLSheet.getCellByPosition( COLREF, lGLCurrRow)
'apos;// extract date &'apos;amp; transaction information from 1st row
sDate = oCellDate.String
sTrans = oCellTrans.String
'apos;// Ensure nonempty date field before GetMonthName call
if Len(Trim(sDate)) = 0 then
sErrName = "quot;ERRBADDATE"quot;
sErrMsg = "quot;1st Date field empty - skipping"quot;
iStatus = ERRSTOP
GoTo DateError
endif
iBrkpt=1
sStyle = oCellDate.Text.CellStyle
lDateFormat = oCellDate.Text.NumberFormat
sMonth = GetMonthName(sDate) 'apos;// get month search name
iBrkpt = 1 'apos;// breakpoint line
'apos;// load 2nd transaction line row from GL sheet
lGLNextRow = lGLCurrRow + 1
'apos;// check that 2nd row is not beyond selection
if lGLNextRow &'apos;gt; lGLEndRow then
'apos; iStatus = msgBox("quot;Selection ends in mid-transaction!"quot;_
'apos; +CHR(13)+CHR(10)+ "quot;Check last row selection of transaction"quot;)
oCellDate.Text.CellBackColor = YELLOW
sErrName = "quot;ERRODDROWS"quot;
sErrMsg = "quot;Selection ends in mid-transaction!"quot;_
+CHR(13)+CHR(10)+ "quot;Check last row selection of transaction"quot;
Call LogError(sErrName, sErrMsg)
iRetValue = ERRSTOP
GoTo AdvanceTrans
'apos;exit For
endif 'apos;// end would advance past last row conditional
'apos;// load 2nd line transaction values
oCellDateB = oGLSheet.getCellByPosition( COLDATE, lGLNextRow)
oCellTransB = oGLSheet.getCellByPosition( COLTRANS, lGLNextRow)
oCellDebitB = oGLSheet.getCellByPosition( COLDEBIT, lGLNextRow)
oCellCreditB = oGLSheet.getCellByPosition( COLCREDIT, lGLNextRow)
oCellAcctB = oGLSheet.getCellByPosition( COLACCT, lGLNextRow)
oCellRefB = oGLSheet.getCellByPosition( COLREF, lGLNextRow)
'apos;XRay oCellDateB
'apos;// extract date information from 2nd row of transaction
sDateB = oCellDateB.Text.String
'apos;// Ensure nonempty date field before GetMonthName call
if Len(Trim(sDateB)) = 0 then
sErrName = "quot;ERRBADDATE"quot;
sErrMsg = "quot;2nd Date field empty - skipping"quot;
GoTo DateError
endif
sStyleB = oCellDateB.Text.CellStyle
lDateBFormat = oCellDateB.Text.NumberFormat
'apos; sMonth = GetMonthName(sDate) 'apos;// use month from 1st line
iBrkpt = 1 'apos;// breakpoint line
'apos;// make sure dates, descriptions, and amounts agree
'apos;// if not, issue message box and bail out
iStatus = StrComp(sDate, sDateB)
if iStatus &'apos;lt;&'apos;gt; 0 then
sErrName = csERRBADDATE
sErrMsg = "quot;Transaction date mismatch!"quot;+CHR(13)+CHR(10)_
+ "quot;Check 1st row selection of transaction"quot;
GoTo DateError
endif
GoTo CheckDesc
'apos;//----------Date Error handler-------------------------------
iBrkpt = 1
'apos;// Date error(s) are terminating errors; iRetVal = -2
DateError:
if iStatus &'apos;lt;&'apos;gt; 0 then
'apos;// log error and set Date Cell YELLOW
oCellDate.Text.CellBackColor = YELLOW
Call LogError(sErrName, sErrMsg)
iRetValue = ERRSTOP 'apos;// bail out on return
GoTo AdvanceTrans
endif 'apos;// end any date error conditional
'apos;//-------end Date Error Handler-----------------------------
CheckDesc:
iBrkpt = 1 'apos;// breakpoint line
'apos;// extract transaction information from both rows
'apos;// make sure that descriptions agree
sTrans = oCellTrans.String
sTransB = oCellTransB.String
iStatus = strComp(sTrans, sTransB)
if iStatus &'apos;lt;&'apos;gt; 0 then
'apos; iStatus = msgBox("quot;Transaction description mismatch!"quot;+CHR(13)+CHR(10)_
'apos; + "quot;Check transaction"quot;)
sErrName = "quot;ERRDESCNOMATCH"quot;
sErrMsg = "quot;Transaction description mismatch!"quot;+CHR(13)+CHR(10)_
+ "quot;Check transaction"quot;
Call LogError(sErrName, sErrMsg)
oCellDate.Text.CellBackColor = YELLOW
oCellDateB.Text.CellBackColor = YELLOW
iRetValue = ERRSTOP 'apos;// force stop on return
GoTo AdvanceTrans
endif 'apos;// end descriptions not same
'apos;// extract debit and credit amounts for both halves of transaction
'apos;// ensure both halves have same amount, if not, bail out
sDebit = oCellDebit.Text.String
sCredit = oCellCredit.Text.String
sDebitB = oCellDebitB.Text.String
sCreditB = oCellCreditB.Text.String
'apos;//-------------------------------------------------------------------------
'apos;// ensure that is actual double entry; either debit on 1st line and
'apos;// Credit on second line are same amount, or Credit on 1st line
'apos;// and Debit on second line are same amount etc.
'apos;// Debit Credit
'apos;// A B sDebit and sCredit
'apos;// C D sDebitB and sCreditB
'apos;// A=D and B=C correct
'apos;// if A and D empty, B and C must be nonempty
'apos;// if B and C empty, A and D must be nonempty
'apos;//-------------------------------------------------------------------------
iBrkpt = 1
'apos; dim bTransValid as boolean
'apos; dim bADEmpty as boolean
'apos; dim bBCEmpty as boolean
bTransValid = (StrComp(sDebit,sCreditB) = 0) AND (StrComp(sCredit,sDebitB)=0)
bTransValid = bTransValid AND ((Len(sDebit) &'apos;gt; 0) OR (Len(sCredit) &'apos;gt; 0))_
AND ((Len(sCreditB) &'apos;gt; 0) OR (Len(sDebitB) &'apos;gt; 0)) 'apos;// mod060520
bADEmpty = (Len(sDebit)=0) AND (Len(sCreditB)=0)
bBCEmpty = (Len(sCredit)=0) AND (Len(sDebitB)=0)
bTransValid = bTransValid AND ((bADEmpty AND (Not bBCEmpty))_
OR (bBCEmpty AND (Not bADEmpty))) 'apos;// mod052020
if Not bTransValid then
'apos;// message, flag both lines, skip
'apos; iStatus = msgBox("quot;Invalid transaction...check Debit and Credit values!"quot;+CHR(13)+CHR(10)_
'apos; +"quot;Transaction skipped"quot;)
sErrName = "quot;ERRDEB&'apos;lt;&'apos;gt;CRED"quot;
sErrMsg = "quot;Invalid transaction...check Debit and Credit values!"quot;+CHR(13)+CHR(10)_
+"quot;Transaction skipped"quot;
Call LogError(sErrName, sErrMsg)
oCellDate.Text.CellBackColor = YELLOW
oCellDateB.Text.CellBackColor = YELLOW
iRetValue = ERRCONTINUE
GoTo AdvanceTrans
endif 'apos;// end invalid transaction
'apos;// extract COA account numbers for both halves of transaction
sAcct = oCellAcct.String
sAcctB = oCellAcctB.String
iBrkpt = 1
'apos;// ensure both halves have COA account number; if not, just skip
if Len( sAcct ) &'apos;lt;&'apos;gt; 4 OR Len(sAcctB) &'apos;lt;&'apos;gt; 4 then
iStatus = msgBox("quot;Transaction contains invalid COA number(s)!"quot;_
+CHR(13)+CHR(10)+ "quot;Check 1st row selection of transaction"quot;)
sErrName = csERRCOANOTFOUND
sErrMsg = "quot;Transaction contains invalid COA number(s)!"quot;_
+CHR(13)+CHR(10)+ "quot;Check 1st row selection of transaction"quot;
Call LogError(sErrName, sErrMsg)
oCellDate.Text.CellBackColor = YELLOW
oCellDateB.Text.CellBackColor = YELLOW
'apos;// Note. have to do the following rather than use if-then-else to loop
'apos;// again, since this Basic does not support "quot;Continue For"quot;
iRetValue = ERRCONTINUE 'apos;// force Advance to next on return
GoTo AdvanceTrans
endif 'apos;// end length not == 4
'apos;// set returned month and COA accounts
rpsMonth = sMonth
rpsAcct1 = sAcct
rpsAcct2 = sAcctB
AdvanceTrans:
'apos;//*-----------------restore error handling for caller-----------
'apos;// restore entry error settings.
ErrLogSetModule(sErrCurrentMod)
ErrLogSetSheet(iErrSheetIx)
ErrLogSetCellInfo(lErrColumn, lErrRow)
'apos;//*----------end error handling setup---------------------------
'apos;// iRetValue = 0, no error
'apos;// ERRCONTINUE (-1) - error; continue with next transaction
'apos;// ERRSTOP (-2) - error; stop processing transactions
CheckDoubleEntry = iRetValue
end function 'apos;// end CheckDoubleEntry 7/3/20
'apos;/**/
'apos;// CheckInserts.bas
'apos;//------------------------------------------------------------------
'apos;// CheckInserts - Check target COA sheet(s) for insertion available.
'apos;// 7/3/20. wmk.
'apos;//------------------------------------------------------------------
public function CheckInserts(psMonth As String, psAcct1 As String,_
psAcct2 As String, rpoCat1Range As Object, rpoCat2Range As Object) as Integer
'apos;// Usage. iVal = CheckInserts(sMonth, sAcct1, sAcct2, oCat1Range, oCat2Range)
'apos;//
'apos;// sMonth = Month name string (e.g. "quot;January"quot;)
'apos;// sAcct1 = COA from 1st line of transaction
'apos;// sAcct2 = COA from 2nd line of transaction
'apos;// rpoCat1Range = (returned)
'apos;// rpoCat2Range = (returned)
'apos;//
'apos;// Entry. Spreadsheet has category sheets for all possible COA #s
'apos;//
'apos;// Exit. rplIns1Ptr = row for insertion of line 1 transaction
'apos;// rplIns2Ptr = row for insertion of line 2 transaction
'apos;//
'apos;// Calls. GetInsRow.
'apos;//
'apos;// Modification history.
'apos;// ---------------------
'apos;// 6/1/20. wmk. original code; stub
'apos;// 6/2/20. wmk. code transported from within PlaceTransM; error handling
'apos;// set up
'apos;// 6/8/20. wmk. bug fix where sCOA1Msg and sCOA2Msg not declared
'apos;// 7/3/20. wmk. bug fix in error handling using lGLCurrRow, needs lErrRow
'apos;//
'apos;// Notes. Passed paramters are COA #s; they will be used to access the
'apos;// correct account catgory sheets, for the month of the transaction
'apos;//
'apos;// constants.
'apos;// insert error codes.
const ERRCOANOTFOUND=-1
const ERROUTOFROOM=-2
const ERRNOCOAMONTH=-3
const sERRCOANOTFOUND="quot;ERRCOANOTFOUND"quot;
const sERROUTOFROOM="quot;ERROUTOFROOM"quot;
const sERRNOCOAMONTH="quot;ERRNOCOAMONTH"quot;
const sERRUNKNOWN="quot;ERRUNKNOWN"quot;
'apos;//----------in Module error handling setup-------------------------------
'apos;// LogError setup snippet.
const csERRUNKNOWN="quot;ERRUNKNOWN"quot;
const sMyName="quot;CheckInserts"quot;
'apos;// add additional error code strings here...
Dim sErrName as String 'apos;// error name for LogError
Dim sErrMsg As String 'apos;// error message for LogError
'apos;//*---------error handling setup---------------------------
'apos;// ErrLogGetModule() - get current module name gsErrModule
'apos;// ErrLogSetModule(sName) - set current module name gsErrModule
'apos;// ErrLogGetCellInfo(lColumn, lRow) - get error focus cell column, row
'apos;// ErrLogSetCellInfo(lColumn, lRow) - set error focus cell column, row
'apos;// ErrLogGetSheet - Get sheet index from error log globals.
'apos;// ErrLogSetSheet - Set sheet index in error log globals.
dim iErrSheetIx as Integer
dim lErrColumn as Long
dim lErrRow as Long
dim sErrCurrentMod As String
'apos;//----------end in Module error handling setup---------------------------
'apos;// process control constants.
const ERRCONTINUE=-1 'apos;// error, but continue with next transaction
const ERRSTOP=-2 'apos;// error, stop processing transactions
'apos;// local variables.
dim iRetValue As Integer 'apos;// function returned value
dim sMonth As String 'apos;// local month
'apos;// Object setup variables.
dim oDoc As Object 'apos;// ThisComponent
dim oSheets As Object 'apos;// Doc.getSheets()
'apos;// COA Sheet processing variables.
dim sAcct As String 'apos;// first line COA#
dim sAcctB As String 'apos;// second line COA#
dim sAcctCat1 as String 'apos;// accounting category of 1st line of transaction
dim sAcctCat2 as String 'apos;// account category of 2nd line of transaction
dim bSameAcctCat as boolean 'apos;// account categories the same flag
dim oCat1Sheet As Object 'apos;// COA sheet for 1st transaction line
dim oCat2Sheet As Object 'apos;// COA sheet for 2nd transaction line
dim bSameCOA As Boolean 'apos;// COAs match flag
dim lCat1InsRow As Long 'apos;// COA sheet insertion row, line 1
dim lCat2InsRow As Long 'apos;// COA sheet insertion row, line 2
dim sBadCOA As String 'apos;// first COA bad string
dim sBadCOA2 As String 'apos;// second COA bad string
dim iStatus As Integer 'apos;// processing status flag
dim sCOA1Msg As String 'apos;// COA1 error message string
dim sCOA2Msg As String 'apos;// COA2 error message string
'apos;// code.
iRetValue = 0
iStatus = 0 'apos;// clear general status
'apos; rplIns1Ptr = -1 'apos;// set bad pointers for return
'apos; rplIns2Ptr = -1
sMonth = psMonth 'apos;// set local copy of passed month
'apos;//*------------error handling code initialization---------------
'apos;// preserve entry error settings.
iErrSheetIx = ErrLogGetSheet()
ErrLogGetCellInfo(lErrColumn, lErrRow)
sErrCurrentMod = ErrLogGetModule()
'apos;//*
'apos;// set local error settings.
ErrLogSetModule(sMyName)
'apos;// keep entry sheet/cell selctions, since errors will be in GL
'apos; ErrLogSetSheet(poTransRange.Sheet)
'apos; ErrLogSetCellInfo(COLDATE, poTransRange.StartRow)
ErrLogSetRecording(true) 'apos;// enable log entries
'apos;//*----------end error handling code initialization-------------
CheckInserts = iRetValue
'apos; if true then
'apos; Exit Function
'apos; endif
'apos;//---------------end stub code--------------------
'apos;//-----------------CheckInserts code starts here----------------------------------------
'apos;//
'apos;// Usage. iVal = CheckInserts(psMonth, psAcct1, psAcct2, rplIns1Ptr, rplIns2Ptr)
'apos;//
'apos;// psMonth = Month name string (e.g. "quot;January"quot;)
'apos;// psAcct1 = COA from 1st line of transaction
'apos;// psAcct2 = COA from 2nd line of transaction
'apos;// rplIns1Ptr = (returned)
'apos;// rplIns2Ptr = (returned)
'apos;//
'apos;// get appropriate sheet names from COA account numbers
iStatus = 0 'apos;// clear processing exceptions
sAcct = psAcct1 'apos;// copy COAs to local vars
sAcctB = psAcct2
sAcctCat1 = GetTransSheetName(sAcct)
sAcctCat2 = GetTransSheetName(sAcctB)
bSameAcctCat = (StrComp(sAcctCat1, sAcctCat2) = 0)
dim iBrkpt As Integer
iBrkpt = 1
'apos;// set up oCat1Sheet as sheet object for first half of transaction
'apos;// oCat2Sheet as sheet object for second half of transaction
'apos;static oCat1Sheet as Object 'apos;// account sheet object of 1st category in transaction
'apos;static oCat2Sheet as Object 'apos;// account sheet object of 2nd category in transaction
'apos;dim lCat1InsRow as long 'apos;// insert index for 1st category in transaction
'apos;dim lCat2InsRow as long 'apos;// insert index for 2nd cateory in transaction
'apos;XRay Doc
oDoc = ThisComponent
oSheets = oDoc.getSheets()
'apos;XRay oSheets
'apos;// check if same sheet, and just copy instance 'apos;// mod051920
oCat1Sheet = oSheets.getByName(sAcctCat1)
if bSameAcctCat then
oCat2Sheet = oCat1Sheet
else
oCat2Sheet = oSheets.getByName(sAcctCat2)
endif
rpoCat1Range.Sheet = oCat1Sheet.RangeAddress.Sheet
rpoCat2Range.Sheet = oCat2Sheet.RangeAddress.Sheet
'apos;XRay oCat1Sheet
iBrkpt=1
'apos;// check here if COA#s different; if not, will bail out later 'apos;// mod051920
bSameCOA = StrComp(sAcct, sAcctB) = 0 'apos;// mod051920
lCat1InsRow = GetInsRow(oCat1Sheet, sAcct, sMonth) 'apos;// mod051920
if bSameCOA then 'apos;// mod051920
'apos;// Note: might get away with setting same insertion row, since will
'apos;// insert 2 lines... for now, skipped
lCat2InsRow = lCat1InsRow 'apos;// mod051920
else 'apos;// mod051920
lCat2InsRow = GetInsRow(oCat2Sheet, sAcctB, sMonth) 'apos;// mod051920
endif 'apos;// end same COA conditional 'apos;// mod051920
'apos;// add code to verify have a row in each sheet before committing to change
'apos;dim lBadRow1 as long 'apos;// 1st acct insert row return value
'apos;dim lBadRow2 as lont 'apos;// 2nd acct insert row return value
if lCat1InsRow &'apos;lt; 0 OR lCat2InsRow &'apos;lt; 0 then
'apos;// issue appropriate message and don'apos;t mark rows as processed
sBadCOA = "quot;"quot;
sBadCOA2 = "quot;"quot;
'apos;// handle transaction line 1 error.
if lCat1InsRow &'apos;lt; 0 then
sBadCOA = sAcct
sCOA1Msg = "quot;"quot; 'apos;// clear line 1 message
ErrLogSetSheet(oCat1Sheet.RangeAddress.Sheet)
ErrLogSetCellInfo(COLDATE, lErrRow)
Select Case lCat1InsRow
'apos; Case -1
Case ERRCOANOTFOUND
sCOA1Msg = "quot;Account "quot;+sBadCOA+"quot; not found"quot;
sErrName = sERRCOANOTFOUND
'apos; Case -2
Case ERROUTOFROOM
sCOA1Msg = "quot;Account "quot;+sBadCOA+"quot; month "quot;+sMonth+"quot; not enough rows"quot;_
+"quot; to insert"quot;
sErrName = sERROUTOFROOM
'apos; Case -3
Case ERRNOCOAMONTH
sCOA1Msg = "quot;Account "quot;+sBadCOA+"quot; month "quot;+sMonth+"quot; not found"quot;
sErrName = sERRNOCOAMONTH
Case else
sCOA1Msg = "quot;Account "quot;+sBadCOA+"quot;Undocumented error"quot;
sErrName = sERRUNKNOWN
end Select
sErrMsg = sCOA1Msg
Call LogError(sErrName, sErrMsg)
endif 'apos;// end error in 1st line conditional
if lCat2InsRow &'apos;lt; 0 then
sBadCOA2 = sAcctB
sCOA2Msg = "quot;"quot; 'apos;// clear line 2 message
Select Case lCat2InsRow
'apos; Case -1
Case ERRCOANOTFOUND
sCOA2Msg = "quot;Account "quot;+sBadCOA2+"quot; not found"quot;
sErrName = sERRCOANOTFOUND
'apos; Case -2
Case ERROUTOFROOM
sCOA2Msg = "quot;Account "quot;+sBadCOA2+"quot; month "quot;+sMonth+"quot; not enough rows"quot;_
+"quot; to insert"quot;
sErrName = sERROUTOFROOM
'apos; Case -3
Case ERRNOCOAMONTH
sCOA2Msg = "quot;Account "quot;+sBadCOA2+"quot; month "quot;+sMonth+"quot; not found"quot;
sErrName = sERRNOCOAMONTH
sCOA2Msg = "quot;Account "quot;+sBadCOA2+"quot;Undocumented error"quot;
sErrName = sERRUNKNOWN
end Select
sErrMsg = sCOA2Msg
Call LogError(sErrName, sErrMsg) 'apos;// log error and continue
endif 'apos;// end bad line 2 insert row conditional
iStatus = ERRCONTINUE 'apos;// flag error to continue with next transaction
'apos; msgBox(sCOA1Msg+CHR(13)+CHR(10) + sCOA2Msg)
'apos;// advance to next transaction
GoTo AdvanceTrans
endif 'apos;// end problem with either COA insert conditional
'apos;// no problems, set returned insertion rows
'apos; rplIns1Ptr = lCat1InsRow
'apos; rplIns2Ptr = lCat2InsRow
rpoCat1Range.StartRow = lCat1InsRow
rpoCat2Range.StartRow = lCat2InsRow
rpoCat1Range.EndRow = lCat1InsRow
rpoCat2Range.EndRow = lCat2InsRow
rpoCat1Range.StartColumn = COLDATE
rpoCat2Range.StartColumn = COLDATE
rpoCat1Range.EndColumn = COLREF
rpoCat2Range.EndColumn = COLREF
AdvanceTrans:
'apos;//*-----------------restore error handling for caller-----------
'apos;// restore entry error settings.
ErrLogSetModule(sErrCurrentMod)
ErrLogSetSheet(iErrSheetIx)
ErrLogSetCellInfo(lErrColumn, lErrRow)
'apos;//*----------end error handling setup---------------------------
'apos;// iStatus = 0, no error
'apos;// ERRCONTINUE (-1) - error; continue with next transaction
'apos;// ERRSTOP (-2) - error; stop processing transactions
iRetValue = iStatus 'apos;// set returned status
CheckInserts = iRetValue
end function 'apos;// end CheckInserts 7/3/20
'apos;/**/
'apos;// CheckSplitTrans.bas
'apos;//---------------------------------------------------------------
'apos;// CheckSplitTrans - Check split transaction for validity.
'apos;// 7/4/20. wmk. 10:45
'apos;/---------------------------------------------------------------
function CheckSplitTrans(poGLSheet as Object, plSplit1stRow as Long )_
as Long
'apos;// Usage. lSplitEndRow = CheckSplitTrans(oGLSheet, lSplit1stRow)
'apos;// call PlaceSplitTrans( oGLSheet, lSplit1stRow )
'apos;//
'apos;// oGLSheet = GL sheet object
'apos;// lSplit1stRow = row index of first row of split transaction
'apos;//
'apos;// Entry. GL sheet processing has found row with "quot;split"quot; as the
'apos;// .Text.String value in COLSPLIT. The split entry contains
'apos;// multiple rows until another row is found with "quot;split"quot; as the
'apos;// .Text.String value in COLSPLIT. The second row of the split
'apos;// transaction MUST contain the COA target and the total amount
'apos;// of the split, regardless of whether it is a Debit or Credit.
'apos;// Subsequent rows contain the amounts split into the opposing
'apos;// COAs, and their value sums MUST equal the COA target amount.
'apos;//
'apos;// Exit. lSplitEndRow = last row of split, "quot;split"quot; in COLSPLIT
'apos;// &'apos;lt; 0 - error in split transaction
'apos;// -1 - (ERRNOTSPLIT) first row not "quot;split"quot; in COLSPLIT
'apos;// -2 - (ERRBADTALLY) split values don'apos;t add to total
'apos;// -3 - (ERRROWSEXCEEDED) too many/few rows before second "quot;split"quot;
'apos;// -4 - (ERRBADVALS) bad Debit/Credit values
'apos;// -5 - (ERRBADDATE) Date field too short
'apos;// -6 - (ERRDATENOTSAME) Date field doesn'apos;t match others
'apos;// -7 - (ERRSPLITDESC) "quot;split"quot; descriptions don'apos;t match
'apos;//
'apos;// Calls. ErrLogGetModule, ErrLogGetCellInfo, ErrLogGetSheet,
'apos;// ErrLogSetSheet, ErrLogSetModule, ErrLogSetCellInfo,
'apos;// LogError
'apos;//
'apos;// Modification history.
'apos;// ---------------------
'apos;// 5/22/20 wmk. original code
'apos;// 5/23/20 wmk. bug fix where not tallying properly; fix bug where
'apos;// empty Date field within loop range checking rows
'apos;// 5/24/20. wmk. documentation added on .Type cell property; modify
'apos;// bad row Date cell with own content to update color
'apos;// 5/27/20. wmk. include new error handling capability
'apos;// 5/28/20. wmk. error handling improvements and documentation
'apos;// 6/5/20. wmk. added check to ensure that transaction desc
'apos;// matches in both "quot;split"quot; lines; added check to
'apos;// ensure that all dates are the same in all
'apos;// transaction lines; cell addresses updated for
'apos;// all error reporting conditions
'apos;// 7/4/20. wmk. double check tally value mismatch with strings to
'apos;// correct issue where 9.62 did not match the sum
'apos;// of 4.81 and 4.81
'apos;//
'apos;// Notes.
'apos;// ensure current row has "quot;split"quot; in COLSPLIT field; return -1 if not
'apos;// determine how many rows are in the "quot;split"quot;, searching for next
'apos;// row with "quot;split"quot;; set some sort of maximum so don'apos;t search forever
'apos;// if maximum exceeded return -3
'apos;// ensure that total values form split rows = total in 1st row
'apos;// if not, return -2
'apos;// set up cat1 sheet to point to total'apos;s category/account sheet
'apos;// loop processing split rows, setting up cat2 sheet to point to
'apos;// each category/account sheet
'apos;// on successful exit, point to last row with "quot;split"quot; in COLSPLIT field
'apos;// Programming notes. oCell.Type returns the cell type {EMPTY,VALUE,TEXT
'apos;// FORMULA). The Value, String, and Formula properties are used to
'apos;// set the values of a cell.
'apos;// constants.
'apos;// local contants. (common with PlaceSplitTrans)
const MAXSPLITROWS=10 'apos;// maximum rows in "quot;split"quot; transaction
const MINROWLIMIT=1 'apos;// 0-based index minimum total row index
const MINDATELEN=6 'apos;// minimum Date string length
const ERRNOTSPLIT=-1 'apos;// first row not "quot;split"quot; in COLSPLIT
const ERRBADTALLY=-2 'apos;// split values don'apos;t add to total
const ERRROWSEXCEEDED=-3 'apos;// too many/few rows before second "quot;split"quot;
const ERRBADVALS=-4 'apos;// bad Debit/Credit values
const ERRBADDATE=-5 'apos;// Date field too short
const ERRDATENOTSAME=-6 'apos;// Date field doesn'apos;t match others 'apos;// mod060520
const ERRSPLITDESC=-7 'apos;// "quot;split"quot; descriptions don'apos;t match 'apos;// mod060520
const COLSPLIT=5 'apos;// "quot;split"quot; column
const csSplit="quot;split"quot; 'apos;// split row identifier string
'apos;// local variables.
dim oCellSplit as Object 'apos;// cell from COLSPLIT column
dim oGLSheet as Object 'apos;// local ptr to poGLSheet
dim oCellCredit as Object 'apos;// credit field
dim oCellDebit as Object 'apos;// debit field
'apos;// other local vars.
dim iBrkPt as integer 'apos;// easy breakpoint reference
dim lRetValue as long 'apos;// returned value
dim bBadSplit as Boolean 'apos;// bad split flag
dim sSplit As String 'apos;// COLSPLIT .Text.String
dim lSplitCount as long 'apos;// split row count
dim i as integer 'apos;// loop counter
dim lGLCurrRow as Long 'apos;// GL current row
dim bFoundSplit as boolean 'apos;// found "quot;split"quot; 2nd time
dim lTrans1stRow as long 'apos;// transaction 1st row
dim dTransTotal as Double 'apos;// split entered total
dim dSplitTally as Double 'apos;// split tallied total
dim dDebitVal as Double 'apos;// Debit value
dim dCreditVal as Double 'apos;// Credit value
dim bDebitSplits as boolean 'apos;// first line is Debit flag
dim sDebit as String 'apos;// debit value string
dim sCredit as String 'apos;// credit value string
dim lGLStartRow as Long 'apos;// start row
dim dAddAmt as Double 'apos;// amount to add to tally
dim sSourceAcct as String 'apos;// source account being split
dim oCellDate as Object 'apos;// cell Date from transaction row
dim sDate As String 'apos;// cell Date string from transaction 'apos;// mod060520
dim sDateSplit As String 'apos;// Date field from first "quot;split"quot; line 'apos;// mod060520
dim oCellTrans As Object 'apos;// cell Transaction desc from row 'apos;// mod060520
dim sTrans As String 'apos;// transaction from end "quot;split"quot; line 'apos;// mod060520
dim sTransSplit As String 'apos;// Transaction from 1st "quot;split"quot; line 'apos;// mod060520
dim bDateMatched As Boolean 'apos;// Date field(s) all match flag 'apos;// mod060520
dim sErrMsg as String 'apos;// error message
dim sErrCode As String 'apos;// error code string
'apos;// code.
lRetValue = ERRNOTSPLIT 'apos;// set error return
'apos;//*---------end error handling setup---------------------------
'apos;// ErrLogGetModule() - get current module name gsErrModule
'apos;// ErrLogSetModule(sName) - set current module name gsErrModule
'apos;// ErrLogGetCellInfo(lColumn, lRow) - get error focus cell column, row
'apos;// ErrLogSetCellInfo(lColumn, lRow) - set error focus cell column, row
'apos;// ErrLogGetSheet - Get sheet index from error log globals.
'apos;// ErrLogSetSheet - Set sheet index in error log globals.
dim iErrSheetIx as Integer
dim lErrColumn as Long
dim lErrRow as Long
dim sErrCurrentMod As String
'apos;//*
'apos;// preserve entry error settings.
iErrSheetIx = ErrLogGetSheet()
ErrLogGetCellInfo(lErrColumn, lErrRow)
sErrCurrentMod = ErrLogGetModule()
'apos;//*
'apos;// set local error settings.
ErrLogSetModule("quot;CheckSplitTrans"quot;)
ErrLogSetSheet(poGLSheet.RangeAddress.Sheet)
ErrLogSetCellInfo(COLSPLIT, plSplit1stRow)
'apos;//*----------end error handling setup---------------------------
'apos;// ensure current row has "quot;split"quot; in COLSPLIT field;
'apos;// return ERRNOTSPLIT if not
lGLCurrRow = plSplit1stRow
lGLStartRow = plSplit1stRow
lTrans1stRow = lGLCurrRow + 1 'apos;// transaction first data row
'apos; oGLSheet = poGLSheet
oCellSplit = poGLSheet.getCellByPosition(COLSPLIT, lGLCurrRow)
sSplit = oCellSplit.Text.String
bBadSplit = (StrComp(sSplit, csSplit) &'apos;lt;&'apos;gt; 0)
lRetValue = ERRNOTSPLIT 'apos;// set initial error
iBrkPt=1
if bBadSplit then
lRetValue = ERRNOTSPLIT
GoTo Bailout
endif 'apos;// end not "quot;split"quot;
'apos;// preserve Date field from "quot;split"quot; 1st row 'apos;// mod060520
oCellDate = poGLSheet.getCellByPosition(COLDATE, lGLCurrRow) 'apos;// mod060520
sDateSplit = oCellDate.String 'apos;// mod060520
'apos;// date must be at least #/#/## long 'apos;// mod060520
if Len(sDateSplit) &'apos;lt; MINDATELEN then 'apos;// mod060520
ErrLogSetCellInfo(COLDATE, lGLCurrRow) 'apos;// mod060520
lRetValue = ERRBADDATE 'apos;// mod060520
GoTo BailOut 'apos;// mod060520
endif 'apos;// end date too short conditional 'apos;// mod060520