mirror of
https://github.com/OpenXE-org/OpenXE.git
synced 2024-12-24 13:40:29 +01:00
rechnung & gutschrift set zahlungsstatus according to saldo
This commit is contained in:
parent
c6a4cf0d23
commit
03f0f7217b
@ -1397,24 +1397,7 @@ class Gutschrift extends GenGutschrift
|
||||
{
|
||||
$this->app->Tpl->Set('UEBERSCHRIFT', 'Gutschriften');
|
||||
|
||||
$this->app->DB->Update("UPDATE gutschrift SET zahlungsstatus='offen' WHERE zahlungsstatus=''");
|
||||
|
||||
// First refresh all open items
|
||||
$openids = $this->app->DB->SelectArr("SELECT id, waehrung from gutschrift WHERE zahlungsstatus != 'bezahlt'");
|
||||
|
||||
foreach ($openids as $openid) {
|
||||
$saldo = $this->app->erp->GetSaldoDokument($openid['id'],'gutschrift');
|
||||
|
||||
if (!empty($saldo)) {
|
||||
if ($saldo['waehrung'] == $openid['waehrung']) {
|
||||
$sql = "UPDATE gutschrift SET ist = soll-'".$saldo['betrag']."' WHERE id=".$openid['id'];
|
||||
$result = $this->app->DB->Update($sql);
|
||||
}
|
||||
}
|
||||
else {
|
||||
$this->app->DB->Update("UPDATE gutschrift SET ist = null WHERE id=".$openid['id']);
|
||||
}
|
||||
}
|
||||
$this->app->DB->Update("UPDATE gutschrift SET zahlungsstatus='offen' WHERE zahlungsstatus=''");
|
||||
|
||||
if($this->app->Secure->GetPOST('ausfuehren') && $this->app->erp->RechteVorhanden('gutschrift', 'edit')) {
|
||||
$drucker = $this->app->Secure->GetPOST('seldrucker');
|
||||
@ -1659,6 +1642,28 @@ class Gutschrift extends GenGutschrift
|
||||
}
|
||||
}
|
||||
|
||||
// refresh all open items
|
||||
$openids = $this->app->DB->SelectArr("SELECT id, waehrung from gutschrift WHERE zahlungsstatus != 'bezahlt'");
|
||||
|
||||
foreach ($openids as $openid) {
|
||||
$saldo = $this->app->erp->GetSaldoDokument($openid['id'],'gutschrift');
|
||||
|
||||
if (!empty($saldo)) {
|
||||
if ($saldo['waehrung'] == $openid['waehrung']) {
|
||||
$sql = "UPDATE
|
||||
gutschrift
|
||||
SET
|
||||
ist = ".$saldo['betrag']."+soll,
|
||||
zahlungsstatus = IF(".$saldo['betrag']." = 0,'bezahlt','offen')
|
||||
WHERE id=".$openid['id'];
|
||||
$this->app->DB->Update($sql);
|
||||
}
|
||||
}
|
||||
else {
|
||||
$this->app->DB->Update("UPDATE gutschrift SET ist = null WHERE id=".$openid['id']);
|
||||
}
|
||||
}
|
||||
|
||||
$backurl = $this->app->Secure->GetGET('backurl');
|
||||
$backurl = $this->app->erp->base64_url_decode($backurl);
|
||||
|
||||
|
@ -2063,24 +2063,7 @@ class Rechnung extends GenRechnung
|
||||
public function RechnungList()
|
||||
{
|
||||
|
||||
$this->app->DB->Update("UPDATE rechnung SET zahlungsstatus='offen' WHERE zahlungsstatus=''");
|
||||
|
||||
// First refresh all open items
|
||||
$openids = $this->app->DB->SelectArr("SELECT id, waehrung from rechnung WHERE zahlungsstatus = 'offen'");
|
||||
|
||||
foreach ($openids as $openid) {
|
||||
$saldo = $this->app->erp->GetSaldoDokument($openid['id'],'rechnung');
|
||||
|
||||
if (!empty($saldo)) {
|
||||
if ($saldo['waehrung'] == $openid['waehrung']) {
|
||||
$sql = "UPDATE rechnung SET ist = ".$saldo['betrag']."+soll WHERE id=".$openid['id'];
|
||||
$this->app->DB->Update($sql);
|
||||
}
|
||||
}
|
||||
else {
|
||||
$this->app->DB->Update("UPDATE rechnung SET ist = null WHERE id=".$openid['id']);
|
||||
}
|
||||
}
|
||||
$this->app->DB->Update("UPDATE rechnung SET zahlungsstatus='offen' WHERE zahlungsstatus=''");
|
||||
|
||||
if($this->app->Secure->GetPOST('ausfuehren') && $this->app->erp->RechteVorhanden('rechnung', 'edit'))
|
||||
{
|
||||
@ -2262,6 +2245,28 @@ class Rechnung extends GenRechnung
|
||||
}
|
||||
}
|
||||
|
||||
// refresh all open items
|
||||
$openids = $this->app->DB->SelectArr("SELECT id, waehrung from rechnung WHERE zahlungsstatus = 'offen'");
|
||||
|
||||
foreach ($openids as $openid) {
|
||||
$saldo = $this->app->erp->GetSaldoDokument($openid['id'],'rechnung');
|
||||
|
||||
if (!empty($saldo)) {
|
||||
if ($saldo['waehrung'] == $openid['waehrung']) {
|
||||
$sql = "UPDATE
|
||||
rechnung
|
||||
SET
|
||||
ist = ".$saldo['betrag']."+soll,
|
||||
zahlungsstatus = IF(".$saldo['betrag']." = 0,'bezahlt','offen')
|
||||
WHERE id=".$openid['id'];
|
||||
$this->app->DB->Update($sql);
|
||||
}
|
||||
}
|
||||
else {
|
||||
$this->app->DB->Update("UPDATE rechnung SET ist = null WHERE id=".$openid['id']);
|
||||
}
|
||||
}
|
||||
|
||||
$this->app->Tpl->Set('UEBERSCHRIFT','Rechnungen');
|
||||
|
||||
$backurl = $this->app->Secure->GetGET('backurl');
|
||||
|
Loading…
Reference in New Issue
Block a user