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 |
public function prepopulateFields($data) {
$checked = NULL;
foreach ($data as &$invoice) {
foreach ($data as &$invoice) {
foreach ($invoice['InvoiceDetail'] as $index => &$detail) {
//TODO: Unsure if DUEDATE is correct value for service end date.
/* Some one-off contracts have their start and end dates
* set to 1900-01-01. If this is the case, we need to set
* them equal to the dates on the invoice header. */
if ($detail['CONTSTARTDTE'] === $detail['CONTENDDTE']) {
$detail['CONTSTARTDTE'] = $invoice['InvoiceHeader']['DOCDATE'];
$detail['CONTENDDTE'] = $invoice['InvoiceHeader']['DUEDATE'];
}
foreach ($detail as $key => &$value) {
if ($checked >= 2) {
$checked = NULL;
}
// Conditional invoiceDetail fields
switch ($key) {
case 'SOPNUMBE':
//CR is credit. All others are charges.
$allowanceOrChargeIndicatorCode = 'ALLOWANCE';
} else
$allowanceOrChargeIndicatorCode = 'CHARGE';
$detail['allowanceOrChargeIndicatorCode'] = $allowanceOrChargeIndicatorCode;
break;
case 'CONTSTARTDTE':
//Use substr() to truncate time component
$value = $_serviceStartDate;
} else {
}
$checked++;
break;
case 'CONTENDDTE':
$value = $_serviceEndDate;
} else {
}
$checked++;
break;
}
//check if start/end contract dates differ > 30 days
if ($checked === 2) {
$newDates = $this->_checkDateSpan($detail['CONTSTARTDTE'], $detail['CONTENDDTE']);
$detail['CONTSTARTDTE'] = $newDates[0];
$detail['CONTENDDTE'] = $newDates[1];
}
}
}
}
}
return $data;
} |
