public function testRaiseInvoice() { $client = Client::GetClient(2); $project = Project::GetProject(4); $quotes = $project->quotations; $quote = $quotes[0]; $discount = 5; $invoice = Invoice::RaiseQuotationInvoice($quote->id, $discount); //in session $invoice->post(); $this->assertInstanceOf('Invoice', $invoice); }
public static function ProjectReport() { $project = Project::GetProject($_GET['sid']); //, $_GET['period'], $_GET['all'] echo ' <div class="logo"> <h5 style="margin-bottom:-15px;margin-top:0px;font-size:14px;">Date: ' . date('d/m/Y') . '</h5> <h4>' . $project->name . '</h4><h5>CLIENT: ' . $project->client->name . '</h5>'; /*if ($_GET['period'] != '' && $_GET['period'] ) { echo '<h5 style="margin-top:-10px">Period: '.$_GET['period'].'</h5>'; } */ echo '</div> <h5>PROJECT ACTIVITIES</h5> <table class="table table-bordered table-striped" style="text-align:center;margin-left:0;margin-right:0;width:760px;font-size:12px;"> <thead class="title"> <tr> <td>NO</td> <td>SERVICE</td> <td>TASK</td> <td>QTY</td> <td>DATE PROPOSED</td> <td>DATE EXECUTED</td> <td>STATUS</td> </tr> </thead> <tbody>'; $count = 1; foreach ($project->activities as $activity) { if ($activity->status == 0) { $status = '<td style="color: #027c97">SCHEDULED</td>'; } elseif ($activity->status == 1) { $status = '<td style="color: #e8e624">ON GOING</td>'; } elseif ($activity->status == 2) { $status = '<td style="color: #e81c34">STALLED</td>'; } elseif ($activity->status == 3) { $status = '<td style="color: #27c97b">COMPLETED</td>'; } elseif ($activity->status == 4) { $status = '<td style="color: #9c2488">SUSPENDED</td>'; } echo '<tr> <td>' . $count . '</td> <td>' . $activity->service . '</td> <td>' . $activity->task . '</td> <td>' . $activity->instances . '</td> <td>' . $activity->requestDate . '</td> <td>' . $activity->executionDate . '</td>' . $status . ' </tr>'; $count++; } echo '</tbody> </table>'; echo '<h5>QUOTED ITEMS</h5> <table class="table table-bordered table-striped" style="text-align:center;margin-left:0;margin-right:0;width:760px;font-size:12px;"> <thead class="title"> <tr> <td>NO</td> <td>SERVICE</td> <td>DESCRIPTION</td> <td>QTY</td> <td>UNIT PRICE</td> <td>VAT</td> <td>SUB-TOTAL</td> </tr> </thead> <tbody>'; $count = 1; $amount = 0.0; foreach ($project->quotations as $quote) { foreach ($quote->lineItems as $item) { echo '<tr> <td>' . $count . '</td> <td>' . $item->itemName . '</td> <td>' . $item->itemDesc . '</td> <td>' . $item->quantity . '</td> <td>' . $item->unitPrice . '</td> <td>' . $item->tax . '</td> <td><script>document.writeln((' . ($item->quantity * $item->unitPrice + $item->quantity * $item->unitPrice * $item->tax / 100) . ').formatMoney(2, \'.\', \',\'));</script></td> </tr>'; $count++; } $amount += $quote->total; } echo '</tbody> </table> <div class="logo"> <h5 style="margin: 5px 0 0 5px;float:right">Total Quoted: <b>Ksh. <script>document.writeln((' . $amount . ').formatMoney(2, \'.\', \',\'));</script></b></h5> </div>'; $invoices = SalesInvoice::GetProjectInvoices($_GET['sid'], $project->client); echo '<h5>INVOICED ITEMS</h5> <table class="table table-bordered table-striped" style="text-align:center;margin-left:0;margin-right:0;width:760px;font-size:12px;"> <thead class="title"> <tr> <td>NO</td> <td>DATE</td> <td>ITEM</td> <td>DESCRIPTION</td> <td>QTY</td> <td>UNIT PRICE</td> <td>VAT</td> <td>SUB-TOTAL</td> </tr> </thead> <tbody>'; $count = 1; $amount = 0.0; foreach ($invoices as $invoice) { foreach ($invoice->lineItems as $item) { echo '<tr> <td>' . $count . '</td> <td>' . $invoice->date . '</td> <td>' . $item->itemName . '</td> <td>' . $item->itemDesc . '</td> <td>' . $item->quantity . '</td> <td>' . $item->unitPrice . '</td> <td>' . $item->tax . '</td> <td><script>document.writeln((' . ($item->quantity * $item->unitPrice + $item->quantity * $item->unitPrice * $item->tax / 100) . ').formatMoney(2, \'.\', \',\'));</script></td> </tr>'; $count++; } $amount += $invoice->total->amount; } echo '</tbody> </table> <div class="logo"> <h5 style="margin: 5px 0 0 5px;float:right">Total Invoiced: <b>Ksh. <script>document.writeln((' . $amount . ').formatMoney(2, \'.\', \',\'));</script></b></h5> </div>'; $expenses = ExpenseVoucher::GetProjectVouchers($_GET['sid'], $project->client); echo '<h5>PROJECT EXPENSES</h5> <table class="table table-bordered table-striped" style="text-align:center;margin-left:0;margin-right:0;width:760px;font-size:12px;"> <thead class="title"> <tr> <td>NO</td> <td>DATE</td> <td>PARTY</td> <td>DESCRIPTION</td> <td>AMOUNT</td> </tr> </thead> <tbody>'; $count = 1; $amount = 0.0; foreach ($expenses as $expense) { foreach ($expense->items as $item) { echo '<tr> <td>' . $count . '</td> <td>' . $expense->date . '</td> <td>' . $item->claimant->name . '</td> <td>' . $item->description . '</td> <td><script>document.writeln((' . $item->adjusted . ').formatMoney(2, \'.\', \',\'));</script></td> </tr>'; $count++; $amount += $item->adjusted; } } echo '</tbody> </table> <div class="logo"> <h5 style="margin: 5px 0 0 5px;float:right">Total Expensed: <b>Ksh. <script>document.writeln((' . $amount . ').formatMoney(2, \'.\', \',\'));</script></b></h5> </div>'; $payments = ReceiptVoucher::GetProjectReceipts($_GET['sid']); echo '<h5>RECEIVED PAYMENTS</h5> <table class="table table-bordered table-striped" style="text-align:center;margin-left:0;margin-right:0;width:760px;font-size:12px;"> <thead class="title"> <tr> <td>REC. NO</td> <td>DATE</td> <td>AMOUNT</td> <td>VOUCHER</td> <td>DESCRIPTION</td> </tr> </thead> <tbody>'; $amount = 0.0; if (count($payments) > 0) { foreach ($payments as $payment) { echo '<tr> <td>' . $payment['id'] . '</td> <td>' . $payment['datetime'] . '</td> <td><script>document.writeln((' . $payment['amount'] . ').formatMoney(2, \'.\', \',\'));</script></td> <td>' . $payment['voucher_no'] . '</td> <td>' . $payment['description'] . '</td> </tr>'; $amount += $payment['amount']; } } echo '</tbody> </table> <div class="logo"> <h5 style="margin: 5px 0 0 5px;float:right">Total Received: <b>Ksh. <script>document.writeln((' . $amount . ').formatMoney(2, \'.\', \',\'));</script></b></h5> </div>'; }
<?php //The aim of a test is to test for the end user use cases, this is their originating principle - BDD, TDD require_once '/../domain/LSOfficeDomain.php'; $client = Client::GetParty(2); $project = Project::GetProject(20); echo count($project->getActivities()); //$invoice->post(); ?>
public function post() { if ($this->prepare()) { $voucher = TransactionProcessor::ProcessPurchaseTX($this); if ($voucher) { if ($this->invoice->orderIds != null && $this->invoice->orderIds != '') { $this->invoice->loadOrders(); foreach ($this->invoice->orders as $order) { $order->setpurchased(); } } if ($this->invoice->projectId != 0) { $project = Project::GetProject($this->invoice->projectId); $project->debit($this->amount); } //TX successful $this->invoice->updateStatus(1); $extras = new stdClass(); $extras->amount = $this->invoice->amount->amount; $extras->tax = $this->invoice->taxamt->amount; $extras->discount = $this->invoice->discamt->amount; $extras->total = $this->invoice->total->amount; $extras->balance = $this->invoice->balance->amount; //$voucher->setExtras($extras); return $voucher; } else { return false; } } }
public function getProject($projectid) { if ($this->validateAdmin()) { echo json_encode(Project::GetProject($projectid)); } else { echo 0; } }
private function processLatestProjects() { try { $sql = 'SELECT id FROM projects ORDER BY modified DESC LIMIT 0,6'; $res = DatabaseHandler::GetAll($sql); $sql2 = 'SELECT count(id) FROM projects'; $res2 = DatabaseHandler::GetOne($sql2); $projects = []; foreach ($res as $project) { $projects[] = Project::GetProject(intval($project['id'])); } $obj = new stdClass(); $obj->projects = $projects; $obj->total = $res2; $this->latestProjects = $obj; } catch (Exception $e) { } }
public static function ReceivePayment($clientId, $purpose, $ledgerId, $amount, $voucherno, $descr) { try { $datetime = new DateTime(); if ($purpose == "G") { $ref = $descr; $purp = 0; } else { $prj = Project::GetProject(intval($purpose)); $ref = $prj->name . " - " . $descr; $purp = $purpose; } $sql = 'INSERT INTO receipts (client_id, project_id, voucher_no, amount, ledger_id, description, status) VALUES (' . $clientId . ', ' . $purp . ', "' . $voucherno . '", ' . $amount . ', ' . $ledgerId . ', "' . $ref . '", 0)'; DatabaseHandler::Execute($sql); $sql2 = 'SELECT * FROM receipts WHERE client_id = ' . $clientId . ' ORDER BY id DESC LIMIT 0,1'; $res = DatabaseHandler::GetRow($sql2); return self::initialize($res); } catch (Exception $e) { } }