WIP Contract/Billing 2024-07-04
This commit is contained in:
@@ -65,7 +65,7 @@ class InvoiceController extends mfBaseController {
|
||||
}
|
||||
|
||||
if(array_key_exists("address", $filter)) {
|
||||
if(array_key_exists("address", $filter) && $filter["address"]) {
|
||||
if($filter["address"]) {
|
||||
$search = $this->db()->escape($filter['address']);
|
||||
if(!array_key_exists("add-where", $new_filter)) $new_filter["add-where"] = "";
|
||||
$new_filter['add-where'] .= " AND (street like '%$search%' OR zip like '%$search%' OR city like '%$search%' OR country like '%$search%')";
|
||||
@@ -102,7 +102,7 @@ class InvoiceController extends mfBaseController {
|
||||
if(!array_key_exists($p->vatrate, $vat)) {
|
||||
$vat[$p->vatrate] = 0;
|
||||
}
|
||||
$vat[$p->vatrate] += $p->price_gross - $p->price;
|
||||
$vat[$p->vatrate] += $p->price_gross - ($p->price * $p->amount);
|
||||
}
|
||||
|
||||
$pdf_vars = [
|
||||
@@ -153,9 +153,13 @@ class InvoiceController extends mfBaseController {
|
||||
//var_dump($owner_id, $billingaddress_id, $bills);exit;
|
||||
|
||||
$invoice_data = [];
|
||||
$invoice_vatrate = 20;
|
||||
|
||||
foreach($billing_rows as $bill) {
|
||||
$vatrate = $bill->vatrate;
|
||||
$vatarea = $bill->vatarea;
|
||||
$invoice_vatrate = $bill->vatgroup->rates[$vatarea]->rate;
|
||||
|
||||
$vatrate = $invoice_vatrate;
|
||||
$price = $bill->price;
|
||||
$price_total = $bill->price * $bill->amount;
|
||||
$price_gross = ($vatrate) ? $price_total + ($price_total / 100) * $vatrate : $price_total;
|
||||
@@ -177,6 +181,9 @@ class InvoiceController extends mfBaseController {
|
||||
$position_data["amount"] = $bill->amount;
|
||||
$position_data["billing_period"] = $bill->billing_period;
|
||||
|
||||
$position_data["fibu_cost_account"] = $bill->vatgroup->rates[$vatarea]->account;
|
||||
$position_data["fibu_cost_account_legacy"] = $bill->vatgroup->rates[$vatarea]->legacy_account;
|
||||
$position_data["fibu_taxcode"] = $bill->vatgroup->rates[$vatarea]->taxcode;
|
||||
|
||||
if($is_setup_only) {
|
||||
$this->log->debug("Contract ID ". $bill->contract_id." is setup only");
|
||||
@@ -219,6 +226,8 @@ class InvoiceController extends mfBaseController {
|
||||
$invoice_data["owner_id"] = $owner_id;
|
||||
$invoice_data["billingaddress_id"] = $billingaddress_id;
|
||||
$invoice_data["customer_number"] = $bill->customer_number;
|
||||
$invoice_data["fibu_account_number"] = $bill->fibu_account_number;
|
||||
|
||||
$invoice_data["company"] = $bill->company;
|
||||
$invoice_data["firstname"] = $bill->firstname;
|
||||
$invoice_data["lastname"] = $bill->lastname;
|
||||
@@ -239,6 +248,12 @@ class InvoiceController extends mfBaseController {
|
||||
$invoice_data["total_vat"] = 0;
|
||||
|
||||
|
||||
$invoice_data["fibu_cost_area"] = $vatarea;
|
||||
$invoice_data["fibu_cost_account"] = $bill->vatgroup->rates[$vatarea]->account;
|
||||
$invoice_data["fibu_cost_account_legacy"] = $bill->vatgroup->rates[$vatarea]->legacy_account;
|
||||
$invoice_data["fibu_taxcode"] = $bill->vatgroup->rates[$vatarea]->taxcode;
|
||||
$invoice_data["tax_text"] = $bill->vatgroup->rates[$vatarea]->invoice_text;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -265,9 +280,9 @@ class InvoiceController extends mfBaseController {
|
||||
// add Invoice::id to Invoiceposition
|
||||
$position->invoice_id = $invoice->id;
|
||||
|
||||
|
||||
if(!$position->vatrate) {
|
||||
if(!$invoice_vatrate || !$position->vatrate) {
|
||||
$total_net += $position->price_total;
|
||||
$total_gross += $position->price_total;
|
||||
} else {
|
||||
$total_vat += ($position->price_total / 100) * $position->vatrate;
|
||||
$total_net += $position->price_total;
|
||||
|
||||
Reference in New Issue
Block a user