mirror of
https://github.com/OpenXE-org/OpenXE.git
synced 2024-11-14 20:17:14 +01:00
fibu_buchhaltung belege zuordnen multi option
This commit is contained in:
parent
667b70eaf5
commit
69172672b2
@ -35973,7 +35973,7 @@ function Firmendaten($field,$projekt="")
|
||||
* Auftrag: gesamtsumme, rechnung: soll, gutschrift: soll verbindlichkeit: betrag
|
||||
* returns array(array(betrag, waehrung)) one line per waehrung
|
||||
*/
|
||||
public function GetSaldenDokument($id, $type, string $cascadelevel = '') : array {
|
||||
public function GetSaldenDokument(int $id, string $type, string $cascadelevel = '') : array {
|
||||
|
||||
if ($cascadelevel != '') {
|
||||
$documents = $this->GetZahlungenAssociatedDocuments($id, $type, $cascadelevel);
|
||||
@ -36014,9 +36014,9 @@ function Firmendaten($field,$projekt="")
|
||||
/*
|
||||
* Calculate the payment amount of a document
|
||||
* Auftrag: gesamtsumme, rechnung: soll, gutschrift: soll verbindlichkeit: betrag
|
||||
* returns array(array(betrag, waehrung)) or empty array
|
||||
* returns array(betrag, waehrung) or empty array if multiple
|
||||
*/
|
||||
public function GetSaldoDokument($id, $type) : array {
|
||||
public function GetSaldoDokument(int $id, string $type) : array {
|
||||
|
||||
$sql = "
|
||||
SELECT
|
||||
|
@ -40,7 +40,16 @@
|
||||
<table>
|
||||
<legend>Stapelverarbeitung</legend>
|
||||
<tr>
|
||||
<td><input type="checkbox" value="1" id="autoalle" /> alle markieren </td>
|
||||
<td><input type="checkbox" value="1" id="autoalle" /> alle markieren
|
||||
<select form="buchungenform" id="sel_aktion" name="sel_aktion">
|
||||
<option value="">{|bitte wählen|} ...</option>
|
||||
<option value="vorschlag">{|auf Vorschläge buchen|}</option>
|
||||
<option value="sachkonto">{|auf Sachkonto buchen|}</option>
|
||||
<option value="vorschlag_diff_sachkonto">{|auf Vorschläge buchen, Differenz auf Sachkonto|}</option>
|
||||
</select>
|
||||
<input type="text" form="buchungenform" id="sachkonto" name="sachkonto" value="">
|
||||
<button name="submit" form="buchungenform" value="BUCHEN" class="ui-button-icon">{|BUCHEN|}</button>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<form action="" method="post">
|
||||
@ -50,17 +59,7 @@
|
||||
</button>
|
||||
</td>
|
||||
</form>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<input type="text" form="buchungenform" id="sachkonto" name="sachkonto" value="">
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<button name="submit" form="buchungenform" value="BUCHEN" class="ui-button-icon" style="width:100%;">{|Markierte BUCHEN|}</button>
|
||||
</td>
|
||||
</tr>
|
||||
</tr>
|
||||
</table>
|
||||
</fieldset>
|
||||
</div>
|
||||
|
@ -766,7 +766,7 @@ class Fibu_buchungen {
|
||||
}
|
||||
|
||||
if ($submit == 'BUCHEN') {
|
||||
|
||||
|
||||
// Process multi action
|
||||
$ids = $this->app->Secure->GetPOST('ids');
|
||||
$werte = $this->app->Secure->GetPOST('werte');
|
||||
@ -774,11 +774,12 @@ class Fibu_buchungen {
|
||||
$auswahl = $this->app->Secure->GetPOST('auswahl');
|
||||
$vorschlaege = $this->app->Secure->GetPOST('vorschlaege');
|
||||
$sachkonto = $this->app->Secure->GetPOST('sachkonto');
|
||||
$aktion = $this->app->Secure->GetPOST('sel_aktion');
|
||||
|
||||
$sachkontoid = null;
|
||||
$account_id = null;
|
||||
if (!empty($sachkonto)) {
|
||||
$sachkonto_kennung = explode(' ',$sachkonto)[0];
|
||||
$sachkontoid = $this->app->DB->SelectArr("SELECT id from kontorahmen WHERE sachkonto = '".$sachkonto_kennung."'")[0]['id'];
|
||||
$account_id = $this->app->DB->SelectArr("SELECT id from kontorahmen WHERE sachkonto = '".$sachkonto_kennung."'")[0]['id'];
|
||||
}
|
||||
|
||||
if (!empty($auswahl)) {
|
||||
@ -794,28 +795,51 @@ class Fibu_buchungen {
|
||||
$von_id = (int) $von[1];
|
||||
|
||||
$betrag = $werte[$key_ids];
|
||||
|
||||
$waehrung = $waehrungen[$key_ids];
|
||||
|
||||
$doc_id = null;
|
||||
$datum = $this->app->DB->SelectArr("SELECT datum FROM fibu_buchungen_alle WHERE typ='".$von_typ."' AND id = '".$von_id."'")[0]['datum']; // Get relevant date of source doc
|
||||
|
||||
if ($sachkontoid) {
|
||||
$doc_typ = 'kontorahmen';
|
||||
$doc_id = $sachkontoid;
|
||||
} else if ($vorschlaege[$key_ids] != '_') {
|
||||
$doc_id = null;
|
||||
if ($vorschlaege[$key_ids] != '_') {
|
||||
$doc = $vorschlaege[$key_ids];
|
||||
$doc = explode('_',$doc);
|
||||
$doc_typ = strtolower($doc[0]);
|
||||
$doc_id = (int) $doc[1];
|
||||
}
|
||||
|
||||
switch ($aktion) {
|
||||
case 'vorschlag':
|
||||
if ($doc_id) {
|
||||
$sql = "INSERT INTO `fibu_buchungen` (`von_typ`, `von_id`, `nach_typ`, `nach_id`, `datum`, `betrag`, `waehrung`, `benutzer`, `zeit`, `internebemerkung`) VALUES ('".$von_typ."','".$von_id."','".$doc_typ."', '".$doc_id."', '".$datum."', '".-$betrag."', '".$waehrung."', '".$this->app->User->GetID()."','".$input['zeit'] = date("Y-m-d H:i")."', '')";
|
||||
// echo($sql."\n");
|
||||
$this->app->DB->Insert($sql);
|
||||
}
|
||||
break;
|
||||
case 'sachkonto':
|
||||
$sql = "INSERT INTO `fibu_buchungen` (`von_typ`, `von_id`, `nach_typ`, `nach_id`, `datum`, `betrag`, `waehrung`, `benutzer`, `zeit`, `internebemerkung`) VALUES ('".$von_typ."','".$von_id."','kontorahmen', '".$account_id."', '".$datum."', '".-$betrag."', '".$waehrung."', '".$this->app->User->GetID()."','".$input['zeit'] = date("Y-m-d H:i")."', '')";
|
||||
// echo($sql."\n");
|
||||
$this->app->DB->Insert($sql);
|
||||
break;
|
||||
case 'vorschlag_diff_sachkonto':
|
||||
if ($doc_id) {
|
||||
$doc_saldo = $this->app->erp->GetSaldoDokument($doc_id, $doc_typ);
|
||||
$sql = "INSERT INTO `fibu_buchungen` (`von_typ`, `von_id`, `nach_typ`, `nach_id`, `datum`, `betrag`, `waehrung`, `benutzer`, `zeit`, `internebemerkung`) VALUES ('".$von_typ."','".$von_id."','".$doc_typ."', '".$doc_id."', '".$datum."', '".-$betrag."', '".$waehrung."', '".$this->app->User->GetID()."','".$input['zeit'] = date("Y-m-d H:i")."', '')";
|
||||
// echo($sql."\n");
|
||||
$this->app->DB->Insert($sql);
|
||||
}
|
||||
|
||||
$datum = $this->app->DB->SelectArr("SELECT datum FROM fibu_buchungen_alle WHERE typ='".$von_typ."' AND id = '".$von_id."'")[0]['datum']; // Get relevant date of source doc
|
||||
|
||||
if ($doc_id) {
|
||||
$sql = "INSERT INTO `fibu_buchungen` (`von_typ`, `von_id`, `nach_typ`, `nach_id`, `datum`, `betrag`, `waehrung`, `benutzer`, `zeit`, `internebemerkung`) VALUES ('".$von_typ."','".$von_id."','".$doc_typ."', '".$doc_id."', '".$datum."', '".-$betrag."', '".$waehrung."', '".$this->app->User->GetID()."','".$input['zeit'] = date("Y-m-d H:i")."', '')";
|
||||
$this->app->DB->Insert($sql);
|
||||
// echo($sql."\n");
|
||||
}
|
||||
// Retrieve counter doc saldo
|
||||
if (!empty($doc_saldo) && ($doc_saldo['waehrung'] == $waehrung) && ($account_id !== null)) {
|
||||
$diff = $betrag+$doc_saldo['betrag'];
|
||||
$sql = "INSERT INTO `fibu_buchungen` (`von_typ`, `von_id`, `nach_typ`, `nach_id`, `datum`, `betrag`, `waehrung`, `benutzer`, `zeit`, `internebemerkung`) VALUES ('".$doc_typ."','".$doc_id."','kontorahmen', '".$account_id."', '".$datum."', '".-$diff."', '".$waehrung."', '".$this->app->User->GetID()."','".$input['zeit'] = date("Y-m-d H:i")."', '')";
|
||||
// echo($sql."\n");
|
||||
$this->app->DB->Insert($sql);
|
||||
} else {
|
||||
$msg .= "<div class=\"warning\">Gegensaldo wurde nicht gebucht. ".count($doc_saldo)." ".$doc_saldo[0]['waehrung']."</div>";
|
||||
}
|
||||
break;
|
||||
}
|
||||
} // auswahl
|
||||
} // foreach
|
||||
} // auswahl
|
||||
|
Loading…
Reference in New Issue
Block a user