Update Sage50Swiss Export

This commit is contained in:
Alexandre SPANGARO 2023-04-29 08:09:22 +02:00
parent 6b87da93c5
commit 383bc8a4a7

View File

@ -1556,19 +1556,47 @@ class AccountancyExport
* https://onlinehelp.sageschweiz.ch/default.aspx?tabid=19984 * https://onlinehelp.sageschweiz.ch/default.aspx?tabid=19984
* http://media.topal.ch/Public/Schnittstellen/TAF/Specification/Sage50-TAF-format.pdf * http://media.topal.ch/Public/Schnittstellen/TAF/Specification/Sage50-TAF-format.pdf
* *
* @param array $objectLines data * @param array $objectLines data
* * @param resource $exportFile [=null] File resource to export or print if null
* @return void * @return void
*/ */
public function exportSAGE50SWISS($objectLines) public function exportSAGE50SWISS($objectLines, $exportFile = null)
{ {
// SAGE50SWISS // SAGE50SWISS
$this->separator = ','; $separator = ',';
$this->end_line = "\r\n"; $end_line = "\r\n";
// Print header line // Print header line
print "Blg,Datum,Kto,S/H,Grp,GKto,SId,SIdx,KIdx,BTyp,MTyp,Code,Netto,Steuer,FW-Betrag,Tx1,Tx2,PkKey,OpId,Flag"; $tab = array();
print $this->end_line;
$tab[] = "Blg";
$tab[] = "Datum";
$tab[] = "Kto";
$tab[] = "S/H";
$tab[] = "Grp";
$tab[] = "GKto";
$tab[] = "SId";
$tab[] = "SIdx";
$tab[] = "KIdx";
$tab[] = "BTyp";
$tab[] = "MTyp";
$tab[] = "Code";
$tab[] = "Netto";
$tab[] = "Steuer";
$tab[] = "FW-Betrag";
$tab[] = "Tx1";
$tab[] = "Tx2";
$tab[] = "PkKey";
$tab[] = "OpId";
$tab[] = "Flag";
$output = implode($separator, $tab).$end_line;
if ($exportFile) {
fwrite($exportFile, $output);
} else {
print $output;
}
$thisPieceNum = ""; $thisPieceNum = "";
$thisPieceAccountNr = ""; $thisPieceAccountNr = "";
$aSize = count($objectLines); $aSize = count($objectLines);
@ -1586,56 +1614,58 @@ class AccountancyExport
$sammelBuchung = true; $sammelBuchung = true;
} }
$tab = array();
//Blg //Blg
print $line->piece_num.$this->separator; $tab[] = $line->piece_num;
// Datum // Datum
$date = dol_print_date($line->doc_date, '%d.%m.%Y'); $date_document = dol_print_date($line->doc_date, '%d.%m.%Y');
print $date.$this->separator; $tab[] = $date_document;
// Kto // Kto
print length_accountg($line->numero_compte).$this->separator; $tab[] = length_accountg($line->numero_compte);
// S/H // S/H
if ($line->sens == 'D') { if ($line->sens == 'D') {
print 'S'.$this->separator; $tab[] = 'S';
} else { } else {
print 'H'.$this->separator; $tab[] = 'H';
} }
//Grp // Grp
print self::trunc($line->code_journal, 1).$this->separator; $tab[] = self::trunc($line->code_journal, 1);
// GKto // GKto
if (empty($line->code_tiers)) { if (empty($line->code_tiers)) {
if ($line->piece_num == $thisPieceNum) { if ($line->piece_num == $thisPieceNum) {
print length_accounta($thisPieceAccountNr).$this->separator; $tab[] = length_accounta($thisPieceAccountNr);
} else { } else {
print "div".$this->separator; $tab[] = "div";
} }
} else { } else {
print length_accounta($line->code_tiers).$this->separator; $tab[] = length_accounta($line->code_tiers);
} }
//SId // SId
print $this->separator; $tab[] = $this->separator;
//SIdx // SIdx
print "0".$this->separator; $tab[] = "0";
//KIdx // KIdx
print "0".$this->separator; $tab[] = "0";
//BTyp // BTyp
print "0".$this->separator; $tab[] = "0";
//MTyp 1=Fibu Einzelbuchung 2=Sammebuchung // MTyp 1=Fibu Einzelbuchung 2=Sammebuchung
if ($sammelBuchung) { if ($sammelBuchung) {
print "2".$this->separator; $tab[] = "2";
} else { } else {
print "1".$this->separator; $tab[] = "1";
} }
// Code // Code
print '""'.$this->separator; $tab[] = '""';
// Netto // Netto
print abs($line->debit - $line->credit).$this->separator; $tab[] = abs($line->debit - $line->credit);
// Steuer // Steuer
print "0.00".$this->separator; $tab[] = "0.00";
// FW-Betrag // FW-Betrag
print "0.00".$this->separator; $tab[] = "0.00";
// Tx1 // Tx1
$line1 = self::toAnsi($line->label_compte, 29); $line1 = self::toAnsi($line->label_compte, 29);
if ($line1 == "LIQ" || $line1 == "LIQ Beleg ok" || strlen($line1) <= 3) { if ($line1 == "LIQ" || $line1 == "LIQ Beleg ok" || strlen($line1) <= 3) {
@ -1651,18 +1681,23 @@ class AccountancyExport
$line2 = ""; $line2 = "";
} }
print '"'.self::toAnsi($line1).'"'.$this->separator; $tab[] = '"'.self::toAnsi($line1).'"';
// Tx2 // Tx2
print '"'.self::toAnsi($line2).'"'.$this->separator; $tab[] = '"'.self::toAnsi($line2).'"';
//PkKey //PkKey
print "0".$this->separator; $tab[] = "0";
//OpId //OpId
print $this->separator; $tab[] = $this->separator;
// Flag // Flag
print "0"; $tab[] = "0";
print $this->end_line; $output = implode($separator, $tab).$end_line;
if ($exportFile) {
fwrite($exportFile, $output);
} else {
print $output;
}
if ($line->piece_num !== $thisPieceNum) { if ($line->piece_num !== $thisPieceNum) {
$thisPieceNum = $line->piece_num; $thisPieceNum = $line->piece_num;