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);
- }
- }
-
- if (empty($rundungsdifferenz)) {
- $this->app->Tpl->Set('RUNDUNGSDIFFERENZICONHIDDEN', 'hidden');
- } else {
- $this->app->Tpl->Set('RUNDUNGSDIFFERENZ', $rundungsdifferenz);
- }
-
- if ($pos_ok) {
- if (!$verbindlichkeit_from_db['freigabe'] && !$einkauf_automatik_aus) {
- if ($this->verbindlichkeit_freigabeeinkauf($id,"Verbindlichkeit automatisch freigegeben (Einkauf)") === true) {
- $this->app->YUI->Message('success',"Verbindlichkeit automatisch freigegeben (Einkauf)");
- $verbindlichkeit_from_db['freigabe'] = 1;
- } else {
- $this->app->YUI->Message('warning','Waren-/Leistungsprüfung (Einkauf) nicht abgeschlossen');
- }
- }
- $this->app->Tpl->Set('POSITIONENMESSAGE', 'Positionen vollständig
');
- } else {
- $this->app->Tpl->Set('POSITIONENMESSAGE', '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).'
');
- if ($verbindlichkeit_from_db['freigabe']) {
- $this->app->DB->Update("UPDATE verbindlichkeit SET freigabe = 0 WHERE id = ".$id);
- $verbindlichkeit_from_db['freigabe'] = 0;
- $this->app->YUI->Message('warning',"Verbindlichkeit rückgesetzt (Einkauf)");
- }
- }
+ // Check positions
+ $pos_check = $this->check_positions($verbindlichkeit_from_db['id'],$verbindlichkeit_from_db['betrag']);
+
+ $this->app->Tpl->Set('BETRAGNETTO', $pos_check['betrag_netto']);
+ $this->app->Tpl->Set('BETRAGBRUTTOPOS', $pos_check['betrag_brutto']);
+
+ if (empty($pos_check['rundungsdifferenz'])) {
+ $this->app->Tpl->Set('RUNDUNGSDIFFERENZICONHIDDEN', 'hidden');
+ } else {
+ $this->app->Tpl->Set('RUNDUNGSDIFFERENZ', $pos_check['rundungsdifferenz']);
}
-
+
+ if ($pos_check['pos_ok']) {
+ if (!$verbindlichkeit_from_db['freigabe'] && !$einkauf_automatik_aus) {
+ if ($this->verbindlichkeit_freigabeeinkauf($id,"Verbindlichkeit automatisch freigegeben (Einkauf)") === true) {
+ $this->app->YUI->Message('success',"Verbindlichkeit automatisch freigegeben (Einkauf)");
+ $verbindlichkeit_from_db['freigabe'] = 1;
+ } else {
+ $this->app->YUI->Message('warning','Waren-/Leistungsprüfung (Einkauf) nicht abgeschlossen');
+ }
+ }
+ $this->app->Tpl->Set('POSITIONENMESSAGE', 'Positionen vollständig
');
+
+ if ($verbindlichkeit_from_db['status'] != 'abgeschlossen' && $verbindlichkeit_from_db['status'] != 'storniert') {
+ $this->verbindlichkeit_abschliessen($id);
+ }
+
+ } else {
+ $this->app->Tpl->Set('
+ POSITIONENMESSAGE', 'Positionen nicht vollständig. Bruttobetrag '.
+ $verbindlichkeit_from_db['betrag'].
+ ', Summe Positionen (brutto) '.
+ $pos_check['betrag_brutto'].
+ ', Differenz '.
+ round($pos_check['betrag_brutto']-$verbindlichkeit_from_db['betrag'],2).
+ '
'
+ );
+ if ($verbindlichkeit_from_db['freigabe']) {
+ $this->app->DB->Update("UPDATE verbindlichkeit SET freigabe = 0 WHERE id = ".$id);
+ $verbindlichkeit_from_db['freigabe'] = 0;
+ $this->app->YUI->Message('warning',"Verbindlichkeit rückgesetzt (Einkauf)");
+ }
+ }
+
/*
* Add displayed items later
*
@@ -1209,8 +1197,6 @@ $menu="