-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathcode.txt
115 lines (100 loc) · 3.61 KB
/
code.txt
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
void clicked()
{
Dialog _dialog;
DialogField _file;
// HcmLabourInvoiceTable buffer;
LedgerJournalImports line;
SysExcelApplication application;
SysExcelWorkbooks workbooks;
SysExcelWorkbook workbook;
SysExcelWorksheets worksheets;
SysExcelWorksheet worksheet;
SysExcelCells cells;
COMVariantType type;
Name name;
FileName filename;
int row;
int ccCount;
str costCenter;
;
ccCount = 1;
costCenter = '';
//LedgerJournalACType ldgerJournalACType;
super();
//Prompt to import excel
_dialog = new Dialog('Please select the file to load');
_dialog.addText('Select file:');
_file = _dialog.addField(typeId(FilenameOpen));
_dialog.run();
if (_dialog.closedOK())
{
filename = _file.value();
}
application = SysExcelApplication::construct();
workbooks = application.workbooks();
try
{
workbooks.open(filename);
}
catch (Exception::Error)
{
throw error('File cannot be opened.');
}
workbook = workbooks.item(1);
worksheets = workbook.worksheets();
worksheet = worksheets.itemFromNum(1); //Here 1 is the worksheet Number
cells = worksheet.cells();
row++; //skip column names
do
{
row++;
line.clear();
//line.HcmLabourInvoiceImportNum = HcmLabourInvoiceTable.HcmLabourInvoiceImportNum;
//line.Department = any2str(cells.item(row, 1).value().toString());
//line.Section = cells.item(row, 2).value().bStr();
line.CostCenter = cells.item(row, 1).value().bStr();
if(costCenter != cells.item(row, 1).value().bStr())
{
//restart the count
ccCount = 1;
}
costCenter = line.CostCenter;
line.Account = cells.item(row,1).value().bStr();
line.CostCenter = cells.item(row,2).value().bStr();
line.CostElement= cells.item(row,3).value().bStr();
line.TransactionTxt = cells.item(row,4).value().bStr();
line.Debit = cells.item(row,5).value().double();
line.Credit = cells.item(row,6).value().double();
line.OffsetAccount = cells.item(row,7).value().bStr();
//line.ReversingEntry
//line.ReversingDate = str2date(cells.item(row,8).value().bStr(), 123);
line.CurrencyCode = cells.item(row,9).value().bStr();
// line.OffsetAccountType = str2enum(ledgerJournalACType, cells.item(row,10).value().bStr());
line.ECNumber = cells.item(row,3).value().bStr();
line.Surname = cells.item(row,4).value().bStr();
line.FirstName = cells.item(row,5).value().bStr();
line.NormalShiftHours = cells.item(row,6).value().double();
line.PlannedOT15 = cells.item(row,7).value().double();
line.PlannedOT20 = cells.item(row,8).value().double();
line.StandByAllowance = cells.item(row,9).value().double();
line.CalloutOT15 = cells.item(row,10).value().double();
line.CalloutOT20 = cells.item(row,11).value().double();
line.PPHOT20 = cells.item(row,12).value().double();
line.UndergroundPlus4 = cells.item(row,13).value().double();
line.NightShiftHours = cells.item(row,14).value().double();
line.Grade = cells.item(row,15).value().variantType() == COMVariantType::VT_BSTR? cells.item(row,15).value().bStr() : int2str(cells.item(row,15).value().double());
line.insert();
ccCount +=1;
type = cells.item(row+1, 1).value().variantType();
}
while (type != COMVariantType::VT_EMPTY);
application.quit();
//cHANGE STATUS OF HEADER
select forUpdate buffer where buffer.HcmLabourInvoiceImportNum == HcmLabourInvoiceTable.HcmLabourInvoiceImportNum;
ttsBegin;
buffer.HcmLabourInvoiceImportState = HcmLabourInvoiceImportState::Imported;
buffer.update();
ttsCommit;
element.RefreshDatasource();
info('Import complete.');
}