Compare commits

...

2 Commits

Author SHA1 Message Date
OpenXE
cbd44d167a rework paketmarke contact fields 2024-07-13 15:19:54 +02:00
OpenXE
78dff8b5c1 Buchhaltung export UTF-8, UTF-8-BOM 2024-07-11 17:16:22 +02:00
6 changed files with 124 additions and 30 deletions

View File

@ -68,6 +68,9 @@ abstract class Versanddienstleister
$auftragId = $this->app->DB->Select("SELECT auftragid FROM rechnung WHERE id=$rechnungId LIMIT 1");
if ($sid === 'rechnung' || $sid === 'lieferschein' || $sid === 'adresse') {
$ret['addresstype'] = 0; // 0 = firma, 1 = packstation, 2 = postfiliale, 3 = privatadresse
$docArr = $this->app->DB->SelectRow("SELECT * FROM `$sid` WHERE id = $id LIMIT 1");
$ret['addressId'] = $docArr['adresse'];
$ret['auftragId'] = $auftragId;
@ -79,12 +82,28 @@ abstract class Versanddienstleister
$ret['original'] = array_filter($docArr, fn($key) => in_array($key, $addressfields), ARRAY_FILTER_USE_KEY);
$ret['name'] = empty(trim($docArr['ansprechpartner'])) ? trim($docArr['name']) : trim($docArr['ansprechpartner']);
$ret['name2'] = !empty(trim($docArr['ansprechpartner'])) ? trim($docArr['name']) : '';
$ret['name3'] = join(';', array_filter([
$docArr['abteilung'],
$docArr['unterabteilung']
], fn(string $item) => !empty(trim($item))));
if ($docArr['typ'] == "firma") {
$ret['company_name'] = $docArr['name'];
$ret['addresstype'] = 0;
} else {
$ret['addresstype'] = 3;
}
$ret['contact_name'] = $docArr['ansprechpartner'];
$ret['company_division'] = join(
';',
array_filter(
[
$docArr['abteilung'],
$docArr['unterabteilung']
],
fn(string $item) => !empty(trim($item))
)
);
$ret['name'] = $docArr['name'];
$ret['address2'] = $docArr['adresszusatz'];
$ret['city'] = $docArr['ort'];
@ -92,7 +111,6 @@ abstract class Versanddienstleister
$ret['country'] = $docArr['land'];
$ret['phone'] = $docArr['telefon'];
$ret['email'] = $docArr['email'];
$ret['addresstype'] = 0;
$strasse = trim($docArr['strasse']);
$ret['streetwithnumber'] = $strasse;

View File

@ -18,29 +18,34 @@ SPDX-License-Identifier: LicenseRef-EGPL-3.1
<td>{|Adresstyp|}:</td>
<td>
<select v-model.number="form.addresstype">
<option value="0">Haus</option>
<option value="0">Firma</option>
<option value="1">Packstation</option>
<option value="2">Filiale</option>
<option value="3">Privatadresse</option>
</select>
</td>
</tr>
<tr>
<td>{|Name / Zeile 1|}:</td>
<td><input type="text" size="36" v-model.trim="form.name"></td>
<tr v-if="form.addresstype === 0">
<td>{|Firma|}:</td>
<td><input type="text" size="36" v-model.trim="form.company_name"></td>
</tr>
<tr v-if="form.addresstype === 0">
<td>{|Firmenname / Zeile 2|}:</td>
<td><input type="text" size="36" v-model.trim="form.name2"></td>
<td>{|Abteilung|}:</td>
<td><input type="text" size="36" v-model.trim="form.company_division"></td>
</tr>
<tr v-if="form.addresstype === 3">
<td>{|Name|}:</td>
<td><input type="text" size="36" v-model.trim="form.name"></td>
</tr>
<tr v-if="form.addresstype === 0 || form.addresstype === 3">
<td>{|Ansprechpartner|}:</td>
<td><input type="text" size="36" v-model.trim="form.contact_name"></td>
</tr>
<tr v-if="form.addresstype === 1 || form.addresstype === 2">
<td>{|Postnummer|}:</td>
<td><input type="text" size="36" v-model.trim="form.postnumber"></td>
</tr>
<tr v-if="form.addresstype === 0">
<td>{|Firmenname / Zeile 3|}:</td>
<td><input type="text" size="36" v-model.trim="form.name3"></td>
</tr>
<tr v-if="form.addresstype === 0">
<tr v-if="form.addresstype === 0 || form.addresstype === 3">
<td>{|Strasse/Hausnummer|}:</td>
<td>
<input type="text" size="30" v-model.trim="form.street">
@ -55,7 +60,7 @@ SPDX-License-Identifier: LicenseRef-EGPL-3.1
<td>{|Postfilialnummer|}:</td>
<td><input type="text" size="10" v-model.trim="form.postofficeNumber"></td>
</tr>
<tr v-if="form.addresstype === 0">
<tr v-if="form.addresstype === 0 || form.addresstype === 3">
<td>{|Adresszeile 2|}:</td>
<td><input type="text" size="36" v-model.trim="form.address2"></td>
</tr>
@ -77,10 +82,6 @@ SPDX-License-Identifier: LicenseRef-EGPL-3.1
</select>
</td>
</tr>
<tr>
<td>{|Ansprechpartner|}:</td>
<td><input type="text" size="36" v-model="form.contactperson"></td>
</tr>
<tr>
<td>{|E-Mail|}:</td>
<td><input type="text" size="36" v-model.trim="form.email"></td>

View File

@ -102,7 +102,19 @@ class Versandart_dhl extends Versanddienstleister{
switch ($json->addresstype) {
case 0:
$shipment->Receiver->Address = new ReceiverNativeAddress();
$shipment->Receiver->Address->name2 = $json->name2;
$shipment->Receiver->name1 = $json->company_name;
$shipment->Receiver->Address->name2 = join(
';',
array_filter(
[
$json->contact_name,
$json->company_division
],
fn(string $item) => !empty(trim($item))
)
);
$shipment->Receiver->Address->streetName = $json->street ?? '';
$shipment->Receiver->Address->streetNumber = $json->streetnumber;
$shipment->Receiver->Address->city = $json->city ?? '';
@ -127,6 +139,20 @@ class Versandart_dhl extends Versanddienstleister{
$shipment->Receiver->Postfiliale->zip = $json->zip ?? '';
$shipment->Receiver->Postfiliale->Origin = Country::Create($json->country ?? 'DE', $json->state);
break;
case 3:
$shipment->Receiver->Address = new ReceiverNativeAddress();
$shipment->Receiver->name1 = $json->name;
$shipment->Receiver->Address->name2 = $json->contact_name;
$shipment->Receiver->Address->streetName = $json->street ?? '';
$shipment->Receiver->Address->streetNumber = $json->streetnumber;
$shipment->Receiver->Address->city = $json->city ?? '';
$shipment->Receiver->Address->zip = $json->zip ?? '';
$shipment->Receiver->Address->Origin = Country::Create($json->country ?? 'DE', $json->state);
if (isset($json->address2) && !empty($json->address2))
$shipment->Receiver->Address->addressAddition[] = $json->address2;
break;
}
$shipment->Receiver->Communication = new Communication();
$shipment->Receiver->Communication->email = $json->email;

View File

@ -82,8 +82,18 @@ class Versandart_sendcloud extends Versanddienstleister
$parcel->ShippingMethodId = $json->product;
$parcel->Name = $json->name;
switch ($json->addresstype) {
case 0:
$parcel->CompanyName = trim("$json->name2 $json->name3");
case 0:
$parcel->CompanyName = $json->company_name;
$parcel->Name = join(
';',
array_filter(
[
$json->contact_name,
$json->company_division
],
fn(string $item) => !empty(trim($item))
)
);
$parcel->Address = $json->street;
$parcel->Address2 = $json->address2;
$parcel->HouseNumber = $json->streetnumber;
@ -98,6 +108,23 @@ class Versandart_sendcloud extends Versanddienstleister
$parcel->Address = "Postfiliale";
$parcel->HouseNumber = $json->postofficeNumber;
break;
case 3:
$parcel->Name = join(
';',
array_filter(
[
$json->name,
$json->contact_name
],
fn(string $item) => !empty(trim($item))
)
);
$parcel->Address = $json->street;
$parcel->Address2 = $json->address2;
$parcel->HouseNumber = $json->streetnumber;
break;
}
$parcel->Country = $json->country;
$parcel->PostalCode = $json->zip;
@ -164,4 +191,4 @@ class Versandart_sendcloud extends Versanddienstleister
}
}
}

View File

@ -51,6 +51,16 @@
<td>Konto f&uuml;r Differenzen:</td>
<td><input type="text" name="sachkonto" id="sachkonto" value="[SACHKONTO]" /></td>
</tr>
<tr>
<td>Format:</td>
<td>
<select name="format">
<option value="ISO-8859-1">ISO-8859-1</option>
<option value="UTF-8">UTF-8</option>
<option value="UTF-8-BOM">UTF-8 mit BOM</option>
</select>
</td>
</tr>
</table>
</fieldset>
</div>

View File

@ -80,6 +80,7 @@ class Exportbuchhaltung
$lgchecked = $this->app->Secure->GetPOST("lieferantengutschrift");
$diffignore = $this->app->Secure->GetPOST("diffignore");
$sachkonto = $this->app->Secure->GetPOST('sachkonto');
$format = $this->app->Secure->GetPOST('format');
$account_id = null;
if (!empty($sachkonto)) {
@ -162,7 +163,7 @@ class Exportbuchhaltung
if ($dataok) {
$filename = "EXTF_".date('Ymd') . "_Buchungsstapel_DATEV_export.csv";
try {
$csv = $this->DATEV_Buchuchungsstapel($rgchecked, $gschecked, $vbchecked, $lgchecked, $buchhaltung_berater, $buchhaltung_mandant, $buchhaltung_wj_beginn, $buchhaltung_sachkontenlaenge, $von, $bis, $projekt, $filename, $diffignore, $sachkonto_kennung);
$csv = $this->DATEV_Buchuchungsstapel($rgchecked, $gschecked, $vbchecked, $lgchecked, $buchhaltung_berater, $buchhaltung_mandant, $buchhaltung_wj_beginn, $buchhaltung_sachkontenlaenge, $von, $bis, $projekt, $filename, $diffignore, $sachkonto_kennung, $format);
header("Content-Disposition: attachment; filename=" . $filename);
header("Pragma: no-cache");
header("Expires: 0");
@ -214,9 +215,10 @@ class Exportbuchhaltung
/*
* Create DATEV Buchhungsstapel
* format: "ISO-8859-1", "UTF-8", "UTF-8-BOM"
* @throws ConsistencyException with string (list of items) if consistency check fails and no sachkonto for differences is given
*/
function DATEV_Buchuchungsstapel(bool $rechnung, bool $gutschrift, bool $verbindlichkeit, bool $lieferantengutschrift, string $berater, string $mandant, datetime $wj_beginn, int $sachkontenlaenge, datetime $von, datetime $bis, int $projekt = 0, string $filename = 'EXTF_Buchungsstapel_DATEV_export.csv', $diffignore = false, $sachkonto_differences) : string {
function DATEV_Buchuchungsstapel(bool $rechnung, bool $gutschrift, bool $verbindlichkeit, bool $lieferantengutschrift, string $berater, string $mandant, datetime $wj_beginn, int $sachkontenlaenge, datetime $von, datetime $bis, int $projekt = 0, string $filename = 'EXTF_Buchungsstapel_DATEV_export.csv', $diffignore = false, $sachkonto_differences, string $format = "ISO-8859-1") : string {
$datev_header_definition = array (
'1' => 'Kennzeichen',
@ -671,7 +673,17 @@ class Exportbuchhaltung
$csv .= '"0";"S";"EUR";"0";"";"";"1234";"1370";"";"101";"";"";"";"Testbuchung";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"0";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";""'; // Testbuchung
$csv = mb_convert_encoding($csv, "ISO-8859-1", "UTF-8");
switch ($format) {
case "UTF-8":
break;
case "UTF-8-BOM":
$csv = "\xef\xbb\xbf".$csv;
break;
default:
$csv = mb_convert_encoding($csv, "ISO-8859-1", "UTF-8");
break;
}
return($csv);
}