mirror of
https://github.com/OpenXE-org/OpenXE.git
synced 2024-11-15 04:27:14 +01:00
verbindlichkeitstatus 'abgeschlossen', refresh status from list, auto-set if everything is ok
This commit is contained in:
parent
2cd60b0bd8
commit
500e8b5838
@ -44,6 +44,13 @@
|
|||||||
</label>
|
</label>
|
||||||
<label for="stornierte">{|Inkl. stornierte|}</label>
|
<label for="stornierte">{|Inkl. stornierte|}</label>
|
||||||
</li>
|
</li>
|
||||||
|
<li class="filter-item">
|
||||||
|
<label for="abgeschlossen" class="switch">
|
||||||
|
<input type="checkbox" id="abgeschlossen">
|
||||||
|
<span class="slider round"></span>
|
||||||
|
</label>
|
||||||
|
<label for="abgeschlossen">{|Inkl. abgeschlossene|}</label>
|
||||||
|
</li>
|
||||||
<li class="filter-item">
|
<li class="filter-item">
|
||||||
<label for="zahlbarbis">{|Zahlbar bis|}:</label>
|
<label for="zahlbarbis">{|Zahlbar bis|}:</label>
|
||||||
<input type="text" name="zahlbarbis" id="zahlbarbis" size="10">
|
<input type="text" name="zahlbarbis" id="zahlbarbis" size="10">
|
||||||
@ -53,8 +60,8 @@
|
|||||||
<input type="text" name="skontobis" id="skontobis" size="10">
|
<input type="text" name="skontobis" id="skontobis" size="10">
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
<form method="post" action="#" hidden>
|
<form method="post" action="#">
|
||||||
<input type="submit" class="btnBlue" name="status_berechnen" value="{|Status berechnen|}" />
|
<button name="submit" value="status_berechnen" class="ui-button-icon">{|Status auffrischen|}</button>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -69,7 +76,7 @@
|
|||||||
[MANUELLFREIGABEBUCHHALTUNG]
|
[MANUELLFREIGABEBUCHHALTUNG]
|
||||||
[ALSBEZAHLTMARKIEREN]
|
[ALSBEZAHLTMARKIEREN]
|
||||||
</select>
|
</select>
|
||||||
<input type="submit" class="btnBlue" name="ausfuehren" value="{|ausführen|}" />
|
<button name="submit" value="ausfuehren" class="ui-button-icon">{|Ausführen|}</button>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
</form>
|
</form>
|
||||||
[TAB1NEXT]
|
[TAB1NEXT]
|
||||||
|
@ -123,6 +123,7 @@ class Verbindlichkeit {
|
|||||||
$this->app->Tpl->Add('JQUERYREADY', "$('#rechnungsfreigabe').click( function() { fnFilterColumn3( 0 ); } );");
|
$this->app->Tpl->Add('JQUERYREADY', "$('#rechnungsfreigabe').click( function() { fnFilterColumn3( 0 ); } );");
|
||||||
$this->app->Tpl->Add('JQUERYREADY', "$('#nichtbezahlt').click( function() { fnFilterColumn4( 0 ); } );");
|
$this->app->Tpl->Add('JQUERYREADY', "$('#nichtbezahlt').click( function() { fnFilterColumn4( 0 ); } );");
|
||||||
$this->app->Tpl->Add('JQUERYREADY', "$('#stornierte').click( function() { fnFilterColumn5( 0 ); } );");
|
$this->app->Tpl->Add('JQUERYREADY', "$('#stornierte').click( function() { fnFilterColumn5( 0 ); } );");
|
||||||
|
$this->app->Tpl->Add('JQUERYREADY', "$('#abgeschlossen').click( function() { fnFilterColumn6( 0 ); } );");
|
||||||
|
|
||||||
for ($r = 1;$r <= 8;$r++) {
|
for ($r = 1;$r <= 8;$r++) {
|
||||||
$this->app->Tpl->Add('JAVASCRIPT', '
|
$this->app->Tpl->Add('JAVASCRIPT', '
|
||||||
@ -175,21 +176,28 @@ class Verbindlichkeit {
|
|||||||
else {
|
else {
|
||||||
$where .= " AND v.status <> 'storniert'";
|
$where .= " AND v.status <> 'storniert'";
|
||||||
}
|
}
|
||||||
// END Toggle filters
|
|
||||||
|
$more_data6 = $this->app->Secure->GetGET("more_data6");
|
||||||
|
if ($more_data6 == 1) {
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$where .= " AND v.status <> 'abgeschlossen'";
|
||||||
|
}
|
||||||
|
|
||||||
$this->app->YUI->DatePicker('zahlbarbis');
|
$this->app->YUI->DatePicker('zahlbarbis');
|
||||||
$filterzahlbarbis = $this->app->YUI->TableSearchFilter($name, 6,'zahlbarbis');
|
$filterzahlbarbis = $this->app->YUI->TableSearchFilter($name, 7,'zahlbarbis');
|
||||||
if (!empty($filterzahlbarbis)) {
|
if (!empty($filterzahlbarbis)) {
|
||||||
$filterzahlbarbis = $this->app->String->Convert($filterzahlbarbis,'%1.%2.%3','%3-%2-%1');
|
$filterzahlbarbis = $this->app->String->Convert($filterzahlbarbis,'%1.%2.%3','%3-%2-%1');
|
||||||
$where .= " AND v.zahlbarbis <= '".$filterzahlbarbis."'";
|
$where .= " AND v.zahlbarbis <= '".$filterzahlbarbis."'";
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->app->YUI->DatePicker('skontobis');
|
$this->app->YUI->DatePicker('skontobis');
|
||||||
$filterskontobis = $this->app->YUI->TableSearchFilter($name, 7,'skontobis');
|
$filterskontobis = $this->app->YUI->TableSearchFilter($name, 8,'skontobis');
|
||||||
if (!empty($filterskontobis)) {
|
if (!empty($filterskontobis)) {
|
||||||
$filterskontobis = $this->app->String->Convert($filterskontobis,'%1.%2.%3','%3-%2-%1');
|
$filterskontobis = $this->app->String->Convert($filterskontobis,'%1.%2.%3','%3-%2-%1');
|
||||||
$where .= " AND v.skontobis <= '".$filterskontobis."'";
|
$where .= " AND v.skontobis <= '".$filterskontobis."'";
|
||||||
}
|
}
|
||||||
|
// END Toggle filters
|
||||||
|
|
||||||
$moreinfo = true; // Allow drop down details
|
$moreinfo = true; // Allow drop down details
|
||||||
$menucol = 1; // For moredata
|
$menucol = 1; // For moredata
|
||||||
@ -444,47 +452,59 @@ $menu="<table cellpadding=0 cellspacing=0><tr><td nowrap>"."<a href=\"index.php?
|
|||||||
function verbindlichkeit_list() {
|
function verbindlichkeit_list() {
|
||||||
|
|
||||||
// Process multi action
|
// Process multi action
|
||||||
$submit = $this->app->Secure->GetPOST('ausfuehren');
|
$submit = $this->app->Secure->GetPOST('submit');
|
||||||
if (!empty($submit)) {
|
switch($submit) {
|
||||||
$auswahl = $this->app->Secure->GetPOST('auswahl');
|
case 'status_berechnen':
|
||||||
$aktion = $this->app->Secure->GetPOST('sel_aktion');
|
|
||||||
|
|
||||||
$selectedIds = [];
|
$sql = "SELECT id FROM verbindlichkeit WHERE status <> 'abgeschlossen' AND status <> 'storniert'";
|
||||||
if(!empty($auswahl)) {
|
$ids = $this->app->DB->SelectArr($sql);
|
||||||
foreach($auswahl as $selectedId) {
|
|
||||||
$selectedId = (int)$selectedId;
|
foreach ($ids as $verbindlichkeit) {
|
||||||
if($selectedId > 0) {
|
$this->verbindlichkeit_abschliessen($verbindlichkeit['id']);
|
||||||
$selectedIds[] = $selectedId;
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
case 'ausfuehren':
|
||||||
|
$auswahl = $this->app->Secure->GetPOST('auswahl');
|
||||||
|
$aktion = $this->app->Secure->GetPOST('sel_aktion');
|
||||||
|
|
||||||
|
$selectedIds = [];
|
||||||
|
if(!empty($auswahl)) {
|
||||||
|
foreach($auswahl as $selectedId) {
|
||||||
|
$selectedId = (int)$selectedId;
|
||||||
|
if($selectedId > 0) {
|
||||||
|
$selectedIds[] = $selectedId;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
switch ($aktion) {
|
||||||
|
case 'freigabeeinkauf':
|
||||||
|
foreach ($selectedIds as $id) {
|
||||||
|
$result = $this->verbindlichkeit_freigabeeinkauf($id);
|
||||||
|
if ($result !== true) {
|
||||||
|
$this->app->YUI->Message('warning',$result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'freigabebuchhaltung':
|
||||||
|
foreach ($selectedIds as $id) {
|
||||||
|
$result = $this->verbindlichkeit_freigabebuchhaltung($id);
|
||||||
|
if ($result !== true) {
|
||||||
|
$this->app->YUI->Message('warning',$result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'bezahlt':
|
||||||
|
foreach ($selectedIds as $id) {
|
||||||
|
$result = $this->verbindlichkeit_freigabebezahlt($id);
|
||||||
|
if ($result !== true) {
|
||||||
|
$this->app->YUI->Message('warning',$result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
switch ($aktion) {
|
|
||||||
case 'freigabeeinkauf':
|
|
||||||
foreach ($selectedIds as $id) {
|
|
||||||
$result = $this->verbindlichkeit_freigabeeinkauf($id);
|
|
||||||
if ($result !== true) {
|
|
||||||
$this->app->YUI->Message('warning',$result);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 'freigabebuchhaltung':
|
|
||||||
foreach ($selectedIds as $id) {
|
|
||||||
$result = $this->verbindlichkeit_freigabebuchhaltung($id);
|
|
||||||
if ($result !== true) {
|
|
||||||
$this->app->YUI->Message('warning',$result);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 'bezahlt':
|
|
||||||
foreach ($selectedIds as $id) {
|
|
||||||
$result = $this->verbindlichkeit_freigabebezahlt($id);
|
|
||||||
if ($result !== true) {
|
|
||||||
$this->app->YUI->Message('warning',$result);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->app->erp->MenuEintrag("index.php?module=verbindlichkeit&action=list", "Übersicht");
|
$this->app->erp->MenuEintrag("index.php?module=verbindlichkeit&action=list", "Übersicht");
|
||||||
@ -864,79 +884,47 @@ $menu="<table cellpadding=0 cellspacing=0><tr><td nowrap>"."<a href=\"index.php?
|
|||||||
$verbindlichkeit_from_db = $result[0];
|
$verbindlichkeit_from_db = $result[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Summarize positions
|
// Check positions
|
||||||
$sql = "SELECT * FROM verbindlichkeit_position WHERE verbindlichkeit = ".$id;
|
$pos_check = $this->check_positions($verbindlichkeit_from_db['id'],$verbindlichkeit_from_db['betrag']);
|
||||||
$positionen = $this->app->DB->SelectArr($sql);
|
|
||||||
|
|
||||||
if (!empty($positionen)) {
|
$this->app->Tpl->Set('BETRAGNETTO', $pos_check['betrag_netto']);
|
||||||
$betrag_netto = 0;
|
$this->app->Tpl->Set('BETRAGBRUTTOPOS', $pos_check['betrag_brutto']);
|
||||||
$betrag_brutto = 0;
|
|
||||||
$betrag_brutto_pos_summe = 0;
|
|
||||||
$steuer_normal = 0;
|
|
||||||
$steuer_ermaessigt = 0;
|
|
||||||
|
|
||||||
/*
|
if (empty($pos_check['rundungsdifferenz'])) {
|
||||||
Normal: umsatzsteuer leer, steuersatz = leer
|
$this->app->Tpl->Set('RUNDUNGSDIFFERENZICONHIDDEN', 'hidden');
|
||||||
Ermäßigt: umsatzsteuer ermaessigt, steuersatz = -1
|
} else {
|
||||||
Befreit: umsatzsteuer befreit, steursatz = -1
|
$this->app->Tpl->Set('RUNDUNGSDIFFERENZ', $pos_check['rundungsdifferenz']);
|
||||||
Individuell: umsatzsteuer leer, steuersatz = wert
|
}
|
||||||
*/
|
|
||||||
foreach ($positionen as $position) {
|
|
||||||
|
|
||||||
$tmpsteuersatz = null;
|
if ($pos_check['pos_ok']) {
|
||||||
$tmpsteuertext = null;
|
if (!$verbindlichkeit_from_db['freigabe'] && !$einkauf_automatik_aus) {
|
||||||
$erloes = null;
|
if ($this->verbindlichkeit_freigabeeinkauf($id,"Verbindlichkeit automatisch freigegeben (Einkauf)") === true) {
|
||||||
|
$this->app->YUI->Message('success',"Verbindlichkeit automatisch freigegeben (Einkauf)");
|
||||||
// function GetSteuerPosition($typ, $posid,&$tmpsteuersatz = null, &$tmpsteuertext = null, &$erloes = null)
|
$verbindlichkeit_from_db['freigabe'] = 1;
|
||||||
|
} else {
|
||||||
$this->app->erp->GetSteuerPosition("verbindlichkeit",$position['id'],$tmpsteuersatz,$tmpsteuertext,$erloes);
|
$this->app->YUI->Message('warning','Waren-/Leistungsprüfung (Einkauf) nicht abgeschlossen');
|
||||||
|
|
||||||
$position['steuersatz_berechnet'] = $tmpsteuersatz;
|
|
||||||
$position['steuertext_berechnet'] = $tmpsteuertext;
|
|
||||||
$position['steuererloes_berechnet'] = $erloes;
|
|
||||||
|
|
||||||
$betrag_netto += ($position['menge']*$position['preis']);
|
|
||||||
$betrag_brutto += ($position['menge']*$position['preis'])*(1+($tmpsteuersatz/100));
|
|
||||||
$betrag_brutto_pos_summe += round(($position['menge']*$position['preis'])*(1+($tmpsteuersatz/100)),2);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->app->Tpl->Set('BETRAGNETTO', round($betrag_netto,2));
|
|
||||||
$this->app->Tpl->Set('BETRAGBRUTTOPOS', round($betrag_brutto,2));
|
|
||||||
|
|
||||||
if ($verbindlichkeit_from_db['betrag'] == round($betrag_brutto,2)) {
|
|
||||||
$pos_ok = true;
|
|
||||||
}
|
|
||||||
else if (round($verbindlichkeit_from_db['betrag'],2) == round($betrag_brutto_pos_summe,2)) {
|
|
||||||
$pos_ok = true;
|
|
||||||
if (round($betrag_brutto,2) != round($betrag_brutto_pos_summe,2)) {
|
|
||||||
$rundungsdifferenz = round(round($betrag_brutto,2) - $betrag_brutto_pos_summe,2);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
$this->app->Tpl->Set('POSITIONENMESSAGE', '<div class="success">Positionen vollständig</div>');
|
||||||
|
|
||||||
if (empty($rundungsdifferenz)) {
|
if ($verbindlichkeit_from_db['status'] != 'abgeschlossen' && $verbindlichkeit_from_db['status'] != 'storniert') {
|
||||||
$this->app->Tpl->Set('RUNDUNGSDIFFERENZICONHIDDEN', 'hidden');
|
$this->verbindlichkeit_abschliessen($id);
|
||||||
} else {
|
|
||||||
$this->app->Tpl->Set('RUNDUNGSDIFFERENZ', $rundungsdifferenz);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($pos_ok) {
|
} else {
|
||||||
if (!$verbindlichkeit_from_db['freigabe'] && !$einkauf_automatik_aus) {
|
$this->app->Tpl->Set('
|
||||||
if ($this->verbindlichkeit_freigabeeinkauf($id,"Verbindlichkeit automatisch freigegeben (Einkauf)") === true) {
|
POSITIONENMESSAGE', '<div class="warning">Positionen nicht vollständig. Bruttobetrag '.
|
||||||
$this->app->YUI->Message('success',"Verbindlichkeit automatisch freigegeben (Einkauf)");
|
$verbindlichkeit_from_db['betrag'].
|
||||||
$verbindlichkeit_from_db['freigabe'] = 1;
|
', Summe Positionen (brutto) '.
|
||||||
} else {
|
$pos_check['betrag_brutto'].
|
||||||
$this->app->YUI->Message('warning','Waren-/Leistungsprüfung (Einkauf) nicht abgeschlossen');
|
', Differenz '.
|
||||||
}
|
round($pos_check['betrag_brutto']-$verbindlichkeit_from_db['betrag'],2).
|
||||||
}
|
'</div>'
|
||||||
$this->app->Tpl->Set('POSITIONENMESSAGE', '<div class="success">Positionen vollständig</div>');
|
);
|
||||||
} else {
|
if ($verbindlichkeit_from_db['freigabe']) {
|
||||||
$this->app->Tpl->Set('POSITIONENMESSAGE', '<div class="warning">Positionen nicht vollständig. Bruttobetrag '.$verbindlichkeit_from_db['betrag'].', Summe Positionen (brutto) '.round($betrag_brutto,2).', Differenz '.round(round($betrag_brutto,2)-$verbindlichkeit_from_db['betrag'],2).'</div>');
|
$this->app->DB->Update("UPDATE verbindlichkeit SET freigabe = 0 WHERE id = ".$id);
|
||||||
if ($verbindlichkeit_from_db['freigabe']) {
|
$verbindlichkeit_from_db['freigabe'] = 0;
|
||||||
$this->app->DB->Update("UPDATE verbindlichkeit SET freigabe = 0 WHERE id = ".$id);
|
$this->app->YUI->Message('warning',"Verbindlichkeit rückgesetzt (Einkauf)");
|
||||||
$verbindlichkeit_from_db['freigabe'] = 0;
|
|
||||||
$this->app->YUI->Message('warning',"Verbindlichkeit rückgesetzt (Einkauf)");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1209,8 +1197,6 @@ $menu="<table cellpadding=0 cellspacing=0><tr><td nowrap>"."<a href=\"index.php?
|
|||||||
|
|
||||||
if (!empty($file_attachments)) {
|
if (!empty($file_attachments)) {
|
||||||
|
|
||||||
// print_r($file_attachments);
|
|
||||||
|
|
||||||
// Try to merge all PDFs
|
// Try to merge all PDFs
|
||||||
$file_paths = array();
|
$file_paths = array();
|
||||||
foreach ($file_attachments as $file_attachment) {
|
foreach ($file_attachments as $file_attachment) {
|
||||||
@ -1247,7 +1233,6 @@ $menu="<table cellpadding=0 cellspacing=0><tr><td nowrap>"."<a href=\"index.php?
|
|||||||
$id = $this->app->Secure->GetGET('id');
|
$id = $this->app->Secure->GetGET('id');
|
||||||
$this->app->erp->BelegFreigabe('verbindlichkeit',$id);
|
$this->app->erp->BelegFreigabe('verbindlichkeit',$id);
|
||||||
$this->app->erp->BelegProtokoll("verbindlichkeit",$id,"Verbindlichkeit freigegeben");
|
$this->app->erp->BelegProtokoll("verbindlichkeit",$id,"Verbindlichkeit freigegeben");
|
||||||
// $this->app->DB->Update("UPDATE verbindlichkeit SET schreibschutz = 1 WHERE id = ".$id);
|
|
||||||
$this->verbindlichkeit_edit();
|
$this->verbindlichkeit_edit();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1307,6 +1292,7 @@ $menu="<table cellpadding=0 cellspacing=0><tr><td nowrap>"."<a href=\"index.php?
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Returns true or error message
|
||||||
function verbindlichkeit_freigabebuchhaltung($id = null)
|
function verbindlichkeit_freigabebuchhaltung($id = null)
|
||||||
{
|
{
|
||||||
if (empty($id)) {
|
if (empty($id)) {
|
||||||
@ -1363,6 +1349,7 @@ $menu="<table cellpadding=0 cellspacing=0><tr><td nowrap>"."<a href=\"index.php?
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Returns true or error message
|
||||||
function verbindlichkeit_freigabebezahlt($id = null)
|
function verbindlichkeit_freigabebezahlt($id = null)
|
||||||
{
|
{
|
||||||
if (empty($id)) {
|
if (empty($id)) {
|
||||||
@ -1391,7 +1378,36 @@ $menu="<table cellpadding=0 cellspacing=0><tr><td nowrap>"."<a href=\"index.php?
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function verbindlichkeit_ruecksetzeneinkauf($id = null)
|
function verbindlichkeit_abschliessen($id = null)
|
||||||
|
{
|
||||||
|
if (empty($id)) {
|
||||||
|
$id = $this->app->Secure->GetGET('id');
|
||||||
|
$gotoedit = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
$sql = "SELECT freigabe, rechnungsfreigabe, bezahlt, betrag FROM verbindlichkeit WHERE id =".$id;
|
||||||
|
$verbindlichkeit = $this->app->DB->SelectRow($sql);
|
||||||
|
|
||||||
|
if ($verbindlichkeit['freigabe'] != 1) {
|
||||||
|
$einkauf_check = $this->check_positions($id,$verbindlichkeit['betrag']);
|
||||||
|
if ($einkauf_check['pos_ok']) {
|
||||||
|
$this->verbindlichkeit_freigabeeinkauf($id);
|
||||||
|
$verbindlichkeit['freigabe'] = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$anzahldateien = $this->app->erp->AnzahlDateien("verbindlichkeit",$id);
|
||||||
|
if (!empty($anzahldateien) && $verbindlichkeit['freigabe'] && $verbindlichkeit['rechnungsfreigabe'] && $verbindlichkeit['bezahlt']) {
|
||||||
|
$sql = "UPDATE verbindlichkeit SET status = 'abgeschlossen' WHERE id=".$id;
|
||||||
|
$this->app->DB->Update($sql);
|
||||||
|
$this->app->erp->BelegProtokoll("verbindlichkeit",$id,"Verbindlichkeit abgeschlossen");
|
||||||
|
if ($gotoedit) {
|
||||||
|
$this->verbindlichkeit_edit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function verbindlichkeit_ruecksetzeneinkauf($id = null)
|
||||||
{
|
{
|
||||||
if (empty($id)) {
|
if (empty($id)) {
|
||||||
$id = $this->app->Secure->GetGET('id');
|
$id = $this->app->Secure->GetGET('id');
|
||||||
@ -1678,4 +1694,70 @@ $menu="<table cellpadding=0 cellspacing=0><tr><td nowrap>"."<a href=\"index.php?
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check positions and return status and values
|
||||||
|
function check_positions($id, $bruttobetrag_verbindlichkeit) : array {
|
||||||
|
|
||||||
|
$result = array(
|
||||||
|
"pos_ok" => false,
|
||||||
|
"betrag_netto" => 0,
|
||||||
|
"betrag_brutto" => 0,
|
||||||
|
"rundungsdifferenz" => 0,
|
||||||
|
"bruttobetrag_verbindlichkeit" => $bruttobetrag_verbindlichkeit
|
||||||
|
);
|
||||||
|
|
||||||
|
if (empty($id)) {
|
||||||
|
return($result);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Summarize positions
|
||||||
|
$sql = "SELECT * FROM verbindlichkeit_position WHERE verbindlichkeit = ".$id;
|
||||||
|
$positionen = $this->app->DB->SelectArr($sql);
|
||||||
|
|
||||||
|
if (!empty($positionen)) {
|
||||||
|
$betrag_netto = 0;
|
||||||
|
$betrag_brutto = 0;
|
||||||
|
$betrag_brutto_pos_summe = 0;
|
||||||
|
$steuer_normal = 0;
|
||||||
|
$steuer_ermaessigt = 0;
|
||||||
|
|
||||||
|
/*
|
||||||
|
Normal: umsatzsteuer leer, steuersatz = leer
|
||||||
|
Ermäßigt: umsatzsteuer ermaessigt, steuersatz = -1
|
||||||
|
Befreit: umsatzsteuer befreit, steursatz = -1
|
||||||
|
Individuell: umsatzsteuer leer, steuersatz = wert
|
||||||
|
*/
|
||||||
|
foreach ($positionen as $position) {
|
||||||
|
|
||||||
|
$tmpsteuersatz = null;
|
||||||
|
$tmpsteuertext = null;
|
||||||
|
$erloes = null;
|
||||||
|
|
||||||
|
$this->app->erp->GetSteuerPosition("verbindlichkeit",$position['id'],$tmpsteuersatz,$tmpsteuertext,$erloes);
|
||||||
|
|
||||||
|
$position['steuersatz_berechnet'] = $tmpsteuersatz;
|
||||||
|
$position['steuertext_berechnet'] = $tmpsteuertext;
|
||||||
|
$position['steuererloes_berechnet'] = $erloes;
|
||||||
|
|
||||||
|
$betrag_netto += ($position['menge']*$position['preis']);
|
||||||
|
$betrag_brutto += ($position['menge']*$position['preis'])*(1+($tmpsteuersatz/100));
|
||||||
|
$betrag_brutto_pos_summe += round(($position['menge']*$position['preis'])*(1+($tmpsteuersatz/100)),2);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
$result['betrag_netto'] = round($betrag_netto,2);
|
||||||
|
$result['betrag_brutto'] = round($betrag_brutto,2);
|
||||||
|
|
||||||
|
if ($bruttobetrag_verbindlichkeit == round($betrag_brutto,2)) {
|
||||||
|
$result['pos_ok'] = true;
|
||||||
|
}
|
||||||
|
else if (round($bruttobetrag_verbindlichkeit,2) == round($betrag_brutto_pos_summe,2)) {
|
||||||
|
$result['pos_ok'] = true;
|
||||||
|
if (round($bruttobetrag_verbindlichkeit,2) != round($betrag_brutto_pos_summe,2)) {
|
||||||
|
$result['rundungsdifferenz'] = round(round($betrag_brutto,2) - $betrag_brutto_pos_summe,2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return($result);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user