forked from layerfsd/Roomer-PMS-1
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathuD.pas
15517 lines (13795 loc) · 513 KB
/
uD.pas
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
unit uD;
interface
{$I Roomer.inc}
uses
SysUtils
, TypInfo
, IOUtils
, Classes
, uDReportData
, System.Generics.Collections
, System.variants
, DB
, ImgList
, Controls
, Dialogs
, Graphics
, Forms
, Menus
, winProcs
, ADODB
, dbTables
, ExtCtrls
, cxGrid
, uRegistryServices
, dateUtils
, ug
, _glob
, hData
, ColCombo
, NativeXml
, kbmMemTable
, dxmdaset
, cxClasses
, cxStyles
, cxGridTableView
, cxGraphics
, cxEdit
, cxContainer
, frxClass
, frxADOComponents
, frxDBSet
, frxExportImage
, frxExportRTF
, frxExportHTML
, frxExportPDF
, frxDesgn
, uRoomerDefinitions
, uReservationStateDefinitions
, cmpRoomerDataSet
, cmpRoomerConnection
, cxEditRepositoryItems, ALHttpClient, ALWininetHttpClient, uMarketDefinitions
, uBreakfastTypeDefinitions, uAmount
, uHotelServicesSettings
;
type
// Todo: Redefine TKeyValuePairList as a dictionary where TKeyAndValue is a simple TPair<string, string>
TKeyAndValue = class
private
FKey: String;
FValue: String;
public
constructor Create(Key: String; Value: String);
property Key: String read FKey write FKey;
property Value: String read FValue write FValue;
end;
TKeyPairType = (FKP_CUSTOMERS, FKP_PRODUCTS, FKP_PAYTYPES, FKP_VAT, FKP_PAYGROUPS, FKP_CASHBOOKS);
TKeyPairList = TObjectList<TKeyAndValue>;
TRoomPackageLineEntry = class
private
FRoomReservation: Integer;
FAmount: Double;
FVatAmount: Double;
FAmountWoVat: Double;
FCode: String; // ItemCode
FDescription: string;
FIsRoom: boolean;
FpackageCode: string;
FPackageDescription: string;
FLineNo: Integer;
FaDate: Tdate;
FItemCount: Double;
public
constructor Create(
_Code: String;
_Description: string;
_Amount, _AmountWoVat,
_VatAmount: Double;
_RoomReservation: Integer;
_isRoom: boolean;
_packageCode: string;
_packageDescription: string;
_lineNo: Integer;
_adate: Tdate;
_count: Double
);
procedure Add(_Amount, _AmountWoVat, _VatAmount: Double; _Code, _Description: string; _count: Double; _adate: Tdate;
_lineNo: Integer);
property packageCode: String read FpackageCode write FpackageCode;
property packageDescription: String read FPackageDescription write FPackageDescription;
property Code: String read FCode write FCode;
property Description: String read FDescription write FDescription;
property Amount: Double read FAmount write FAmount;
property AmountWoVat: Double read FAmountWoVat write FAmountWoVat;
property VatAmount: Double read FVatAmount write FVatAmount;
property RoomReservation: Integer read FRoomReservation write FRoomReservation;
property isroom: boolean read FIsRoom write FIsRoom;
property LineNo: Integer read FLineNo write FLineNo;
property aDate: Tdate read FaDate write FaDate;
property ItemCount: Double read FItemCount write FItemCount;
end;
TRoomPackageLineEntryList = TObjectList<TRoomPackageLineEntry>;
Td = class(TDataModule)
rptDesign: TfrxDesigner;
frxPDFExport1: TfrxPDFExport;
frxHTMLExport1: TfrxHTMLExport;
frxRTFExport1: TfrxRTFExport;
frxJPEGExport1: TfrxJPEGExport;
mtPayments_: TkbmMemTable;
mtHead_: TkbmMemTable;
mtVAT_: TkbmMemTable;
mtLines_: TkbmMemTable;
mtCompany_: TkbmMemTable;
mtCaptions_: TkbmMemTable;
inPosMonitor: TTimer;
mQuickRes: TdxMemData;
mQuickResRoom: TStringField;
mQuickResDateFrom: TDateField;
mQuickResDateTo: TDateField;
mQuickRes2: TkbmMemTable;
roomerMainDataSet: TRoomerDataSet;
wRooms_: TRoomerDataSet;
kbmInvoiceLines: TkbmMemTable;
cxEditRepository1: TcxEditRepository;
currencyEUR2d: TcxEditRepositoryCurrencyItem;
RoomsDateDS: TDataSource;
mInvoiceHeadsDS: TDataSource;
mInvoiceLinesDS: TDataSource;
mrptTurnoverDS: TDataSource;
PaymentListDS: TDataSource;
RoomRentOnInvoiceDS: TDataSource;
kbmRoomsDate_: TkbmMemTable;
mInvoiceHeads: TkbmMemTable;
mInvoiceLines: TkbmMemTable;
mrptTurnover: TkbmMemTable;
kbmPaymentList_: TkbmMemTable;
kbmRoomRentOnInvoice_: TkbmMemTable;
TurnoverDS: TDataSource;
mrptPaymentsDS: TDataSource;
RoomsDateChangeDS: TDataSource;
PaymentsDS: TDataSource;
kbmInvoiceLinePriceChangeDS: TDataSource;
kbmTurnover_: TkbmMemTable;
mrptPayments: TkbmMemTable;
kbmRoomsDateChange_: TkbmMemTable;
kbmPayments_: TkbmMemTable;
kbmInvoiceLinePriceChange_: TkbmMemTable;
confirmMonitor: TTimer;
currencyISK2d: TcxEditRepositoryCurrencyItem;
currencyUSD2d: TcxEditRepositoryCurrencyItem;
currencyCAD2d: TcxEditRepositoryCurrencyItem;
currencyGBP2d: TcxEditRepositoryCurrencyItem;
ALWinInetHTTPClient1: TALWinInetHTTPClient;
CurrencyMXN2d: TcxEditRepositoryCurrencyItem;
mlogInvoicelines: TkbmMemTable;
mInvoicelines_before: TkbmMemTable;
mInvoicelines_after: TkbmMemTable;
mInvoicelog: TkbmMemTable;
procedure DataModuleCreate(Sender: TObject);
procedure DataModuleDestroy(Sender: TObject);
procedure RoomTypes_NewRecord(DataSet: TDataSet);
procedure DayNotes_BeforePost(DataSet: TDataSet);
function getRoomTypeColors(sRoomType: string): recStatusAttr;
procedure roomerMainDataSetSessionExpired(Sender: TObject);
procedure roomerMainDatasetCredentialsChanged(Sender: TObject);
procedure kbmRoomRentOnInvoice_BeforePost(DataSet: TDataSet);
procedure mInvoiceHeadsBeforePost(DataSet: TDataSet);
procedure confirmMonitorTimer(Sender: TObject);
procedure mInvoicelines_beforeNewRecord(DataSet: TDataSet);
procedure mInvoicelines_afterNewRecord(DataSet: TDataSet);
private
FHotelServicesSettings: THotelServicesSettings;
{ Private declarations }
procedure SetMainRoomerDataSet(ds: TRoomerDataSet; ConnectAllDatasets: boolean = True);
function LocateWRoom(Room: String): boolean;
procedure SelectCloudConfig;
procedure SetDefaultCloudConfig;
procedure SetCloudConfigByFile(filename: String);
function GetApplicationId: string;
procedure SetApplicationid(const Value: string);
public
{ Public declarations }
qConnected: boolean;
qRes, qRres: Integer;
zRptInitFilter: string;
zRptInitSortField: string;
zRptInitSortDir: string;
zItemTypesFilter: string;
zItemTypesSortField: string;
zItemTypesSortDir: string;
function RetrieveFinancesKeypair(keyPairType: TKeyPairType): TKeyPairList;
function KeyExists(keyList: TKeyPairList; Key: String): boolean;
procedure PrepareFixedTables;
procedure SaveTcxGridColumnOrder(form: TForm; grid: TcxGrid);
procedure LoadTcxGridColumnOrder(form: TForm; grid: TcxGrid);
function colorCodeOfStatus(status: String): TColor;
procedure CopyInvoiceToInvoiceLinesTmp(Invoice: Integer; FromKredit: boolean); overload;
procedure CopyInvoiceToInvoiceLinesTmp(Invoice: Integer; FromKredit: boolean; var hasPackage : Boolean; var SelectedInvoiceIndex : Integer); overload;
function GetCustomerCurrency(sCustomer: string): string;
function GetCustomerName(customer: string): string;
function GET_CustomerTypesDescription_byCustomerType(CustomerType: string): string;
// MaidActions Table
function qryGetMaidActions(Orderstr: string): string;
function Del_MaidActionByMaidAction(sAction: string): boolean;
function MaidActionExist(sCode: string): boolean;
function qryGetTelPriceGroups(Orderstr: string): string;
function GET_telPriceGroupsName_byCode(Code: string): string;
function Del_PriceGroupByCode(Code: string): boolean;
function PriceGroupExist(Code: string): boolean;
function qryGetTelPriceRules(Orderstr: string): string;
function GET_telPriceRulesName_byCode(Code: string): string;
function Del_PriceRuleByCode(Code: string): boolean;
function PriceRuleExist(Code: string): boolean;
function isMixedStatus(reservation: Integer): string;
function isMixedPaymentDetails(reservation: Integer): string;
function isGroup(RoomReservation: Integer): boolean;
function GetReservationLocations(reservation: Integer; var lst: tstringList): Integer;
function GetRoomReservationLocations(RoomReservation: Integer; var lst: tstringList): Integer;
procedure insertActivityLogFromMemTable;
function GET_RoomsDescription_byRoom(sRoom: string): string;
function GET_roomstatus(sRoom: string): char;
function RoomExists(sRoom: string): Integer;
function RoomExists_InRoomReservation(sRoom: string): Integer;
// Roomtypes Table
function RoomTypeExistsInOther(sRoomType: string): boolean;
function RoomTypeExists(sRoomType: string): boolean;
function Del_RoomTypeByRoomType(sRoomType: string): boolean;
function RoomTypeGroupExistsInOther(sRoomTypeGroup: string): boolean;
function RoomTypeGroupExists(sRoomTypeGroup: string): boolean;
function Del_RoomTypeGroupByRoomTypeGroup(sRoomTypeGroup: string): boolean;
function GET_RoomTypeGroupDescription_byRoomTypeGroup(sRoomTypeGroup: string): string;
function qryGetViewRooms(Orderstr: string): string;
function OpenViewRoomsQuery(SortField, SortDir: string): boolean;
function getRoomText(sRoom: string): string;
// Locations Table
function GET_LocationDescription_byLocation(sLocation: string): string;
function GET_Location_byLocationDescription(sDescription: string): string;
// Paytypes Table
procedure PayTypes_InitDoExport;
function PayTypes_isExport(sPaytype: string): boolean;
// ItemTypes Table
function GET_ItemTypeDescription_byItemType(sItemType: string): string;
function Del_ItemTypeByItemType(sItemType: string): boolean;
function ItemTypeExists(sItemType: string): boolean;
function ItemTypeExistsInOther(sItemType: string): boolean;
// Items Table
function qryGetItems(Orderstr: string): string;
// StaffMembers Table
function GET_StaffMemberName_byInitials(sInitials: string): string;
function GET_StaffMemberPID_byInitials(sInitials: string): string;
// PriceCodes Table
function qryGetRoomPrices_1(Orderstr: string; priceCodeID, seasonId: Integer; RoomType, Currency: string;
seEndDate: TdateTime): string;
function Del_RoomPricesByID_1(Id: Integer): boolean;
function Get_LastRoomPriceID_1: Integer;
function getPrice_1(rtID: Integer; persons: Integer; var Code, RoomType, Currency: string): Double;
function getPrice_2(rtID: Integer; persons: Integer): Double;
function getRackPriceID_1(seasonId: Integer; RoomType, Currency: string): Integer;
function PriceExistsByCodes(pcCode, seDescription, RoomType, Currency: string): boolean;
function PriceExistsByCodesAndCurrency(pcCode, Currency: string): boolean;
function ReadUserSettingsAndHotelConfigurations(login, password: string): boolean;
// Seasons Table
function GET_SeasonsDates_bySeasonID(seasonId: Integer; var seStartdate, seEndDate: TdateTime): boolean;
function GET_SeasonsDescription_bySeasonID(seasonId: Integer): string;
function GET_SeasonsId_byDescription(seDescription: string): Integer;
function Del_SeasonByID(Id: Integer): boolean;
function SeasonExist(aDateFrom, aDateTo: TdateTime): boolean;
function SeasonCount(aDate: TdateTime): Integer;
function FindSeasonID(aDate: TdateTime): Integer;
function SeasonExists_byID(seasonId: Integer): boolean;
// tblINC Table
function getTblINC_nextCustomerNumber: string;
function getTblINC_Last: Integer;
function getTblINC_Length: Integer;
function getTblINC_Fill: string;
// InvoiceLinesTmp
function InvoiceLinesTmp_exists(iRoomReservation: Integer): boolean;
function del_InvoiceLinesTmp(iRoomReservation: Integer): boolean;
function UpdateRoomResBreakfastState(reservation, RoomReservation: Integer; aBreakfast: TBreakfastType; aPrice: TAmount): boolean;
procedure UpdateGroupAccountAll(reservation, RoomReservation, RoomReservationAlias: Integer; GroupAccount: boolean);
function UpdateGroupAccountOne(reservation, RoomReservation, RoomReservationAlias: Integer; GroupAccount: boolean;
InvoiceIndex: Integer = -1): boolean;
procedure MoveRoomDateToInvoiceIndex(aReservation, aRoomReservation: integer; aDate:TDate; aInvoiceIndex: Integer);
procedure MoveGroupRoomToInvoiceIndex(aReservation, aRoomReservation, aInvoiceIndex: Integer);
function UpdateReservationMarket(aReservation: Integer; aMarket: TReservationMarketType): boolean;
function UpdateExpectedCheckoutTime(aReservation, aRoomReservation: Integer; const aCheckoutTime: string): boolean;
function UpdateExpectedTimeOfArrival(aReservation, aRoomReservation: Integer; const aTimeOfArrival: string)
: boolean;
function UpdateChildrenCount(aReservation, aRoomReservation: Integer; const aChildren: integer): boolean;
function UpdateInfantCount(aReservation, aRoomReservation: Integer; const aInfants: integer): boolean;
function isAllRRSameCurrency(reservation: Integer): boolean;
// Er Allar herbergisb�kanir innan b�kunnar � sama gjaldmi�li
function GetGroupAccount(reservation, RoomReservation: Integer): boolean;
function OpenInvoiceInvoiceLines(reservation, RoomReservation: Integer): Integer;
function NameOnOpenInvoice(reservation, RoomReservation: Integer): string;
function MoveRoom(RoomReservation: Integer; NewRoom: string): boolean;
function GetRoomList_Occupied(dtDateFrom, dtDateTo: Tdate; iRoomReservation: Integer; var lst: tstringList)
: boolean;
function isDay_Occupied(dtDate: Tdate; Room: string; var RoomReservation: Integer): boolean;
function Occupied_fromTo(dtDateFrom, dtDateTo: Tdate; Room: string): boolean;
function RemoveRoomsDate(iRoomReservation: Integer): boolean;
function ChangeRrDates(RoomReservation: Integer; newArrival, newDeparture: Tdate;
updateRoomstatus: boolean): boolean;
// function RR_ChangeDates(RoomReservation : integer;newArrival, newDeparture : Tdate) : boolean;
function isAllDatesSameInRes(reservation: Integer): boolean;
procedure RemoveRoomReservation(RoomReservation: Integer;
CancelStaff
, CancelReason
, CancelInformation: string;
CancelType: Integer;
doLog,
useTrans, ask: boolean);
procedure RemoveReservation(iReservation: Integer;
CancelStaff
, CancelReason
, CancelInformation: string;
CancelType: Integer
);
procedure RemoveReservationNotSave(iReservation: Integer; CancelStaff, CancelReason, CancelInformation: string;
CancelType: Integer);
procedure SetAsNoRoomEnh(RoomReservation: Integer; AllReservations: boolean);
function GetCustomerFromRes(aRes: Integer): string;
function GetInvoiceCurrency(InvoiceNumber: Integer): string;
function GetInvoiceCurrencyAndReservationNumber(InvoiceNumber: Integer;
var reservation, RoomReservation: Integer;
var Room: String): string;
Procedure GetInvoiceCurrencyAndRate(InvoiceNumber: Integer; var Currency: string; var Rate: Double);
procedure UpdateUsersLanguage(Staff: string; iLanguage: Integer);
procedure CheckInGuest(RoomReservation: Integer);
procedure CheckinReservation(aReservation: integer);
procedure CheckOutGuest(RoomReservation: Integer; Room: String);
procedure CheckoutReservation(aReservation: integer);
function GetCustomerPreferences(CustomerID: string): string;
function GetRoomStatus(Room: string): char;
function AskApproval(PayType: string): boolean;
function getCountryCode(aText: string): string;
function getCountryName(const aCountryCode: string): string;
function Item_Get_AccountKey(sItem: string): string;
function Item_Get_Type(Item: string): string;
function Item_Get_Data(aItem: string): recItemPlusHolder;
function Item_Del(sItem: string): boolean;
function Item_ExistsInOther(sItem: string): boolean;
function Item_Get_ItemTypeInfo(Item: string; package: String = ''): TItemTypeInfo;
function FieldExists(rSet: TRoomerDataSet; FieldName: String): boolean;
function VATDescription(Code: string): string;
function VATPercentage(Code: string): Double;
function VATvalueFormula(Code: string): String;
function PackageVATvalueFormula(package, Item: string; VATPercentage: Double): String;
procedure VATvalueFormulaAndPercentage(Code: String; package: String; Item: String; var Formula: string;
var Percentage: Double);
function StaffExists(Staff: string): boolean;
function CustomerTypeName(CustomerTypeCode: string): string;
function SetInvoiceOrginalRef(Invoice, RoomReservation, OrginalRef: Integer): boolean;
function inDateRange(seasonId: Integer; FromDate, ToDate: Tdate; var RangeStart, RangeEnd: Tdate): boolean;
function GetRoomReservation(reservation: Integer; Room: string): Integer;
function RoomsTypeCount(CountAll: boolean): Integer;
function isUnPaid(RoomReservation: Integer): boolean;
function isUnPaidByRes(reservation: Integer): boolean;
function RemoveRoomsDatebyReservation(iReservation: Integer): boolean;
function RemoveRoomReservationByReservation(iReservation: Integer): boolean;
function RemoveInvoiceHeadsByReservation(iReservation: Integer): boolean;
function RemoveReservationsByReservation(iReservation: Integer): boolean;
function NextRoomReservatiaon(Room: string; RoomReservation: Integer; noResDate: Tdate): Integer;
function LastRoomReservatiaon(Room: string; RoomReservation: Integer; noResDate: Tdate): Integer;
function RemoveDirectInvoiceRemnants(aInvoiceType: integer): boolean;
function InsInvoiceAction(R: TInvoiceActionRec): boolean;
procedure SetUnclean(Room: string);
procedure SetAllClean;
procedure SetAllUnClean;
function invoice_isExport(invoiceNo: Integer): boolean;
function GetRoomReservatiaonArrival(RoomReservation: Integer): Tdate;
function Del_MaidsJobsByDate(aDate: Tdate; All: boolean): boolean;
function getRoomTypeFromRR(RR: Integer): string;
function getChangeAvailabilityInfo(RR: Integer; var RoomType, status: string;
var Arrival, departure: Tdate): boolean;
function getCountryGroupNameFromCountry(Country: string): string;
function getCountryGroupFromCountry(Country: string): string;
function getLocationFromRoom(Room: string): string;
function getinStatisticsFromRoom(Room: string): boolean;
function getFloorFromRoom(Room: string): Integer;
function ChangeCountry(newCountry: string; reservation, RoomReservation, Person, Medhod: Integer): boolean;
function reservationCount(reservation: Integer): Integer;
function getCountryFromReservation(reservation: Integer): string;
function isKredit(InvoiceNumber: Integer): boolean;
function Del_PaymentByInvoice(iNumber: Integer): boolean;
procedure CreateMtFields;
procedure InsertMTdata(InvoiceNumber: Integer; doExport, silent: boolean; showPackage: boolean);
procedure exportToSnertaTextRec(silent: boolean);
procedure exportToSnertaSimpleXML(silent: boolean);
function SnertaExportCustomers(custNo: string): Integer;
function SnertaExportRooms(Room, prefix: string): Integer;
function lstRR_CurrentlyCheckedIn(aDate: Tdate): tstringList;
function isRrCurrentlyCheckedIn(RoomReservation: Integer): boolean;
function isResCurrentlyCheckedIn(reservation: Integer): boolean;
function ExtStatusText(status: string; aDate, Arrival, departure: Tdate): string;
function Next_OccupiedDate(FromDate: Tdate; Room: string): Tdate;
function Next_OccupiedDayCount(FromDate: Tdate; Room: string): Integer;
function GetCurrentGuestsXML: Integer;
procedure RR_ExcluteFromOpenInvoices(RoomReservation: Integer);
function hiddenInfo_Exists(Refrence, RefrenceType: Integer): Integer; // returns field ID
function hiddenInfo_getData(Id: Integer): recHiddenInfoHolder;
function hiddenInfo_Append(Id: Integer; newText: string; res: Integer): boolean;
procedure chkInPosMonitor;
function IH_GetRefrence(InvoiceNumber, reservation, RoomReservation: Integer): string;
procedure IH_getPaymentsTypes(InvoiceNumber: Integer; var PayTypes, PayTypeDescription, payGroups,
payGroupDescription: string);
Function IA_ActionCount(InvoiceNumber, actionID: Integer): Integer;
procedure UpdPaymentsWhenChangingReservationToGroup(reservation, RoomReservation: Integer);
procedure UpdPaymentsWhenChangingReservationToRoom(reservation, RoomReservation: Integer);
procedure INV_UpdateBreakfastGuests(aReservation, aRoomReservation: integer; aNewNumberOfBreakfast: integer);
// *************************************************************************
// Control functions
/// ////////////////////////////////////////////////////////////////////////
procedure ctrlGetGlobalValues;
function ChkCompany(Company, CompanyName: string): boolean;
procedure ctrlSetInteger(aField: string; ivalue: Integer);
procedure ctrlSetString(aField: string; svalue: string);
// *************************************************************
// StatusAttr
// -------------------------------------------------------------
procedure Get_All_StatusAttributes;
procedure save_StatusAttr_Blocked;
procedure save_StatusAttr_NoShow;
procedure save_StatusAttr_Waitinglist;
procedure save_StatusAttr_WaitinglistNonOptional;
procedure save_StatusAttr_Allotment;
procedure save_StatusAttr_Departed;
procedure save_StatusAttr_Departing;
procedure save_StatusAttr_GuestLeavingNextDay;
procedure save_StatusAttr_GuestStaying;
procedure save_StatusAttr_ArrivingOtherLeaving;
procedure save_StatusAttr_order;
procedure save_StatusAttr_Canceled;
procedure save_StatusAttr_Tmp1;
procedure save_StatusAttr_Tmp2;
procedure Default_StatusAttr_Blocked;
procedure Default_StatusAttr_NoShow;
procedure Default_StatusAttr_Option;
procedure Default_StatusAttr_WaitingList;
procedure Default_StatusAttr_Allotment;
procedure Default_StatusAttr_Departed;
procedure Default_StatusAttr_Departing; //
procedure Default_StatusAttr_GuestLeavingNextDay;
procedure Default_StatusAttr_GuestStaying;
procedure Default_StatusAttr_ArrivingOtherLeaving;
procedure Default_StatusAttr_order;
procedure Default_StatusAttr_canceled;
procedure Default_StatusAttr_tmp1;
procedure Default_StatusAttr_tmp2;
// ---------------------------------------------------------------
function RV_Upd_Name(res: Integer; newName: string): boolean;
function RR_Upd_CurrencyRoomPrice(iRoomReservation: Integer; aDate: string; Currency: string): boolean;
function RR_Upd_MemoTexts(iRoomReservation: Integer; HiddenInfo: string): boolean;
function RR_Upd_Paycard_Token_Id(iRoomReservation: Integer; tokenId : Integer): boolean;
procedure RR_Upd_FirstGuestName(iRoomReservation: Integer; newName: string);
function RE_Upd_MarketSegment(newValue: string; reservation: Integer): boolean;
function IH_Upd_UnPaid_RR(RoomReservation: Integer): boolean;
function RR_Upd_Package(iRoomReservation: Integer; package: string): boolean;
function RR_clear_Package(iRoomReservation: Integer; package: string): boolean;
function RR_GetNumberOfRooms(iReservation: Integer): Integer;
function RR_GetGuestCount(iRoomReservation: Integer): Integer;
procedure RR_ChangeGuestCount(aRoomReservation: integer; aGuestDataset: TDataset; aNewGuestCount: integer);
function RR_GetRoomNr(iRoomReservation: Integer): string;
function RR_GetRoomArrivalAndDeparture(iRoomReservation: Integer; var Room: String;
var Arrival, departure: TdateTime): boolean;
function RR_GetArrivalDate(iRoomReservation: Integer): Tdate;
function RR_GetDepartureDate(iRoomReservation: Integer): Tdate;
function RR_getDates(iRoomReservation: Integer): recResDateHolder;
function RV_getDates(iReservation: Integer): recResDateHolder;
function RR_GetReservationName(iRoomReservation: Integer): string;
function RR_GetMemoText(iRoomReservation: Integer; VAR RoomNotes: string; FieldName: String = 'HiddenInfo')
: boolean;
function RR_GetMemoBothTextForRoom(iRoomReservation: Integer; var RoomNotes, ChannelRequest: string): boolean;
function RR_GetFirstGuestName(iRoomReservation: Integer): string;
function RR_GetAllGuestNames(iRoomReservation: Integer; showAll: boolean = True; showTotal: boolean = True): string;
function RR_GetLastGuestID(iRoomReservation: Integer): Integer;
function RR_GetFirstGuestCountry(iRoomReservation: Integer): string;
function RR_GetFirstGuestType(iRoomReservation: Integer): string;
function RR_GetStatus(iRoomReservation: Integer): string;
function RR_GetIsGroopAccount(iRoomReservation: Integer): boolean;
function RR_FirstDayAndRoom(RoomReservation: Integer; var Room: string): Tdate;
function RV_FirstDayAndRoom(reservation: Integer; var Room: string): Tdate;
function Ref_FirstDayAndRoom(ref: string; var Room: string): Tdate;
function RV_getMemos(reservation: Integer; var information, PMinfo: string): boolean;
function INV_FirstDayAndRoom(InvoiceNumber: Integer; var Room: string; var InvoiceKind: Integer): Tdate;
function RRlst_FromToUnpaid(DateFrom, DateTo: Tdate): tstringList;
function RRlst_FromTo(DateFrom, DateTo: Tdate): tstringList;
function RRlst_Departure(DateFrom, DateTo: Tdate): tstringList;
function GuestlistRRlst_FromTo(DateFrom, DateTo: Tdate; includeNoshow, includeAllotment, includeBlocked: boolean)
: tstringList;
function GuestListRRlst_Arrival(DateFrom, DateTo: Tdate; includeNoshow, includeAllotment, includeBlocked: boolean)
: tstringList;
function GuestlistRRlst_Departure(DateFrom, DateTo: Tdate; includeNoshow, includeAllotment, includeBlocked: boolean)
: tstringList;
function RRlst_DepartureNationalReport(DateFrom, DateTo: Tdate): tstringList;
function RRlst_DepartureNationalReportByLocation(DateFrom, DateTo: Tdate; Location: string): tstringList;
function RRlst_Arrival(DateFrom, DateTo: Tdate): tstringList;
function Rvlst_CreatedFromTo(DateFrom, DateTo: Tdate): tstringList;
function Rvlst_FromToGroup(DateFrom, DateTo: Tdate): tstringList;
function RVlst_FromTo(DateFrom, DateTo: Tdate): tstringList;
function RVlst_Arrival(DateFrom, DateTo: Tdate; customer: string = ''): tstringList;
function RVlst_Departure(DateFrom, DateTo: Tdate): tstringList;
procedure Reservations_InitUseStayTax;
Function GroupAccountCount(reservation: Integer): Integer;
procedure UpdateStatusSimple(reservation, RoomReservation: Integer; newStatus: string);
function SetAsNoRoom(RoomReservation: Integer): boolean;
function ChkFinished(invNr: Integer): Integer;
function AddInvoiceLinesTMP(LastLineNumber, iReservation: Integer): boolean;
procedure InsertReciptData(PaymentData: recPaymentHolder; invoiceData: recInvoiceHeadHolder);
function LocateRecord(rSet: TRoomerDataSet; FieldName: String; Value: Integer): boolean; overload;
function LocateRecord(rSet: TRoomerDataSet; FieldName: String; Value: String): boolean; overload;
procedure ApplyFieldsToKbmMemTable(sourceSet: TRoomerDataSet; destSet: TdxMemData; loadDataSet: boolean = True);
procedure SaveKbmMemTable(destSet: TdxMemData; filename: String; performTouch: boolean = False);
procedure TurnoverAndPaymentsGetAll(clearData: boolean; var zGlob: recTurnoverAndPaymentsGlobals);
procedure TurnoverAndPaymentsGetAll_II(clearData: boolean; var zGlob: recTurnoverAndPaymentsGlobals_II);
procedure TurnoverAndPaymentsUpdateTurnover(var zGlob: recTurnoverAndPaymentsGlobals);
procedure TurnoverAndPaymentsUpdateTurnover_II(var zGlob: recTurnoverAndPaymentsGlobals_II);
procedure TurnoverAndPaymentsUpdateTurnoverItemPriceChange(var rec: recTurnoverAndPaymentsGlobals);
procedure TurnoverAndPaymentsUpdateTurnoverItemPriceChange_II(var rec: recTurnoverAndPaymentsGlobals_II);
procedure TurnoverAndPaymentsDoConfirm;
procedure TurnoverAndPaymentsDoConfirm_II;
function GetLastConfirm: TdateTime;
procedure chkConfirmMonitor;
procedure TurnoverAndPayemnetsClearAllData(justClose: boolean);
function ChangeNationality(newCountry: string; reservation, RoomReservation, Person, Medhod: Integer): boolean;
function ChangeMarketType(newMarketType: string; reservation: Integer): boolean;
function getCurrencyProperties(Currency: String): TcxCustomEditProperties;
procedure AddOrCreateToPackage(pckTotalsList: TRoomPackageLineEntryList;
Code: String;
_Description: string;
RoomReservation: Integer;
_Amount,
_AmountWoVat,
_VatAmount: Double;
_isRoom: boolean;
_packageCode: string;
_packageDescription: string;
_lineNo: Integer;
_adate: Tdate;
_count: Double
);
procedure GenerateOfflineReports;
function CheckOutRoom(reservation, RoomReservation: Integer; Room: String): boolean;
procedure GetEmailAddressesForInvoiceNumber(aInvoiceNumber: integer; aAddressList: TStrings);
procedure CheckAndCorrectCredentials(const aHotelCode: string);
property ApplicationId: string read GetApplicationId write SetApplicationid;
property HotelServicesSettings : THotelServicesSettings read FHotelServicesSettings;
end;
function CreateNewDataSet: TRoomerDataSet;
function HtmlToColor(s: string; aDefault: TColor): TColor;
function getRowHeightFromIndex(index: Integer): Integer;
function GenerateProformaInvoiceNumber: Integer;
var
PROFORMA_INVOICE_NUMBER: Integer;
{$IFDEF rmROOMERSSL}
const cRoomerBase: String = 'https://secure.roomercloud.net';
cRoomerBasePort: String = '443';
cRoomerOpenAPIBase: String = 'https://secure.roomercloud.net';
cRoomerOpenApiBasePort: String = '443';
{$ELSE}
const cRoomerBase: String = 'http://secure.roomercloud.net';
cRoomerBasePort: String = '80';
cRoomerOpenApiBasePort: String = '80';
cRoomerOpenAPIBase: String = 'http://secure.roomercloud.net';
{$ENDIF}
const cRoomerStoreBase: String = 'http://roomerstore.com';
cRoomerStoreBasePort: String = '80';
var
d: Td;
implementation
uses
uPriceOBJ
, uAppGlobal
, uDayNotes
, uInvoiceSummeryOBJ
, uSqlDefinitions
, uMain
, objRoomList2
, PrjConst
, uUtils
, uStringUtils
, uFileSystemUtils
, uDateUtils
, uTaxCalc
, uActivityLogs
, uOfflineReportGenerator
, uFrmSelectCloudConfiguration
, Inifiles
, uAlerts
, uFrmCheckOut
, UITypes
, uVatCalculator, uTableEntityList, uSQLUtils, uCredentialsAPICaller, ufrmInvoiceEdit,
Math, uInvoiceDefinitions, uProvideARoom2, uRoomerCurrencymanager, uRoomServicesAPI, uVCLUtils;
{$R *.dfm}
var
RoomerStoreUri: String;
RoomerOpenApiUri: String;
RoomerApiUri: String;
RoomerApiEntitiesUri: String;
RoomerApiDatasetsUri: String;
function CreateNewDataSet: TRoomerDataSet;
begin
result := d.roomerMainDataSet.CreateNewDataSet;
end;
function Td.getCurrencyProperties(Currency: String): TcxCustomEditProperties;
var
currEdit: TObject;
begin
Currency := UpperCase(Currency);
currEdit := FindComponent(format('currency%s2d', [Currency]));
if currEdit <> nil then
result := (currEdit AS TcxEditRepositoryCurrencyItem).Properties
else // Should not happen, except for unknown currencies
begin
if Currency = 'EUR' then
result := d.currencyEUR2d.Properties
else
if Currency = 'ISK' then
result := d.currencyISK2d.Properties
else
if Currency = 'USD' then
result := d.currencyUSD2d.Properties
else
if Currency = 'CAD' then
result := d.currencyCAD2d.Properties
else
if Currency = 'MXN' then
result := d.CurrencyMXN2d.Properties
else
if Currency = 'GBP' then
result := d.currencyGBP2d.Properties
else
result := d.currencyEUR2d.Properties;
end;
end;
procedure Td.chkInPosMonitor;
var
use: boolean;
interval: Integer;
begin
try
use := g.qInPosMonitorUse;
interval := g.qInPosMonitorChkSec;
interval := interval * 1000;
except
use := False;
interval := 5000;
end;
inPosMonitor.interval := interval;
inPosMonitor.Enabled := use;
end;
procedure Td.LoadTcxGridColumnOrder(form: TForm; grid: TcxGrid);
var
i: Integer;
begin
// ini := TRoomerRegistryIniFile.Create();
for i := 0 to grid.ViewCount - 1 do
grid.Views[i].RestoreFromRegistry(form.Name + '_' + grid.Name, False, True);
end;
// *****************************
procedure Td.SetDefaultCloudConfig;
begin
RoomerOpenApiUri := ParameterByName('OpenApiBase', cRoomerOpenAPIBase) + ':' + ParameterByName('RoomerOpenApiBasePort', cRoomerOpenApiBasePort) + '/roomer/openAPI/REST/';
RoomerStoreUri := ParameterByName('RoomerStoreBase', cRoomerStoreBase) + ':' + ParameterByName('RoomerStoreBasePort', cRoomerStoreBasePort) + '/';
RoomerApiUri := ParameterByName('RoomerBase', cRoomerBase) + ':' + ParameterByName('Port', cRoomerBasePort) + '/services/';
RoomerApiEntitiesUri := RoomerApiUri + 'entities/';
RoomerApiDatasetsUri := RoomerApiUri + 'datasets/';
end;
procedure Td.SetCloudConfigByFile(filename: String);
begin
with TInifile.Create(TPath.Combine(ExtractFilePath(Application.ExeName), filename)) do
try
RoomerOpenApiUri := ReadString('Cloud', 'RoomerOpenAPIBase', cRoomerOpenAPIBase) + ':' +
ReadString('Cloud', 'RoomerOpenApiPort', cRoomerOpenApiBasePort) +
ReadString('Cloud', 'RoomerOpenApiRestPath', '/roomer/openAPI/REST/');
RoomerStoreUri := ReadString('Cloud', 'RoomerStoreBase', cRoomerStoreBase) + ':' +
ReadString('Cloud', 'RoomerStoreBasePort', cRoomerStoreBasePort) + '/';
RoomerApiUri := ReadString('Cloud', 'RoomerBase', cRoomerBase) + ':' +
ReadString('Cloud', 'RoomerBasePort', cRoomerBasePort) + '/services/';
RoomerApiEntitiesUri := RoomerApiUri + 'entities/';
RoomerApiDatasetsUri := RoomerApiUri + 'datasets/';
finally
Free;
end;
end;
procedure Td.SelectCloudConfig;
var
files: TStrings;
path: String;
lfile: string;
begin
files := tstringList.Create;
try
for path in GetFilesInSpecifiedDirectory(ExtractFilePath(Application.ExeName), 'roomer_environment*.cfg') do
files.Add(path);
if files.Count = 0 then
begin
SetDefaultCloudConfig;
end
else
begin
if files.Count = 1 then
SetCloudConfigByFile(files[0])
else
begin
lfile := SelectConfigurationEnvironment(files);
if lFile.IsEmpty then
ExitProcess(0)
else
SetCloudConfigByFile(lFile);
end;
end;
finally
files.Free;
end;
end;
procedure Td.DataModuleCreate(Sender: TObject);
begin
FHotelServicesSettings := THotelServicesSettings.Create;
qRes := -1;
qRres := -1;
SelectCloudConfig;
roomerMainDataSet.OnSessionExpired := roomerMainDataSetSessionExpired;
SetMainRoomerDataSet(roomerMainDataSet);
kbmInvoiceLines.Open;
end;
procedure Td.chkConfirmMonitor;
var
use: boolean;
interval: Integer;
begin
try
use := g.qConfirmAuto;
interval := 120000;
g.qLastConfirm := GetLastConfirm;
confirmMonitor.interval := interval;
except
use := False;
end;
confirmMonitor.Enabled := use;
end;
procedure Td.SaveTcxGridColumnOrder(form: TForm; grid: TcxGrid);
var
i: Integer;
begin
for i := 0 to grid.ViewCount - 1 do
grid.Views[i].StoreToRegistry(form.Name + '_' + grid.Name, True, [], '');
end;
procedure Td.SetMainRoomerDataSet(ds: TRoomerDataSet; ConnectAllDatasets: boolean = True);
var
i: Integer;
begin
ds.RoomerStoreUri := RoomerStoreUri;
ds.OpenApiUri := RoomerOpenApiUri;
ds.RoomerUri := RoomerApiUri;
ds.RoomerEntitiesUri := RoomerApiEntitiesUri;
ds.RoomerDatasetsUri := RoomerApiDatasetsUri;
if ConnectAllDatasets then
for i := 0 to ComponentCount - 1 do
begin
if (Components[i] IS TRoomerDataSet) then
begin
if Components[i] <> ds then
begin
TRoomerDataSet(Components[i]).ParentRoomerDataSet := ds;
TRoomerDataSet(Components[i]).RoomerStoreUri := RoomerStoreUri;
TRoomerDataSet(Components[i]).OpenApiUri := RoomerOpenApiUri;
TRoomerDataSet(Components[i]).RoomerUri := RoomerApiUri;
TRoomerDataSet(Components[i]).RoomerEntitiesUri := RoomerApiEntitiesUri;
TRoomerDataSet(Components[i]).RoomerDatasetsUri := RoomerApiDatasetsUri;
end;
end;
end;
end;
procedure Td.DataModuleDestroy(Sender: TObject);
begin
FHotelServicesSettings.Free;
roomerMainDataSet.Logout;
end;
// ******************************************************************************
// Global Table Functions
// ******************************************************************************
function Td.AddInvoiceLinesTMP(LastLineNumber, iReservation: Integer): boolean;
var
lineHolder: recInvoicelineHolder;
ExecutionPlan: TRoomerExecutionPlan;
begin
// **TTTT
result := False;
ExecutionPlan := d.roomerMainDataSet.CreateExecutionPlan;
try
if d.kbmInvoiceLines.Active then
begin
if d.kbmInvoiceLines.locate('Reservation', iReservation, []) then
begin
try
d.kbmInvoiceLines.First;
while not d.kbmInvoiceLines.eof do
begin
if d.kbmInvoiceLines.FieldByName('Reservation').AsInteger = iReservation then
begin
hData.initInvoiceLineHolderRec(lineHolder);
lineHolder.InvoiceNumber := -1;
lineHolder.reservation := d.kbmInvoiceLines.FieldByName('Reservation').AsInteger;
lineHolder.RoomReservation := d.kbmInvoiceLines.FieldByName('RoomReservation').AsInteger;
lineHolder.AutoGen := d.kbmInvoiceLines.FieldByName('AutoGen').Asstring;
lineHolder.SplitNumber := d.kbmInvoiceLines.FieldByName('SplitNumber').AsInteger;