mirror of
https://github.com/OpenXE-org/OpenXE.git
synced 2024-11-15 04:27:14 +01:00
Zahlungen improvements
This commit is contained in:
parent
1f52278758
commit
e356051f5a
@ -6551,13 +6551,24 @@ r.land as land, p.abkuerzung as projekt, r.zahlungsweise as zahlungsweise,
|
|||||||
// $columnfilter = true;
|
// $columnfilter = true;
|
||||||
|
|
||||||
// SQL statement
|
// SQL statement
|
||||||
$sql = "SELECT SQL_CALC_FOUND_ROWS r.id,'<img src=./themes/{$this->app->Conf->WFconf['defaulttheme']}/images/details_open.png class=details>' as open,concat('<input type=\"checkbox\" name=\"auswahl[]\" value=\"',r.id,'\" />')as auswahl, r.belegnr, DATE_FORMAT(r.datum,'%d.%m.%Y') as vom,
|
$sql = "SELECT SQL_CALC_FOUND_ROWS
|
||||||
if(r.kundennummer <> '',r.kundennummer,adr.kundennummer),
|
r.id,
|
||||||
|
'<img src=./themes/{$this->app->Conf->WFconf['defaulttheme']}/images/details_open.png class=details>' as open,
|
||||||
CONCAT(" . $this->app->erp->MarkerUseredit("r.name", "r.useredittimestamp") . ", if(r.internebezeichnung!='',CONCAT('<br><i style=color:#999>',r.internebezeichnung,'</i>'),'')) as kunde,
|
concat('<input type=\"checkbox\" name=\"auswahl[]\" value=\"',r.id,'\" />') as auswahl,
|
||||||
r.land as land, p.abkuerzung as projekt, r.zahlungsweise as zahlungsweise, FORMAT(r.soll,2{$extended_mysql55} ) as soll, ifnull(r.waehrung,'EUR'),
|
r.belegnr,
|
||||||
if(r.soll-r.ist+r.skonto_gegeben!=0 AND r.ist > 0 AND r.zahlungsstatus!='bezahlt','teilbezahlt',r.zahlungsstatus) as zahlung,
|
DATE_FORMAT(r.datum,'%d.%m.%Y') as vom,
|
||||||
if(r.soll-r.ist+r.skonto_gegeben!=0 AND r.ist > 0,FORMAT(r.ist-r.soll+r.skonto_gegeben,2{$extended_mysql55}),FORMAT((r.soll-r.ist+r.skonto_gegeben)*-1,2{$extended_mysql55})) as fehlt, if(r.status = 'storniert' AND r.teilstorno = 1,'TEILSTORNO',UPPER(r.status)) as status, ".(!empty($zusatzcols)?implode(', ',$zusatzcols).',':'')." r.id
|
if(r.kundennummer <> '',r.kundennummer,adr.kundennummer),
|
||||||
|
CONCAT(" . $this->app->erp->MarkerUseredit("r.name", "r.useredittimestamp") . ", if(r.internebezeichnung!='',CONCAT('<br><i style=color:#999>',r.internebezeichnung,'</i>'),'')) as kunde,
|
||||||
|
r.land as land,
|
||||||
|
p.abkuerzung as projekt,
|
||||||
|
r.zahlungsweise as zahlungsweise,
|
||||||
|
FORMAT(r.soll,2{$extended_mysql55} ) as soll,
|
||||||
|
ifnull(r.waehrung,'EUR'),
|
||||||
|
if(r.soll-r.ist+r.skonto_gegeben!=0 AND r.ist > 0 AND r.zahlungsstatus!='bezahlt','teilbezahlt',r.zahlungsstatus) as zahlung,
|
||||||
|
if(r.soll-r.ist+r.skonto_gegeben!=0 AND r.ist > 0,FORMAT(r.ist-r.soll+r.skonto_gegeben,2{$extended_mysql55}),FORMAT((r.soll-r.ist+r.skonto_gegeben)*-1,2{$extended_mysql55})) as fehlt,
|
||||||
|
if(r.status = 'storniert' AND r.teilstorno = 1,'TEILSTORNO',UPPER(r.status)) as status,
|
||||||
|
".(!empty($zusatzcols)?implode(', ',$zusatzcols).',':'')."
|
||||||
|
r.id
|
||||||
FROM rechnung r LEFT JOIN projekt p ON p.id=r.projekt LEFT JOIN adresse adr ON r.adresse=adr.id LEFT JOIN auftrag au ON au.id = r.auftragid ";
|
FROM rechnung r LEFT JOIN projekt p ON p.id=r.projekt LEFT JOIN adresse adr ON r.adresse=adr.id LEFT JOIN auftrag au ON au.id = r.auftragid ";
|
||||||
if(isset($parameter['artikel']) && !empty($parameter['artikel'])) {
|
if(isset($parameter['artikel']) && !empty($parameter['artikel'])) {
|
||||||
$artikelid = $this->app->DB->Select("SELECT id FROM artikel where geloescht != 1 AND nummer != 'DEL' AND nummer != '' AND nummer = '".$this->app->DB->real_escape_string(reset(explode(' ',trim($parameter['artikel']))))."' LIMIT 1");
|
$artikelid = $this->app->DB->Select("SELECT id FROM artikel where geloescht != 1 AND nummer != 'DEL' AND nummer != '' AND nummer = '".$this->app->DB->real_escape_string(reset(explode(' ',trim($parameter['artikel']))))."' LIMIT 1");
|
||||||
|
@ -7088,6 +7088,7 @@ title: 'Abschicken',
|
|||||||
$navarray['menu']['admin'][$menu]['sec'][] = array('Arbeitsnachweis','arbeitsnachweis','list');
|
$navarray['menu']['admin'][$menu]['sec'][] = array('Arbeitsnachweis','arbeitsnachweis','list');
|
||||||
$navarray['menu']['admin'][$menu]['sec'][] = array('Gutschrift / '.$this->Firmendaten("bezeichnungstornorechnung"),'gutschrift','list');
|
$navarray['menu']['admin'][$menu]['sec'][] = array('Gutschrift / '.$this->Firmendaten("bezeichnungstornorechnung"),'gutschrift','list');
|
||||||
$navarray['menu']['admin'][$menu]['sec'][] = array('Proformarechnung','proformarechnung','list');
|
$navarray['menu']['admin'][$menu]['sec'][] = array('Proformarechnung','proformarechnung','list');
|
||||||
|
$navarray['menu']['admin'][$menu]['sec'][] = array('Kontoauszüge','kontoauszuege','list');
|
||||||
$navarray['menu']['admin'][$menu]['sec'][] = array('Abolauf','rechnungslauf','rechnungslauf');
|
$navarray['menu']['admin'][$menu]['sec'][] = array('Abolauf','rechnungslauf','rechnungslauf');
|
||||||
$navarray['menu']['admin'][$menu]['sec'][] = array('Mahnwesen','mahnwesen','list');
|
$navarray['menu']['admin'][$menu]['sec'][] = array('Mahnwesen','mahnwesen','list');
|
||||||
|
|
||||||
@ -36021,7 +36022,7 @@ function Firmendaten($field,$projekt="")
|
|||||||
* Gutschrift -> Rechnung -> Auftrag OR Verbindlichkeit
|
* Gutschrift -> Rechnung -> Auftrag OR Verbindlichkeit
|
||||||
* Results array of ids, types, belegnr
|
* Results array of ids, types, belegnr
|
||||||
*/
|
*/
|
||||||
public function GetZahlungenAssociatedDocuments(int $id, string $type) : array {
|
public function GetZahlungenAssociatedDocuments(int $id, string $type, string $lastlevel = 'auftrag') : array {
|
||||||
|
|
||||||
$assocs = array(
|
$assocs = array(
|
||||||
array(
|
array(
|
||||||
@ -36056,6 +36057,11 @@ function Firmendaten($field,$projekt="")
|
|||||||
// Go to highest level
|
// Go to highest level
|
||||||
$above = $assocs[array_search($type,array_column($assocs,'type'))]['above'];
|
$above = $assocs[array_search($type,array_column($assocs,'type'))]['above'];
|
||||||
while ($above) {
|
while ($above) {
|
||||||
|
|
||||||
|
if ($type == $lastlevel) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
$sql = "SELECT ".$above."id as id FROM ".$type." WHERE id = ".$id;
|
$sql = "SELECT ".$above."id as id FROM ".$type." WHERE id = ".$id;
|
||||||
$above_id = $this->app->DB->SelectArr($sql)[0];
|
$above_id = $this->app->DB->SelectArr($sql)[0];
|
||||||
if (!empty($above)) {
|
if (!empty($above)) {
|
||||||
@ -36090,16 +36096,18 @@ function Firmendaten($field,$projekt="")
|
|||||||
* Results array of payments with information
|
* Results array of payments with information
|
||||||
* Gutschrift -> Rechnungid, Rechnung -> Auftragid
|
* Gutschrift -> Rechnungid, Rechnung -> Auftragid
|
||||||
*/
|
*/
|
||||||
public function GetZahlungen(int $id, string $type) : array {
|
public function GetZahlungen(int $id, string $type, bool $cascade = false, string $lastlevel = 'auftrag') : array {
|
||||||
|
|
||||||
$documents = $this->GetZahlungenAssociatedDocuments($id, $type);
|
if ($cascade) {
|
||||||
|
$documents = $this->GetZahlungenAssociatedDocuments($id, $type, $lastlevel);
|
||||||
|
} else {
|
||||||
|
$documents = array(array('id' => $id, 'type' => $type));
|
||||||
|
}
|
||||||
|
|
||||||
if (empty($documents)) {
|
if (empty($documents)) {
|
||||||
return(array());
|
return(array());
|
||||||
}
|
}
|
||||||
|
|
||||||
// print_r($documents);
|
|
||||||
|
|
||||||
$zahlungen = array();
|
$zahlungen = array();
|
||||||
|
|
||||||
$tables = array(
|
$tables = array(
|
||||||
@ -36148,9 +36156,44 @@ function Firmendaten($field,$projekt="")
|
|||||||
return($zahlungen);
|
return($zahlungen);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function GetZahlung(int $id, string $type, bool $cascade = false, string $lastlevel = 'auftrag') {
|
||||||
|
$zahlungen = $this->GetZahlungen($id, $type, $cascade);
|
||||||
|
if (empty($zahlungen)) {
|
||||||
|
$zahlbetrag = 0;
|
||||||
|
} else {
|
||||||
|
$zahlbetrag = array_sum(array_column($zahlungen,'betrag'));
|
||||||
|
}
|
||||||
|
return($zahlbetrag);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Calculate the payment saldo of a document
|
* Calculate the payment saldo of a document
|
||||||
|
* Auftrag: gesamtsumme, rechnung: soll, gutschrift: soll verbindlichkeit: betrag
|
||||||
*/
|
*/
|
||||||
|
public function GetSaldoDokument($id, $type, string $lastlevel = 'auftrag') {
|
||||||
|
|
||||||
|
$zahlbetrag = $this->GetZahlung($id, $type, false);
|
||||||
|
|
||||||
|
$sollspalten = array(
|
||||||
|
'auftrag' => 'gesamtsumme',
|
||||||
|
'rechnung' => 'soll',
|
||||||
|
'gutschrift' => 'soll',
|
||||||
|
'verbindlichkeit' => 'betrag'
|
||||||
|
);
|
||||||
|
|
||||||
|
$sql = "SELECT ".$sollspalten[$type]." as sollbetrag FROM ".$type." WHERE id =".$id;
|
||||||
|
|
||||||
|
// echo($sql);
|
||||||
|
|
||||||
|
$result = $this->app->DB->SelectArr($sql);
|
||||||
|
|
||||||
|
if (!empty($result)) {
|
||||||
|
$sollbetrag = $result[0]['sollbetrag'];
|
||||||
|
} else {
|
||||||
|
$sollbetrag = 0;
|
||||||
|
}
|
||||||
|
return($sollbetrag-$zahlbetrag);
|
||||||
|
}
|
||||||
|
|
||||||
public function ANABREGSNeuberechnen($id,$art,$force=false)
|
public function ANABREGSNeuberechnen($id,$art,$force=false)
|
||||||
{
|
{
|
||||||
|
@ -3423,7 +3423,7 @@ class Auftrag extends GenAuftrag
|
|||||||
{
|
{
|
||||||
$id = $this->app->Secure->GetGET('id');
|
$id = $this->app->Secure->GetGET('id');
|
||||||
|
|
||||||
$zahlungen = $this->app->erp->GetZahlungen($id,'auftrag');
|
$zahlungen = $this->app->erp->GetZahlungen($id,'auftrag',true);
|
||||||
|
|
||||||
// print_r($zahlungen);
|
// print_r($zahlungen);
|
||||||
|
|
||||||
@ -3451,6 +3451,17 @@ class Auftrag extends GenAuftrag
|
|||||||
</td>
|
</td>
|
||||||
</tr>";
|
</tr>";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$saldo = $this->app->erp->GetSaldoDokument($id,'auftrag');
|
||||||
|
|
||||||
|
$result .= "
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
".$saldo."
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
";
|
||||||
|
|
||||||
return("<table width=100% border=0 class=auftrag_cell cellpadding=0 cellspacing=0>".$result."</table>");
|
return("<table width=100% border=0 class=auftrag_cell cellpadding=0 cellspacing=0>".$result."</table>");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div style="background-color:white">
|
<div style="background-color:white">
|
||||||
<h2 class="greyh2">{|Zahlungen|}</h2>
|
<h2 class="greyh2">Zahlungsübersicht</h2>
|
||||||
<div style="padding:10px">
|
<div style="padding:10px">
|
||||||
[ZAHLUNGEN]
|
[ZAHLUNGEN]
|
||||||
</div>
|
</div>
|
||||||
|
@ -44,7 +44,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div style="background-color:white">
|
<div style="background-color:white">
|
||||||
<h2 class="greyh2">Zahlungen</h2>
|
<h2 class="greyh2">Zahlungsübersicht</h2>
|
||||||
<div style="padding:10px">
|
<div style="padding:10px">
|
||||||
[ZAHLUNGEN]
|
[ZAHLUNGEN]
|
||||||
</div>
|
</div>
|
||||||
@ -69,15 +69,12 @@
|
|||||||
[PDFARCHIV]
|
[PDFARCHIV]
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div style="background-color:white">
|
<!--
|
||||||
<h2 class="greyh2">Deckungsbeitrag</h2>
|
<div style="background-color:white">
|
||||||
<div style="padding:10px">
|
<h2 class="greyh2">Deckungsbeitrag</h2>
|
||||||
|
<div style="padding:10px">
|
||||||
|
<div class="info">Dieses Modul ist erst ab Version Professional verfügbar</div>
|
||||||
<div class="info">Dieses Modul ist erst ab Version Professional verfügbar</div>
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
-->
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
@ -659,7 +659,7 @@ class Gutschrift extends GenGutschrift
|
|||||||
{
|
{
|
||||||
$id = $this->app->Secure->GetGET('id');
|
$id = $this->app->Secure->GetGET('id');
|
||||||
|
|
||||||
$zahlungen = $this->app->erp->GetZahlungen($id,'gutschrift');
|
$zahlungen = $this->app->erp->GetZahlungen($id,'gutschrift',true);
|
||||||
|
|
||||||
// print_r($zahlungen);
|
// print_r($zahlungen);
|
||||||
|
|
||||||
@ -687,6 +687,30 @@ class Gutschrift extends GenGutschrift
|
|||||||
</td>
|
</td>
|
||||||
</tr>";
|
</tr>";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$sum = array_sum(array_column($zahlungen,'betrag'))." ".$zahlung['waehrung'];
|
||||||
|
|
||||||
|
if ($sum != 0) {
|
||||||
|
$result .= "
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<b>
|
||||||
|
Summe:
|
||||||
|
</b>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<b>
|
||||||
|
".$sum."
|
||||||
|
</b>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
";
|
||||||
|
}
|
||||||
|
|
||||||
return("<table width=100% border=0 class=auftrag_cell cellpadding=0 cellspacing=0>".$result."</table>");
|
return("<table width=100% border=0 class=auftrag_cell cellpadding=0 cellspacing=0>".$result."</table>");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1770,11 +1770,12 @@ class Rechnung extends GenRechnung
|
|||||||
$this->app->Tpl->Set('VORKASSE','');
|
$this->app->Tpl->Set('VORKASSE','');
|
||||||
}
|
}
|
||||||
|
|
||||||
// $saldo=$this->app->DB->Select("SELECT ist-skonto_gegeben FROM rechnung WHERE id='$id'");
|
$ist = $this->app->erp->EUR($this->app->erp->GetZahlung($id,'rechnung'));
|
||||||
|
$this->app->Tpl->Set('ISTDB',$ist);
|
||||||
|
|
||||||
$saldo = $this->app->erp->EUR($this->RechnungSaldo($id));
|
$istgs = $this->app->erp->EUR($this->app->erp->GetZahlung($id,'rechnung',true,'rechnung'));
|
||||||
|
$this->app->Tpl->Set('ISTGS',$istgs);
|
||||||
|
|
||||||
$this->app->Tpl->Set('LIVEIST',"$saldo");
|
|
||||||
|
|
||||||
if($schreibschutz=="1" && $this->app->erp->RechteVorhanden('rechnung','schreibschutz'))
|
if($schreibschutz=="1" && $this->app->erp->RechteVorhanden('rechnung','schreibschutz'))
|
||||||
{
|
{
|
||||||
@ -2086,8 +2087,17 @@ class Rechnung extends GenRechnung
|
|||||||
|
|
||||||
public function RechnungList()
|
public function RechnungList()
|
||||||
{
|
{
|
||||||
|
|
||||||
$this->app->DB->Update("UPDATE rechnung SET zahlungsstatus='offen' WHERE zahlungsstatus=''");
|
$this->app->DB->Update("UPDATE rechnung SET zahlungsstatus='offen' WHERE zahlungsstatus=''");
|
||||||
|
|
||||||
|
// First refresh all open items
|
||||||
|
$openids = $this->app->DB->SelectArr("SELECT id from rechnung WHERE zahlungsstatus = 'offen'");
|
||||||
|
|
||||||
|
foreach ($openids as $openid) {
|
||||||
|
$saldo = $this->app->erp->GetSaldoDokument($openid['id'],'rechnung');
|
||||||
|
$this->app->DB->Update("UPDATE rechnung SET ist = soll-".$saldo." WHERE id=".$openid['id']);
|
||||||
|
}
|
||||||
|
|
||||||
if($this->app->Secure->GetPOST('ausfuehren') && $this->app->erp->RechteVorhanden('rechnung', 'edit'))
|
if($this->app->Secure->GetPOST('ausfuehren') && $this->app->erp->RechteVorhanden('rechnung', 'edit'))
|
||||||
{
|
{
|
||||||
$drucker = $this->app->Secure->GetPOST('seldrucker');
|
$drucker = $this->app->Secure->GetPOST('seldrucker');
|
||||||
@ -2734,7 +2744,7 @@ class Rechnung extends GenRechnung
|
|||||||
{
|
{
|
||||||
$id = $this->app->Secure->GetGET('id');
|
$id = $this->app->Secure->GetGET('id');
|
||||||
|
|
||||||
$zahlungen = $this->app->erp->GetZahlungen($id,'rechnung');
|
$zahlungen = $this->app->erp->GetZahlungen($id,'rechnung',true);
|
||||||
|
|
||||||
// print_r($zahlungen);
|
// print_r($zahlungen);
|
||||||
|
|
||||||
@ -2760,86 +2770,35 @@ class Rechnung extends GenRechnung
|
|||||||
".$zahlung['betrag']." ".$zahlung['waehrung']."
|
".$zahlung['betrag']." ".$zahlung['waehrung']."
|
||||||
</a>
|
</a>
|
||||||
</td>
|
</td>
|
||||||
</tr>";
|
</tr>
|
||||||
|
";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$sum = array_sum(array_column($zahlungen,'betrag'))." ".$zahlung['waehrung'];
|
||||||
|
|
||||||
|
if ($sum != 0) {
|
||||||
|
$result .= "
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<b>
|
||||||
|
Summe:
|
||||||
|
</b>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<b>
|
||||||
|
".$sum."
|
||||||
|
</b>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
";
|
||||||
|
}
|
||||||
|
|
||||||
return("<table width=100% border=0 class=auftrag_cell cellpadding=0 cellspacing=0>".$result."</table>");
|
return("<table width=100% border=0 class=auftrag_cell cellpadding=0 cellspacing=0>".$result."</table>");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function RechnungSaldo($id)
|
|
||||||
{
|
|
||||||
if($id <= 0) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
$rechnungid = $this->app->DB->Select(
|
|
||||||
sprintf(
|
|
||||||
'SELECT `id` FROM `rechnung` WHERE `id`= %d LIMIT 1',
|
|
||||||
$id
|
|
||||||
)
|
|
||||||
);
|
|
||||||
$auftragid = $rechnungid <= 0?0:$this->app->DB->Select(
|
|
||||||
sprintf(
|
|
||||||
'SELECT `auftragid` FROM `rechnung` WHERE `id`=%d LIMIT 1',
|
|
||||||
$rechnungid
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
$eingangArr = $this->app->DB->SelectArr(
|
|
||||||
sprintf(
|
|
||||||
"SELECT ko.bezeichnung as konto, DATE_FORMAT(ke.datum,'%%d.%%m.%%Y') as datum, k.id as kontoauszuege, ke.betrag as betrag
|
|
||||||
FROM `kontoauszuege_zahlungseingang` AS `ke`
|
|
||||||
LEFT JOIN `kontoauszuege` AS `k` ON ke.kontoauszuege=k.id
|
|
||||||
LEFT JOIN `konten` AS `ko` ON k.konto=ko.id
|
|
||||||
WHERE (ke.objekt='rechnung' AND ke.parameter=%d)
|
|
||||||
OR (ke.objekt='auftrag' AND ke.parameter=%d AND ke.parameter>0)
|
|
||||||
OR (ke.objekt='rechnung' AND ke.parameter=%d AND ke.parameter>0)",
|
|
||||||
$id, $auftragid, $rechnungid
|
|
||||||
)
|
|
||||||
);
|
|
||||||
$einnahmen = 0;
|
|
||||||
if(!empty($eingangArr)) {
|
|
||||||
foreach($eingangArr AS $eingangRow) {
|
|
||||||
$einnahmen += $eingangRow['betrag'];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//$rechnungen = $this->app->DB->SelectArr("SELECT belegnr, DATE_FORMAT(datum,'%d.%m.%Y') as datum,soll FROM rechnung WHERE rechnungid='$id' "); // alt
|
|
||||||
$rechnungen = $this->app->DB->SelectArr(
|
|
||||||
sprintf(
|
|
||||||
"SELECT ro.belegnr, DATE_FORMAT(ro.datum,'%%d.%%m.%%Y') as datum, ro.soll
|
|
||||||
FROM `rechnung` AS `ro`
|
|
||||||
WHERE ro.`id` = %d ",
|
|
||||||
$id
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
if(!empty($rechnungen)) {
|
|
||||||
foreach($rechnungen as $rechnungRow) {
|
|
||||||
$einnahmen += $rechnungRow['soll'];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$ausgangArr = $this->app->DB->SelectArr(
|
|
||||||
sprintf(
|
|
||||||
"SELECT ko.bezeichnung as konto, DATE_FORMAT(ke.datum,'%%d.%%m') as datum, ke.betrag as betrag
|
|
||||||
FROM kontoauszuege_zahlungsausgang ke
|
|
||||||
LEFT JOIN kontoauszuege k ON ke.kontoauszuege=k.id
|
|
||||||
LEFT JOIN konten ko ON k.konto=ko.id
|
|
||||||
WHERE (ke.objekt='rechnung' AND ke.parameter=%d)
|
|
||||||
OR (ke.objekt='rechnung' AND ke.parameter=%d AND ke.parameter>0)
|
|
||||||
OR (ke.objekt='auftrag' AND ke.parameter=%d AND ke.parameter>0)",
|
|
||||||
$id, $rechnungid, $auftragid
|
|
||||||
)
|
|
||||||
);
|
|
||||||
$ausgaben = 0;
|
|
||||||
if(!empty($ausgangArr)){
|
|
||||||
foreach($ausgangArr as $ausgangRow) {
|
|
||||||
$ausgaben += $ausgangRow['betrg'];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $einnahmen - $ausgaben;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user