| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- <?php
- $utc_timezone = new DateTimeZone("UTC");
- $invoice_interval = new DateInterval("P30D");
- $field_names = [
- "BillNo",
- "Supplier",
- "BillDate",
- "DueDate",
- "Terms",
- "Location",
- "Memo",
- "Account",
- "LineDescription",
- "LineAmount",
- "LineTaxCode",
- "LineTaxAmount",
- ];
- fputcsv($handle, $field_names);
- foreach($tests as $test) {
- if($test->dts_tester_invoice_paid === null) continue;
- $project = $test->getProject();
- $template = $project->getTemplate();
- $location = $test->getLocation();
- $tester = $test->getTester();
- $values = $test->getValues(true);
- $test_cost = $test->test_fee > 0 ? $test->test_fee : $project->default_tester_fee;
- $travel_costs = $test->test_travel_cost > 0 ? $test->test_travel_cost : 0;
- $other_costs = $template->getTesterInvoiceCosts($values);
- $total_cost = $test_cost + $travel_costs + $other_costs;
- $invoice_generated_dt = new DateTime($test->dts_tester_invoice_generated, $utc_timezone);
- $invoice_date = $invoice_generated_dt->format("d/m/Y");
- $invoice_generated_dt->add($invoice_interval);
- $invoice_due_date = $invoice_generated_dt->format("d/m/Y");
- $output = [];
- $output[] = $test->getTesterInvoiceReference();
- $output[] = sprintf("%d %s %s", $tester->id, $tester->first_name, $tester->last_name);
- $output[] = $invoice_date;
- $output[] = $invoice_due_date;
- $output[] = "Net 30";
- $output[] = "";
- $output[] = "$location->id $location->name";
- $output[] = "Tester Fees";
- $output[] = "";
- $output[] = $total_cost;
- $output[] = "No VAT";
- $output[] = "0";
- fputcsv($handle, $output);
- }
|