WIP PreorderBilling 2025-03-22

This commit is contained in:
Frank Schubert
2025-03-22 14:50:08 +01:00
parent aebb463b74
commit 217b19026e
17 changed files with 2113 additions and 28 deletions
+13 -4
View File
@@ -108,7 +108,10 @@ $pagination_entity_name = "Billingrecords";
</div>
<div class="float-right">
<a class="btn btn-outline-primary mb-2" href="<?=self::getUrl("PreorderBilling", "importPreorders")?>">
<i class="fas fa-fw fa-file-import"></i> Rechnungsdatensätze erstellen
<i class="far fa-fw fa-file-import"></i> Rechnungsdatensätze erstellen
</a>
<a class="btn btn-primary mb-2 ml-2" href="<?=self::getUrl("PreorderBillingInvoice", "create")?>">
<i class="far fa-fw fa-file-invoice"></i> Rechnungen erstellen
</a>
</div>
</div>
@@ -140,7 +143,13 @@ $pagination_entity_name = "Billingrecords";
<td><?=$billing->preorder->adb_hausnummer->netzgebiet->name?></td>
<td><a href="<?=self::getUrl("Preorder", "Index", ["filter" => ["oaid" => $billing->oaid]])?>" target="_blank"><?=$billing->oaid?></a></td>
<td><?=$billing->order_date?></td>
<td><?=$billing->start_date?> -<br /><?=$billing->end_date?></td>
<td>
<?php if($billing->start_date == $billing->end_date): ?>
<?=$billing->start_date?>
<?php else: ?>
<?=$billing->start_date?> -<br /><?=$billing->end_date?>
<?php endif; ?>
</td>
<td>
<?=($billing->company) ? $billing->company."<br />" : ""?>
<?=($billing->firstname || $billing->lastname) ? $billing->firstname." ".$billing->lastname."<br />" : ""?>
@@ -154,8 +163,8 @@ $pagination_entity_name = "Billingrecords";
<?=$billing->product_name?>
</td>
<td><?=($billing->amount / (int)$billing->amount > 1) ? number_format($billing->amount,3,",",".") : (int)$billing->amount?></td>
<td class="<?=($billing->price < 0) ? "text-danger" : ""?>">€ <?=number_format($billing->price,4,",",".")?></td>
<td class="<?=($billing->price_setup < 0) ? "text-danger" : ""?>">€ <?=number_format($billing->price_setup,4,",",".")?></td>
<td class="<?=($billing->price < 0) ? "text-danger" : ""?>">€ <?=number_format($billing->price,2,",",".")?></td>
<td class="<?=($billing->price_setup < 0) ? "text-danger" : ""?>">€ <?=number_format($billing->price_setup,2,",",".")?></td>
<td><?=($billing->billing_delivery == "email") ? "Email" : "Papier"?></td>
<td></td>
</tr>
@@ -0,0 +1,179 @@
<?php
$pagination_baseurl = $this->getUrl($Mod, "Index");
$pagination_baseurl_params = ["filter" => $filter];
$pagination_entity_name = "Rechnungen";
?>
<?php include(realpath(dirname(__FILE__) . "/../../$mfLayoutPackage") . "/header.php"); ?>
<!-- start page title -->
<div class="row">
<div class="col-12">
<div class="page-title-box">
<div class="page-title-right">
<ol class="breadcrumb m-0">
<li class="breadcrumb-item"><a href="<?=self::getUrl("Dashboard")?>"><?=MFAPPNAME_SLUG?></a></li>
<li class="breadcrumb-item"><a href="<?=self::getUrl("Preordercampaign")?>">Vorbestellkampagnen</a></li>
<li class="breadcrumb-item active">Rechnungen</li>
</ol>
</div>
<h4 class="page-title">Rechnungen</h4>
</div>
</div>
</div>
<!-- end page title -->
<div class="row">
<div class="col-lg-12">
<div class="card">
<div class="card-body mb-3">
<h4 class="header-title mb-3">Filter</h4>
<form method="get" action="<?=self::getUrl("PreorderBillingInvoice")?>">
<div class="row">
<div class="col-1">
<label class="form-label" for="filter_oaid">OAID</label>
<input type="text" class="form-control" name="filter[oaid]" id="filter_oaid" value="<?=(array_key_exists("oaid", $filter)) ? $filter['oaid'] : ""?>"/>
</div>
<div class="col-2">
<label class="form-label" for="filter_owner_id">Netzbetreiber</label>
<select class="form-control" name="filter[owner_id]" id="filter_owner_id">
<option></option>
<?php foreach($netoperators as $netop): ?>
<option value="<?=$netop->id?>" <?=(is_array($filter) && $filter["owner_id"] == $netop->id) ? "selected='selected'" : ""?>><?=$netop->getCompanyOrName()?></option>
<?php endforeach; ?>
</select>
</div>
<div class="col-1">
<label class="form-label" for="filter_fibu_account_number">Fibu Kontonummer</label>
<input type="text" class="form-control" name="filter[fibu_account_number]" id="filter_fibu_account_number" value="<?=(array_key_exists("fibu_account_number", $filter)) ? $filter['fibu_account_number'] : ""?>"/>
</div>
<div class="col-2">
<label class="form-label" for="filter_product">Produkt</label>
<select class="form-control" name="filter[product_id]" id="filter_product_id">
<option></option>
<?php foreach(PreorderProduct::getWithTypes() as $product): ?>
<option value="<?=$product->id?>" <?=(is_array($filter) && $filter["product_id"] == $product->id) ? "selected='selected'" : ""?>><?=$product->name?></option>
<?php endforeach; ?>
</select>
</div>
<div class="col-1">
<label class="form-label" for="filter_start_date_from">Periode von</label>
<input type="text" class="form-control" name="filter[start_date_from]" id="filter_start_date_from" value="<?=(array_key_exists("start_date_from", $filter)) ? $filter['start_date_from'] : ""?>"/>
</div>
<div class="col-1">
<label class="form-label" for="filter_start_date_to">Periode bis</label>
<input type="text" class="form-control" name="filter[start_date_to]" id="filter_start_date_to" value="<?=(array_key_exists("start_date_to", $filter)) ? $filter['start_date_to'] : ""?>"/>
</div>
<div class="col-2">
<label class="form-label" for="filter_status">Status</label>
<select class="form-control" name="filter[status]" id="filter_status">
<option value="open" <?=(array_key_exists("status", $filter) && $filter['status'] == "open") ? "selected='selected'" : ""?>>Nur offene</option>
<option value="billed" <?=(array_key_exists("status", $filter) && $filter['status'] == "billed" ) ? "selected='selected'" : ""?>>Nur verrechnete</option>
</select>
</div>
</div>
<div class="row mt-2">
<div class="col">
<button type="submit" class="btn btn-primary">Filter anwenden</button>
<a class="btn btn-secondary" href="<?=self::getUrl("PreorderBilling")?>?resetFilter=1">Filter zurücksetzen</a>
</div>
</div>
</form>
</div>
</div>
<div class="card">
<div class="card-body mb-3">
<div class="row">
<div class="col-12">
<h4 class="header-title">Rechnungen</h4>
</div>
</div>
<div class="row">
<div class="col-12">
<?php include(realpath(dirname(__FILE__)."/../")."/tpl/pagination.php"); ?>
<?php include(realpath(dirname(__FILE__)."/../")."/tpl/pagination-summary.php"); ?>
<table class="table table-sm table-striped table-hover">
<tr>
<th>Rechnungsnummer</th>
<th>Rechnungsdatum</th>
<th>Kundennummer</th>
<th>Rechnungsadresse</th>
<th>Netto</th>
<th>Ust.</th>
<th>Brutto</th>
<th></th>
</tr>
<?php foreach($invoices as $invoice): ?>
<tr>
<td>
<a href="<?=self::getUrl("PreorderBillingInvoice", "downloadInvoice", ["id" => $invoice->id])?>"><i class="fas fa-download fa-fw"></i> <?=$invoice->invoice_number?></a>
<?php if($invoice->pdf): ?>
<i class="fas fa-fw fa-check" title="PDF generiert"></i>
<?php endif; ?>
<?php if($invoice->date_delivered): ?>
<i class="fas fa-fw fa-mail" title="per Email versendet am <?=date("d.m.Y H:i", $invoice->date_delivered)?>"></i>
<?php endif; ?>
</td>
<td><?=($invoice->invoice_date) ? (new DateTime($invoice->invoice_date))->format("d.m.Y") : ""?></td>
<td><?=$invoice->fibu_account_number?></td>
<td>
<?=($invoice->company) ? $invoice->company."<br />" : ""?>
<?=($invoice->firstname || $invoice->lastname) ? $invoice->firstname." ".$invoice->lastname."<br />" : ""?>
<?=$invoice->street?><br />
<?=$invoice->zip?> <?=$invoice->city?>
<?=($invoice->country != "Österreich") ? "<br >".$invoice->country : ""?>
</td>
<td>€ <?=number_format($invoice->total, 2, ",", ".")?></td>
<td>€ <?=number_format($invoice->total_gross - $invoice->total, 2, ",", ".")?></td>
<td>€ <?=number_format($invoice->total_gross, 2, ",", ".")?></td>
<td></td>
</tr>
<?php endforeach; ?>
</table>
<?php include(realpath(dirname(__FILE__)."/../")."/tpl/pagination-summary.php"); ?>
<?php include(realpath(dirname(__FILE__)."/../")."/tpl/pagination.php"); ?>
</div>
</div>
</div>
</div>
</div>
</div>
<script>
$("#filter_start_date_from").datepicker({
orientation: "bottom",
language: 'de',
format: "dd.mm.yyyy",
showWeekDays: true,
todayBtn: 'linked',
autoclose: true
});
$("#filter_start_date_to").datepicker({
orientation: "bottom",
language: 'de',
format: "dd.mm.yyyy",
showWeekDays: true,
todayBtn: 'linked',
autoclose: true
});
</script>
<?php include(realpath(dirname(__FILE__) . "/../../$mfLayoutPackage") . "/footer.php"); ?>
@@ -0,0 +1,43 @@
<!DOCTYPE html>
<html>
<head>
<title>Xinon Rechnung</title>
<meta charset="utf-8" />
</head>
<body style="border:0; margin: 0;font-family: sans-serif, Verdana;font-size: 11px;" onload="subst()">
<script>
function subst() {
var vars = {};
var query_strings_from_url = document.location.search.substring(1).split('&');
for (var query_string in query_strings_from_url) {
if (query_strings_from_url.hasOwnProperty(query_string)) {
var temp_var = query_strings_from_url[query_string].split('=', 2);
vars[temp_var[0]] = decodeURI(temp_var[1]);
}
}
var css_selector_classes = ['page', 'frompage', 'topage', 'webpage', 'section', 'subsection', 'date', 'isodate', 'time', 'title', 'doctitle', 'sitepage', 'sitepages'];
for (var css_class in css_selector_classes) {
if (css_selector_classes.hasOwnProperty(css_class)) {
var element = document.getElementsByClassName(css_selector_classes[css_class]);
for (var j = 0; j < element.length; ++j) {
element[j].textContent = vars[css_selector_classes[css_class]];
}
}
}
}
</script>
<div style="margin-bottom: 16px;height: 1px"></div>
<div style="color:grey;text-align: center;margin-bottom: 0">
<span>XINON GmbH | Fladnitz 150 | 8322 Studenzen</span><br>
<span>Tel.: +43 3115 40800 | E-Mail: office@xinon.at</span><br>
<span>UID: ATU68711968 | FN: 416556h | LG: Feldbach</span><br>
<span>IBAN: {{ bank_iban }} | BIC: {{ bank_bic }}</span><br>
</div>
<div style="text-align: right">Seite <span class="page"></span> von <span class="topage"></span></div>
<div style="margin-top: 16px;height: 1px"></div>
</body>
</html>
@@ -0,0 +1,143 @@
<!DOCTYPE html>
<html>
<head>
<title>Invoice Header</title>
<meta charset="utf-8" />
<style>
body {
border: 0;
margin: 0;
padding-top: 0;
font-family: "Open Sans", sans-serif, Verdana;
font-size: 12px;
}
.info-table {
border-collapse: collapse;
width: 100%;
}
.customer-details {
vertical-align: top;
font-size: 14px;
padding-left: 30pt;
width: 50%;
}
.invoice-details {
border-collapse: collapse;
width: 100%;
border: 2px solid #e1e1e1;
padding: 6px;
font-size: 12px;
}
.invoice-details tr {
padding-top: 0;
padding-bottom: 0;
}
.invoice-details th {
text-align: left;
font-size: 12px;
padding: 6px;
padding-top: 0;
padding-bottom: 0;
}
.invoice-details td {
text-align: left;
font-size: 12px;
padding: 6px;
padding-top: 0;
padding-bottom: 0;
}
.separator {
margin-top: 48px;
height: 1px;
}
#topSpacer {
margin-bottom: 32px;
height: 20px;
}
</style>
</head>
<body>
<div id="topSpacer"></div>
<table style="width: 100%; margin-bottom: 36px;">
<tr>
<td style="width: 60%; font-size: 14px; padding-top: 28px;">
<strong>RML Infrastruktur GmbH</strong><br />
Wirtschaftspark A<br />
8940 Liezen<br />
Österreich
</td>
<td style="width: 40%; text-align: right;">
<img alt="RML Logo" src="{{ basedir }}/public/assets/images/rml-logo-header.png" style="text-align:right;height: 125px;">
</td>
</tr>
</table>
<table style="width: 100%; border-collapse: collapse;">
<tr>
<td class="customer-details">
<div>{{ addressLine_1 }}</div>
<div>{{ addressLine_2 }}</div>
<div>{{ addressLine_3 }}</div>
<div>{{ addressLine_4 }}</div>
<div>{{ addressLine_5 }}</div>
</td>
<td>
<table class="info-table">
<tr>
<td style="width: 100%;">
<table class="invoice-details">
<tr>
<th>Rechnungsdatum:</th>
<td>{{ invoiceDate }}</td>
</tr>
<tr>
<th>Kundennummer:</th>
<td>{{ customerNumber }}</td>
</tr>
{{ vatHtml }}
<tr>
<th>&nbsp;</th>
<td></td>
</tr>
<tr>
<th>Sachbearbeiter:</th>
<td>{{ caseWorker }}</td>
</tr>
<tr>
<th>Telefon:</th>
<td>{{ caseWorkerPhone }}</td>
</tr>
<tr>
<th>Email:</th>
<td>{{ caseWorkerEmail }}</td>
</tr>
<tr>
<th>Unsere Auftragsnummer:</th>
<td>{{ orderNumber }}</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
<div class="separator"></div>
</body>
</html>
@@ -0,0 +1,158 @@
<?php
/**
* @var string $ressourcePathPrefix
* @var Invoice $invoice
* @var array $vat
*/
$net_total = $invoice->total;
$gross_total = $invoice->total_gross;
$is_credit = $net_total < 0;
$invoice_date = new DateTime($invoice->invoice_date);
$this->setReturnValue(['filename' => $invoice->invoice_number . ".pdf"]);
//die(json_encode($invoice->positions));
?>
<!DOCTYPE html>
<html>
<head>
<title>Rechnung</title>
<meta charset="utf-8" />
<!-- <link href="-->
<?php //= self::getResourcePath() ?><!--assets/css/bootstrap.min.css" rel="stylesheet" type="text/css" />-->
<style>
body {
margin-top: 0;
padding-top: 0;
/*padding-top: 20pt;*/
font-family: "Open Sans", sans-serif, Verdana;
font-size: 12px;
}
tr {
page-break-inside: avoid;
}
.uneven {
background-color: #ebebeb;
}
table tr td:last-child {
text-align: right;
}
.additionalRow td:first-child {
text-align: left;
padding-left: 20pt;
}
th {
height: 28px;
}
#invoiceTable tr th,
#invoiceTable tr td {
padding: 4px;
}
#invoiceTable tr td {
font-size: 11px;
}
tr.position td {
vertical-align: top;
}
tr.position td:first-child {
vertical-align: middle !important;
padding-left: 4pt;
}
#invoiceTable tr td:first-child {
max-width: 200pt;
}
</style>
</head>
<body>
<div>
<h2><?=($is_credit) ? "Gutschrift" : "Rechnung"?> <?=$invoice->invoice_number?></h2>
<table style="border-collapse: collapse; width: 100%;" id="invoiceTable">
<tr style="font-weight: bold; border-bottom: 1px solid black;" class="uneven">
<th style="text-align: left">Pos</th>
<th style="text-align: left">Artikel</th>
<th style="text-align: left">Leistung / Produkt</th>
<th style="text-align: right">Preis</th>
<th style="text-align: right">Menge</th>
<th style="text-align: left">Einheit</th>
<th style="text-align: right">Preis €</th>
<th style="text-align: right; padding-right: 4pt">Gesamt €</th>
</tr>
<?php
$i = 0;
foreach($invoice->positions as $p):
$amount = (float) number_format($p->amount, 3, ",", ".");
$price = number_format($p->price, 2, ",",".");
$price_total = number_format($p->price_total, 2, ",",".");
$price_gross = number_format($p->price_gross, 2, ",",".");
$vatrate = number_format($p->vatrate, 0, ",",".");
?>
<tr class="position <?=($i%2 == 0) ? "even" : "uneven" ?>">
<td style="text-align: left"><?=$i+1?></td>
<td style="text-align: left"><?=$p->article_number?></td>
<td style="text-align: left"><?=$p->article_name?></td>
<td style="text-align: right"><?=$price?> €</td>
<td style="text-align: right"><?=$amount?></td>
<td style="text-align: left"><?=$p->unit?></td>
<td style="text-align: right"><?=$price?> €</td>
<td style="padding-right: 4pt;"><?=$price_total?> €</td>
</tr>
<?php
$i++;
endforeach;
?>
<tr style="font-weight: bold; background-color: #ebebeb; border-bottom: 1px solid black;border-top: 1px solid black">
<td colspan="6">Gesamt Netto:</td>
<td colspan="2" style="text-align: right; padding-right: 4pt;"><?=number_format($net_total, 2, ",","."). " €"?></td>
</tr>
<?php foreach ($vat as $rate => $vat_total): ?>
<?php if($rate > 0): ?>
<tr style="font-size: 11px;border-bottom: 1px solid black;">
<td colspan="6">+ USt. <?=number_format($rate, 0, ",", ".")?>%:</td>
<td colspan="2" style="text-align: right; padding-right: 4pt;"><?=number_format($vat_total, 2, ",","."). " €"?></td>
</tr>
<?php endif; ?>
<?php endforeach; ?>
<!-- double underline border on bottom -->
<tr style="font-weight: bold; border-bottom: 3px double black; background-color: #ebebeb;">
<td colspan="6">Gesamt Brutto:</td>
<td colspan="2" style="text-align: right; padding-right: 4pt;"><?=number_format($gross_total, 2, ",","."). " €"?></td>
</tr>
</table>
<div style="margin-top: 20pt;">
<?php if($invoice->tax_text): ?>
<p style="font-weight: bold;"><?=$invoice->tax_text?></p>
<?php endif; ?>
</div>
</body>
</html>