Anlage des Repos
This commit is contained in:
666
archive/Export-WinLineDoc/Archiv/Export-WinLineDocument.vbs
Normal file
666
archive/Export-WinLineDoc/Archiv/Export-WinLineDocument.vbs
Normal file
@@ -0,0 +1,666 @@
|
||||
' VB Script Document
|
||||
'
|
||||
' Export Script for WinLine documents.
|
||||
' Configuration has to be done in the additional fields in the "WinLine Mandantenstamm"
|
||||
'
|
||||
' Digital Data
|
||||
' Ludwig-Rinn-Straße 16
|
||||
' 35452 Heuchelheim
|
||||
' Tel.: 0641 / 202360
|
||||
' E-Mail: info(at)didalog.de
|
||||
'
|
||||
' Version Number: 1.0.1.0
|
||||
' Version Date: 15.07.2019
|
||||
|
||||
On Error Resume Next
|
||||
|
||||
'#-----------------------------------------------------------------------------------------------------#
|
||||
'############################################ set variables ############################################
|
||||
'#-----------------------------------------------------------------------------------------------------#
|
||||
|
||||
DIM DateTime, SplitChar, ReplaceSpecialChar, DocExtension, DocVersion, DocVersionSeparator, DocType, MandatorShortName, DocAccountNumber, DocAANGExportPath, DocAABExportPath, DocALSExportPath, DocAREExportPath
|
||||
DIM FileSystemObject, Shell, DocAANGConvention, DocAABConvention, DocALSConvention, DocAREConvention, DocAANGNumber, DocAABNumber, DocALSNumber, DocARENumber, DocTargetPath, DocTargetFileName, FullPath
|
||||
SET FileSystemObject = CreateObject("Scripting.FileSystemObject")
|
||||
SET Shell = CreateObject("WScript.Shell")
|
||||
|
||||
'Standard / default variables.
|
||||
DateTime = now
|
||||
SplitChar = "|"
|
||||
ReplaceSpecialChar = " "
|
||||
DocExtension = ".pdf"
|
||||
DocExportCheck = "true"
|
||||
DocExportCheckTry = 0
|
||||
DocExportCheckMaxTrys = 10
|
||||
DocVersion = 1
|
||||
DocVersionSeparator = "~"
|
||||
Timestamp = ((year(DateTime)*100 + month(DateTime))*100 + day(DateTime))*10000 + hour(DateTime)*100 + minute(DateTime)
|
||||
DocType = Value (25,139) 'WinLine Belegstufe
|
||||
RecordNumber = Value (25,22) 'WinLine Laufnummer
|
||||
PostingType = Value (357,6) 'WinLine Buchungsart (Debitorisch = 1 / Kreditorisch = 2)
|
||||
Amount = Value (0,201) 'WinLine Betrag (Artikel, Gutschrift)
|
||||
MandatorShortName = TRIM(CSTR(Value (1,200))) 'WinLine Mandantenkürzel (individual Feld)
|
||||
DocAccountNumber = TRIM(CSTR(Value (0,30))) 'WinLine Kontonummer (Debitor / Kreditor)
|
||||
DocAANGNumber = TRIM(CSTR(Value (0,34))) 'WinLine Angebotsnummer
|
||||
DocAABNumber = TRIM(CSTR(Value (0,35))) 'WinLine Auftragsnummer
|
||||
DocALSNumber = TRIM(CSTR(Value (0,36))) 'WinLine Lieferscheinnummer
|
||||
DocARENumber = TRIM(CSTR(Value (0,37))) 'WinLine Rechnungsnummer
|
||||
DocAANFNumber = TRIM(CSTR(Value (0,34))) 'WinLine Anfragennummer
|
||||
DocABENumber = TRIM(CSTR(Value (0,35))) 'WinLine Bestellnummer
|
||||
DocAANGExportPath = TRIM(CSTR(Split(Value (1,201),SplitChar)(0))) 'WinLine Exportpfad für Angebote (individual Feld)
|
||||
DocAABExportPath = TRIM(CSTR(Split(Value (1,202),SplitChar)(0))) 'WinLine Exportpfad für Aufträge (individual Feld)
|
||||
DocALSExportPath = TRIM(CSTR(Split(Value (1,203),SplitChar)(0))) 'WinLine Exportpfad für Lieferscheine (individual Feld)
|
||||
DocAREExportPath = TRIM(CSTR(Split(Value (1,204),SplitChar)(0))) 'WinLine Exportpfad für Rechnungen (individual Feld)
|
||||
DocAGUExportPath = TRIM(CSTR(Split(Value (1,205),SplitChar)(0))) 'WinLine Exportpfad für Gutschriften (individual Feld)
|
||||
DocAANFExportPath = TRIM(CSTR(Split(Value (1,206),SplitChar)(0))) 'WinLine Exportpfad für Anfragen (individual Feld)
|
||||
DocABEExportPath = TRIM(CSTR(Split(Value (1,207),SplitChar)(0))) 'WinLine Exportpfad für Bestellungen (individual Feld)
|
||||
DocAANGConvention = TRIM(CSTR(Split(Value (1,201),SplitChar)(1))) 'WinLine Benennungsschema für Angebote (individual Feld)
|
||||
DocAABConvention = TRIM(CSTR(Split(Value (1,202),SplitChar)(1))) 'WinLine Benennungsschema für Aufträge (individual Feld)
|
||||
DocALSConvention = TRIM(CSTR(Split(Value (1,203),SplitChar)(1))) 'WinLine Benennungsschema für Lieferscheine (individual Feld)
|
||||
DocAREConvention = TRIM(CSTR(Split(Value (1,204),SplitChar)(1))) 'WinLine Benennungsschema für Rechnungen (individual Feld)
|
||||
DocAGUConvention = TRIM(CSTR(Split(Value (1,205),SplitChar)(1))) 'WinLine Benennungsschema für Gutschriften (individual Feld)
|
||||
DocAANFConvention = TRIM(CSTR(Split(Value (1,206),SplitChar)(1))) 'WinLine Benennungsschema für Anfragen (individual Feld)
|
||||
DocABEConvention = TRIM(CSTR(Split(Value (1,207),SplitChar)(1))) 'WinLine Benennungsschema für Bestellungen (individual Feld)
|
||||
|
||||
MandatorSpecificVarCount = 50
|
||||
MandatorSpecificVarCounter = 0
|
||||
|
||||
i = 1 : s = ""
|
||||
'Loop for mass declaration of Mandator specific Variables
|
||||
DO
|
||||
s = s & i '& ", "
|
||||
MandatorSpecificVarCounter = MandatorSpecificVarCounter+1
|
||||
|
||||
msgbox i
|
||||
LOOP WHILE MandatorSpecificVarCounter < MandatorSpecificVarCount
|
||||
|
||||
|
||||
MandatorShortName = TRIM(CSTR(Value (1,200))) 'WinLine Mandantenkürzel (individual Feld)
|
||||
MandatorShortName = TRIM(CSTR(Value (1,201))) 'WinLine Mandantenkürzel (individual Feld)
|
||||
MandatorShortName = TRIM(CSTR(Value (1,202))) 'WinLine Mandantenkürzel (individual Feld)
|
||||
MandatorShortName = TRIM(CSTR(Value (1,203))) 'WinLine Mandantenkürzel (individual Feld)
|
||||
MandatorShortName = TRIM(CSTR(Value (1,204))) 'WinLine Mandantenkürzel (individual Feld)
|
||||
MandatorShortName = TRIM(CSTR(Value (1,205))) 'WinLine Mandantenkürzel (individual Feld)
|
||||
MandatorShortName = TRIM(CSTR(Value (1,206))) 'WinLine Mandantenkürzel (individual Feld)
|
||||
MandatorShortName = TRIM(CSTR(Value (1,207))) 'WinLine Mandantenkürzel (individual Feld)
|
||||
MandatorShortName = TRIM(CSTR(Value (1,208))) 'WinLine Mandantenkürzel (individual Feld)
|
||||
MandatorShortName = TRIM(CSTR(Value (1,209))) 'WinLine Mandantenkürzel (individual Feld)
|
||||
MandatorShortName = TRIM(CSTR(Value (1,210))) 'WinLine Mandantenkürzel (individual Feld)
|
||||
MandatorShortName = TRIM(CSTR(Value (1,211))) 'WinLine Mandantenkürzel (individual Feld)
|
||||
MandatorShortName = TRIM(CSTR(Value (1,212))) 'WinLine Mandantenkürzel (individual Feld)
|
||||
MandatorShortName = TRIM(CSTR(Value (1,213))) 'WinLine Mandantenkürzel (individual Feld)
|
||||
MandatorShortName = TRIM(CSTR(Value (1,214))) 'WinLine Mandantenkürzel (individual Feld)
|
||||
MandatorShortName = TRIM(CSTR(Value (1,215))) 'WinLine Mandantenkürzel (individual Feld)
|
||||
MandatorShortName = TRIM(CSTR(Value (1,216))) 'WinLine Mandantenkürzel (individual Feld)
|
||||
MandatorShortName = TRIM(CSTR(Value (1,217))) 'WinLine Mandantenkürzel (individual Feld)
|
||||
MandatorShortName = TRIM(CSTR(Value (1,218))) 'WinLine Mandantenkürzel (individual Feld)
|
||||
MandatorShortName = TRIM(CSTR(Value (1,219))) 'WinLine Mandantenkürzel (individual Feld)
|
||||
MandatorShortName = TRIM(CSTR(Value (1,220))) 'WinLine Mandantenkürzel (individual Feld)
|
||||
MandatorShortName = TRIM(CSTR(Value (1,221))) 'WinLine Mandantenkürzel (individual Feld)
|
||||
MandatorShortName = TRIM(CSTR(Value (1,222))) 'WinLine Mandantenkürzel (individual Feld)
|
||||
MandatorShortName = TRIM(CSTR(Value (1,223))) 'WinLine Mandantenkürzel (individual Feld)
|
||||
MandatorShortName = TRIM(CSTR(Value (1,224))) 'WinLine Mandantenkürzel (individual Feld)
|
||||
MandatorShortName = TRIM(CSTR(Value (1,225))) 'WinLine Mandantenkürzel (individual Feld)
|
||||
MandatorShortName = TRIM(CSTR(Value (1,226))) 'WinLine Mandantenkürzel (individual Feld)
|
||||
MandatorShortName = TRIM(CSTR(Value (1,227))) 'WinLine Mandantenkürzel (individual Feld)
|
||||
MandatorShortName = TRIM(CSTR(Value (1,228))) 'WinLine Mandantenkürzel (individual Feld)
|
||||
MandatorShortName = TRIM(CSTR(Value (1,229))) 'WinLine Mandantenkürzel (individual Feld)
|
||||
MandatorShortName = TRIM(CSTR(Value (1,230))) 'WinLine Mandantenkürzel (individual Feld)
|
||||
MandatorShortName = TRIM(CSTR(Value (1,231))) 'WinLine Mandantenkürzel (individual Feld)
|
||||
MandatorShortName = TRIM(CSTR(Value (1,232))) 'WinLine Mandantenkürzel (individual Feld)
|
||||
MandatorShortName = TRIM(CSTR(Value (1,233))) 'WinLine Mandantenkürzel (individual Feld)
|
||||
MandatorShortName = TRIM(CSTR(Value (1,234))) 'WinLine Mandantenkürzel (individual Feld)
|
||||
MandatorShortName = TRIM(CSTR(Value (1,235))) 'WinLine Mandantenkürzel (individual Feld)
|
||||
MandatorShortName = TRIM(CSTR(Value (1,236))) 'WinLine Mandantenkürzel (individual Feld)
|
||||
MandatorShortName = TRIM(CSTR(Value (1,237))) 'WinLine Mandantenkürzel (individual Feld)
|
||||
MandatorShortName = TRIM(CSTR(Value (1,238))) 'WinLine Mandantenkürzel (individual Feld)
|
||||
MandatorShortName = TRIM(CSTR(Value (1,239))) 'WinLine Mandantenkürzel (individual Feld)
|
||||
MandatorShortName = TRIM(CSTR(Value (1,240))) 'WinLine Mandantenkürzel (individual Feld)
|
||||
|
||||
'Costumer variables - dont forget to add the replace function in the lower preparing part.
|
||||
'VarName = mesoField 'Description
|
||||
|
||||
'#-----------------------------------------------------------------------------------------------------#
|
||||
'########################################### preparing part ############################################
|
||||
'#-----------------------------------------------------------------------------------------------------#
|
||||
|
||||
'Retrive Document Type (0 = Vorschau).
|
||||
IF (DocType = 0) THEN
|
||||
|
||||
'Nothing will happen, its just a Preview ;-)
|
||||
|
||||
'Retrive Document Type (1 = Angebot/Anfrage). Depending on it, the Targetpath and Targetfilename.
|
||||
ELSEIF (DocType = 1) THEN)
|
||||
|
||||
'If document is for a debtor.
|
||||
IF (PostingType = 1) THEN
|
||||
|
||||
'If ExportPath has content
|
||||
IF NOT (IsEmpty(DocAANGExportPath) Or IsNull(DocAANGExportPath) Or DocAANGExportPath = "") THEN
|
||||
|
||||
DocTargetPath = DocAANGExportPath
|
||||
|
||||
'If ExportPath has no content, fallback on the general WinLine network path.
|
||||
ELSE
|
||||
|
||||
DocTargetPath = "%NETWORK%"
|
||||
|
||||
END IF
|
||||
|
||||
'If Convention has content.
|
||||
IF NOT (IsEmpty(DocAANGConvention) Or IsNull(DocAANGConvention) Or DocAANGConvention = "") THEN
|
||||
|
||||
DocTargetFileName = DocAANGConvention
|
||||
|
||||
'If Convention AND ExportPath had both no content.
|
||||
ELSEIF (DocTargetPath = "%NETWORK%") THEN
|
||||
|
||||
DocTargetFileName = Nothing
|
||||
|
||||
'If ExportPath has content, but Convention hasnt.
|
||||
ELSE
|
||||
|
||||
MSGBOX("Ungültige Export Dateinamens Einstellung für Ausgangsangebote. FailSafe ist AANG_" & DocAccountNumber & "_" & Timestamp & ".pdf" & "!")
|
||||
DocTargetFileName = "AANG_" & DocAccountNumber & Timestamp
|
||||
|
||||
END IF
|
||||
|
||||
'If document is for a creditor.
|
||||
ELSEIF (PostingType = 2) THEN
|
||||
|
||||
'If ExportPath has content
|
||||
IF NOT (IsEmpty(DocAANFExportPath) Or IsNull(DocAANFExportPath) Or DocAANFExportPath = "") THEN
|
||||
|
||||
DocTargetPath = DocAANFExportPath
|
||||
|
||||
'If ExportPath has no content, fallback on the general WinLine network path.
|
||||
ELSE
|
||||
|
||||
DocTargetPath = "%NETWORK%"
|
||||
|
||||
END IF
|
||||
|
||||
'If Convention has content.
|
||||
IF NOT (IsEmpty(DocAANFConvention) Or IsNull(DocAANFConvention) Or DocAANFConvention = "") THEN
|
||||
|
||||
DocTargetFileName = DocAANFConvention
|
||||
|
||||
'If Convention AND ExportPath had both no content.
|
||||
ELSEIF (DocTargetPath = "%NETWORK%") THEN
|
||||
|
||||
DocTargetFileName = Nothing
|
||||
|
||||
'If ExportPath has content, but Convention hasnt.
|
||||
ELSE
|
||||
|
||||
MSGBOX("Ungültige Export Dateinamens Einstellung für Ausgangsanfragen. FailSafe ist AANF_" & DocAccountNumber & "_" & Timestamp & ".pdf" & "!")
|
||||
DocTargetFileName = "AANF_" & DocAccountNumber & Timestamp
|
||||
|
||||
END IF
|
||||
|
||||
'If document is not for a debtor or creditor.
|
||||
ELSE
|
||||
|
||||
MSGBOX("Undefinierte Export Einstellung! Abbruch des Exports.")
|
||||
|
||||
END IF
|
||||
|
||||
'########## working on it'#########
|
||||
'Retrive Document Type (10 = StornoAngebot/Anfrage). Depending on it, the Targetpath and Targetfilename.
|
||||
ELSEIF (DocType = 1) THEN)
|
||||
|
||||
'If document is for a debtor.
|
||||
IF (PostingType = 1) THEN
|
||||
|
||||
'If ExportPath has content
|
||||
IF NOT (IsEmpty(DocAANGExportPath) Or IsNull(DocAANGExportPath) Or DocAANGExportPath = "") THEN
|
||||
|
||||
DocTargetPath = DocAANGExportPath
|
||||
|
||||
'If ExportPath has no content, fallback on the general WinLine network path.
|
||||
ELSE
|
||||
|
||||
DocTargetPath = "%NETWORK%"
|
||||
|
||||
END IF
|
||||
|
||||
'If Convention has content.
|
||||
IF NOT (IsEmpty(DocAANGConvention) Or IsNull(DocAANGConvention) Or DocAANGConvention = "") THEN
|
||||
|
||||
DocTargetFileName = DocAANGConvention
|
||||
|
||||
'If Convention AND ExportPath had both no content.
|
||||
ELSEIF (DocTargetPath = "%NETWORK%") THEN
|
||||
|
||||
DocTargetFileName = Nothing
|
||||
|
||||
'If ExportPath has content, but Convention hasnt.
|
||||
ELSE
|
||||
|
||||
MSGBOX("Ungültige Export Dateinamens Einstellung für Ausgangsangebote. FailSafe ist AANG_" & DocAccountNumber & "_" & Timestamp & ".pdf" & "!")
|
||||
DocTargetFileName = "AANG_" & DocAccountNumber & Timestamp
|
||||
|
||||
END IF
|
||||
|
||||
'If document is for a creditor.
|
||||
ELSEIF (PostingType = 2) THEN
|
||||
|
||||
'If ExportPath has content
|
||||
IF NOT (IsEmpty(DocAANFExportPath) Or IsNull(DocAANFExportPath) Or DocAANFExportPath = "") THEN
|
||||
|
||||
DocTargetPath = DocAANFExportPath
|
||||
|
||||
'If ExportPath has no content, fallback on the general WinLine network path.
|
||||
ELSE
|
||||
|
||||
DocTargetPath = "%NETWORK%"
|
||||
|
||||
END IF
|
||||
|
||||
'If Convention has content.
|
||||
IF NOT (IsEmpty(DocAANFConvention) Or IsNull(DocAANFConvention) Or DocAANFConvention = "") THEN
|
||||
|
||||
DocTargetFileName = DocAANFConvention
|
||||
|
||||
'If Convention AND ExportPath had both no content.
|
||||
ELSEIF (DocTargetPath = "%NETWORK%") THEN
|
||||
|
||||
DocTargetFileName = Nothing
|
||||
|
||||
'If ExportPath has content, but Convention hasnt.
|
||||
ELSE
|
||||
|
||||
MSGBOX("Ungültige Export Dateinamens Einstellung für Ausgangsanfragen. FailSafe ist AANF_" & DocAccountNumber & "_" & Timestamp & ".pdf" & "!")
|
||||
DocTargetFileName = "AANF_" & DocAccountNumber & Timestamp
|
||||
|
||||
END IF
|
||||
|
||||
'If document is not for a debtor or creditor.
|
||||
ELSE
|
||||
|
||||
MSGBOX("Undefinierte Export Einstellung! Abbruch des Exports.")
|
||||
|
||||
END IF
|
||||
|
||||
|
||||
'########## working on it
|
||||
|
||||
|
||||
'Retrive Document Type (2 = Auftrag/Bestellung). Depending on it, the Targetpath and Targetfilename.
|
||||
ELSEIF (DocType = 2) THEN
|
||||
|
||||
'If document is for a debtor.
|
||||
IF (PostingType = 1) THEN
|
||||
|
||||
'If ExportPath has content
|
||||
IF NOT (IsEmpty(DocAABExportPath) Or IsNull(DocAABExportPath) Or DocAABExportPath = "") THEN
|
||||
|
||||
DocTargetPath = DocAABExportPath
|
||||
|
||||
'If ExportPath has no content, try to exit. But exit wont work, so fallback on the general WinLine network path.
|
||||
ELSE
|
||||
|
||||
DocTargetPath = "%NETWORK%"
|
||||
|
||||
END IF
|
||||
|
||||
'If Convention has content.
|
||||
IF NOT (IsEmpty(DocAABConvention) Or IsNull(DocAABConvention) Or DocAABConvention = "") THEN
|
||||
|
||||
DocTargetFileName = DocAABConvention
|
||||
|
||||
'If Convention AND ExportPath had both no content.
|
||||
ELSEIF (DocTargetPath = "%NETWORK%") THEN
|
||||
|
||||
DocTargetFileName = Nothing
|
||||
|
||||
'If ExportPath has content, but Convention hasnt.
|
||||
ELSE
|
||||
|
||||
MSGBOX("Ungültige Export Dateinamens Einstellung für Ausgangsauftragsbestätgrechnungen. FailSafe ist AAB_" & DocAccountNumber & "_" & Timestamp & ".pdf" & "!")
|
||||
DocTargetFileName = "AAB_" & DocAccountNumber & Timestamp
|
||||
|
||||
END IF
|
||||
|
||||
'If document is for a creditor.
|
||||
ELSEIF (PostingType = 2) THEN
|
||||
|
||||
'If ExportPath has content
|
||||
IF NOT (IsEmpty(DocABEExportPath) Or IsNull(DocABEExportPath) Or DocABEExportPath = "") THEN
|
||||
|
||||
DocTargetPath = DocABEExportPath
|
||||
|
||||
'If ExportPath has no content, fallback on the general WinLine network path.
|
||||
ELSE
|
||||
|
||||
DocTargetPath = "%NETWORK%"
|
||||
|
||||
END IF
|
||||
|
||||
'If Convention has content.
|
||||
IF NOT (IsEmpty(DocABEConvention) Or IsNull(DocABEConvention) Or DocABEConvention = "") THEN
|
||||
|
||||
DocTargetFileName = DocABEConvention
|
||||
|
||||
'If Convention AND ExportPath had both no content.
|
||||
ELSEIF (DocTargetPath = "%NETWORK%") THEN
|
||||
|
||||
DocTargetFileName = Nothing
|
||||
|
||||
'If ExportPath has content, but Convention hasnt.
|
||||
ELSE
|
||||
|
||||
MSGBOX("Ungültige Export Dateinamens Einstellung für Ausgangsbestellungen. FailSafe ist ABE_" & DocAccountNumber & "_" & Timestamp & ".pdf" & "!")
|
||||
DocTargetFileName = "ABE_" & DocAccountNumber & Timestamp
|
||||
|
||||
END IF
|
||||
|
||||
'If document is not for a debtor or creditor.
|
||||
ELSE
|
||||
|
||||
MSGBOX("Undefinierte Export Einstellung! Abbruch des Exports.")
|
||||
|
||||
END IF
|
||||
|
||||
'Retrive Document Type (3 = Lieferschein / -3 = Teillieferschein). Depending on it, the Targetpath and Targetfilename.
|
||||
ELSEIF (DocType = 3 OR DocType = -3) THEN
|
||||
|
||||
'If document is for a debtor.
|
||||
IF (PostingType = 1) THEN
|
||||
|
||||
'If ExportPath has content
|
||||
IF NOT (IsEmpty(DocALSExportPath) Or IsNull(DocALSExportPath) Or DocALSExportPath = "") THEN
|
||||
|
||||
DocTargetPath = DocALSExportPath
|
||||
|
||||
'If ExportPath has no content, try to exit. But exit wont work, so fallback on the general WinLine network path.
|
||||
ELSE
|
||||
|
||||
DocTargetPath = "%NETWORK%"
|
||||
|
||||
END IF
|
||||
|
||||
'If Convention has content.
|
||||
IF NOT (IsEmpty(DocALSConvention) Or IsNull(DocALSConvention) Or DocALSConvention = "") THEN
|
||||
|
||||
DocTargetFileName = DocALSConvention
|
||||
|
||||
'If Convention AND ExportPath had both no content.
|
||||
ELSEIF (DocTargetPath = "%NETWORK%") THEN
|
||||
|
||||
DocTargetFileName = Nothing
|
||||
|
||||
'If ExportPath has content, but Convention hasnt.
|
||||
ELSE
|
||||
|
||||
MSGBOX("Ungültige Export Dateinamens Einstellung für Ausgangslieferscheine. FailSafe ist ALS_" & DocAccountNumber & "_" & Timestamp & ".pdf" & "!")
|
||||
DocTargetFileName = "ALS_" & DocAccountNumber & Timestamp
|
||||
|
||||
END IF
|
||||
|
||||
'If document is for a creditor.
|
||||
ELSEIF (PostingType = 2) THEN
|
||||
|
||||
'########################################### Currently not implemented ###########################################
|
||||
|
||||
'If document is not for a debtor or creditor.
|
||||
ELSE
|
||||
|
||||
MSGBOX("Undefinierte Export Einstellung! Abbruch des Exports.")
|
||||
|
||||
END IF
|
||||
|
||||
'Retrive Document Type (4 = Rechnung). Depending on it, the Targetpath and Targetfilename.
|
||||
ELSEIF (DocType = 4) THEN
|
||||
|
||||
'If document is for a debtor.
|
||||
IF (PostingType = 1) THEN
|
||||
|
||||
IF (LEFT(Amount,1) = "-") THEN
|
||||
|
||||
'If ExportPath has content
|
||||
IF NOT (IsEmpty(DocAGUExportPath) Or IsNull(DocAGUExportPath) Or DocAGUExportPath = "") THEN
|
||||
|
||||
DocTargetPath = DocAGUExportPath
|
||||
|
||||
'If ExportPath has no content, try to exit. But exit wont work, so fallback on the general WinLine network path.
|
||||
ELSE
|
||||
|
||||
DocTargetPath = "%NETWORK%"
|
||||
|
||||
END IF
|
||||
|
||||
'If Convention has content.
|
||||
IF NOT (IsEmpty(DocAGUConvention) Or IsNull(DocAGUConvention) Or DocAGUConvention = "") THEN
|
||||
|
||||
DocTargetFileName = DocAGUConvention
|
||||
|
||||
'If Convention AND ExportPath had both no content.
|
||||
ELSEIF (DocTargetPath = "%NETWORK%") THEN
|
||||
|
||||
DocTargetFileName = Nothing
|
||||
|
||||
'If ExportPath has content, but Convention hasnt.
|
||||
ELSE
|
||||
|
||||
MSGBOX("Ungültige Export Dateinamens Einstellung für Ausgangsgutschriften. FailSafe ist AGU_" & DocAccountNumber & "_" & Timestamp & ".pdf" & "!")
|
||||
DocTargetFileName = "AGU_" & DocAccountNumber & Timestamp
|
||||
|
||||
END IF
|
||||
|
||||
ELSE
|
||||
|
||||
'If ExportPath has content
|
||||
IF NOT (IsEmpty(DocAREExportPath) Or IsNull(DocAREExportPath) Or DocAREExportPath = "") THEN
|
||||
|
||||
DocTargetPath = DocAREExportPath
|
||||
|
||||
'If ExportPath has no content, try to exit. But exit wont work, so fallback on the general WinLine network path.
|
||||
ELSE
|
||||
|
||||
DocTargetPath = "%NETWORK%"
|
||||
|
||||
END IF
|
||||
|
||||
'If Convention has content.
|
||||
IF NOT (IsEmpty(DocAREConvention) Or IsNull(DocAREConvention) Or DocAREConvention = "") THEN
|
||||
|
||||
DocTargetFileName = DocAREConvention
|
||||
|
||||
'If Convention AND ExportPath had both no content.
|
||||
ELSEIF (DocTargetPath = "%NETWORK%") THEN
|
||||
|
||||
DocTargetFileName = Nothing
|
||||
|
||||
'If ExportPath has content, but Convention hasnt.
|
||||
ELSE
|
||||
|
||||
MSGBOX("Ungültige Export Dateinamens Einstellung für Ausgangsrechnungen. FailSafe ist ARE_" & DocAccountNumber & "_" & Timestamp & ".pdf" & "!")
|
||||
DocTargetFileName = "ARE_" & DocAccountNumber & Timestamp
|
||||
|
||||
END IF
|
||||
|
||||
END IF
|
||||
|
||||
'If document is for a creditor.
|
||||
ELSEIF (PostingType = 2) THEN
|
||||
|
||||
'########################################### Currently not implemented ###########################################
|
||||
|
||||
'If document is not for a debtor or creditor.
|
||||
ELSE
|
||||
|
||||
MSGBOX("Undefinierte Export Einstellung! Abbruch des Exports.")
|
||||
|
||||
END IF
|
||||
|
||||
'Retrive Document Type (14 = StornoRechnung). Depending on it, the Targetpath and Targetfilename.
|
||||
ELSEIF (DocType = 14) THEN
|
||||
|
||||
|
||||
'If DocType was unknown.
|
||||
ELSE
|
||||
|
||||
MSGBOX("Undefinierte Belegstufe (" & DocType & ")! Abbruch des Exports.")
|
||||
|
||||
END IF
|
||||
|
||||
'Replace PlaceHolder in DocTargetPath from Configuration, including invalid Characters.
|
||||
IF (DocTargetPath <> "") THEN
|
||||
|
||||
DocTargetPath = Replace(DocTargetPath,"%Mandantenkürzel%",MandatorShortName)
|
||||
DocTargetPath = Replace(DocTargetPath,"%Jahr%",(Year(date)))
|
||||
DocTargetPath = Replace(DocTargetPath,"%Monat%",(month(date)))
|
||||
DocTargetPath = Replace(DocTargetPath,"%Monatsname%",MonthName((month(date))))
|
||||
DocTargetPath = Replace(DocTargetPath,"%Tag%",(day(date)))
|
||||
DocTargetPath = Replace(DocTargetPath,"%KontoNr%",DocAccountNumber)
|
||||
DocTargetPath = Replace(DocTargetPath,"%Laufnummer%",RecordNumber)
|
||||
DocTargetPath = Replace(Replace(Replace(Replace(Replace(Replace(DocTargetPath,"/",ReplaceSpecialChar),"*",ReplaceSpecialChar),"?",ReplaceSpecialChar),"<",ReplaceSpecialChar),">",ReplaceSpecialChar),"|",ReplaceSpecialChar)
|
||||
|
||||
END IF
|
||||
|
||||
'Replace PlaceHolder in DocTargetFileName from Configuration, including invalid Characters.
|
||||
IF (DocTargetFileName <> "") THEN
|
||||
|
||||
DocTargetFileName = Replace(DocTargetFileName,"%Mandantenkürzel%",MandatorShortName)
|
||||
DocTargetFileName = Replace(DocTargetFileName,"%AngebotsNr%",DocAANGNumber)
|
||||
DocTargetFileName = Replace(DocTargetFileName,"%AuftragsNr%",DocAABNumber)
|
||||
DocTargetFileName = Replace(DocTargetFileName,"%LieferscheinNr%",DocALSNumber)
|
||||
DocTargetFileName = Replace(DocTargetFileName,"%RechnungsNr%",DocARENumber)
|
||||
DocTargetFileName = Replace(DocTargetFileName,"%AnfragenNr%",DocAANFNumber)
|
||||
DocTargetFileName = Replace(DocTargetFileName,"%BestellNr%",DocABENumber)
|
||||
DocTargetFileName = Replace(DocTargetFileName,"%Jahr%",(Year(date)))
|
||||
DocTargetFileName = Replace(DocTargetFileName,"%Monat%",(month(date)))
|
||||
DocTargetFileName = Replace(DocTargetFileName,"%Monatsname%",MonthName((month(date))))
|
||||
DocTargetFileName = Replace(DocTargetFileName,"%Tag%",(day(date)))
|
||||
DocTargetFileName = Replace(DocTargetFileName,"%KontoNr%",DocAccountNumber)
|
||||
DocTargetFileName = Replace(DocTargetFileName,"%Laufnummer%",RecordNumber)
|
||||
DocTargetFileName = Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(DocTargetFileName,"\",ReplaceSpecialChar),"/",ReplaceSpecialChar),":",ReplaceSpecialChar),"*",ReplaceSpecialChar),"?",ReplaceSpecialChar),"<",ReplaceSpecialChar),">",ReplaceSpecialChar),"|",ReplaceSpecialChar)
|
||||
|
||||
END IF
|
||||
|
||||
'#-----------------------------------------------------------------------------------------------------#
|
||||
'############################################# main part ###############################################
|
||||
'#-----------------------------------------------------------------------------------------------------#
|
||||
|
||||
'Check if all necessary export parameters are set.
|
||||
IF ((DocTargetPath <> "") AND (DocTargetFileName <> "") AND (DocExtension <> "")) THEN
|
||||
|
||||
'Check if destination folder / folder strukture exists. If not, try to create.
|
||||
IF NOT FileSystemObject.FolderExists(DocTargetPath) THEN
|
||||
|
||||
strDir = FileSystemObject.GetAbsolutePathName(DocTargetPath)
|
||||
arrDirs = Split( strDir, "\" )
|
||||
|
||||
If Left( strDir, 2 ) = "\\" THEN
|
||||
strDirBuild = "\\" & arrDirs(2) & "\" & arrDirs(3) & "\"
|
||||
idxFirst = 4
|
||||
Else
|
||||
strDirBuild = arrDirs(0) & "\"
|
||||
idxFirst = 1
|
||||
End If
|
||||
|
||||
For idx = idxFirst to Ubound( arrDirs )
|
||||
strDirBuild = FileSystemObject.BuildPath( strDirBuild, arrDirs(idx) )
|
||||
If Not FileSystemObject.FolderExists( strDirBuild ) THEN
|
||||
FileSystemObject.CreateFolder strDirBuild
|
||||
End if
|
||||
Next
|
||||
|
||||
END IF
|
||||
|
||||
'If DocTargetPath exists, export file - including version tagging.
|
||||
IF (FileSystemObject.FolderExists(DocTargetPath)) THEN
|
||||
|
||||
FullPath = DocTargetPath & "\" & DocTargetFileName & DocExtension
|
||||
|
||||
IF (FileSystemObject.FileExists(FullPath)) THEN
|
||||
|
||||
DO
|
||||
|
||||
DocVersion = DocVersion + 1
|
||||
FullPath = DocTargetPath & "\" & DocTargetFileName & DocVersionSeparator & DocVersion & DocExtension
|
||||
|
||||
LOOP UNTIL (FileSystemObject.FileExists(FullPath) = False)
|
||||
|
||||
END IF
|
||||
|
||||
ExportOutput FullPath, 5, 0
|
||||
|
||||
'Optional check if file was exported successfully.
|
||||
IF (DocExportCheck = "true") THEN
|
||||
|
||||
CheckExportScriptPath = FileSystemObject.FolderExists(Shell.ExpandEnvironmentStrings("%TEMP%") & "\" & "Digital_Data")
|
||||
CheckExportScript = "CheckExport-" & DocTargetFileName & ((year(DateTime)*100 + month(DateTime))*100 + day(DateTime))*10000 + hour(DateTime)*100 + minute(DateTime) & ".vbs"
|
||||
|
||||
IF NOT (CheckExportScriptPath) THEN
|
||||
|
||||
FileSystemObject.CreateFolder(CheckExportScriptPath)
|
||||
|
||||
END IF
|
||||
|
||||
IF (FileSystemObject.FolderExists(CheckExportScriptPath)) THEN
|
||||
|
||||
|
||||
|
||||
ELSE
|
||||
|
||||
|
||||
|
||||
END IF
|
||||
|
||||
END IF
|
||||
|
||||
ELSE
|
||||
|
||||
MSGBOX("ACHTUNG: Zielpfad für Export konnte nicht erstellt werden! Export wird abgebrochen.")
|
||||
|
||||
END IF
|
||||
|
||||
ELSE
|
||||
|
||||
'Missing Value in DocTargetPath, DocTargetFileName or DocExtension
|
||||
WScript.Quit(1)
|
||||
|
||||
END IF
|
||||
|
||||
'#-----------------------------------------------------------------------------------------------------#
|
||||
'########################################### finishing part ############################################
|
||||
'#-----------------------------------------------------------------------------------------------------#
|
||||
|
||||
FileSystemObject = Nothing
|
||||
Shell = Nothing
|
||||
DateTime = Nothing
|
||||
SplitChar = Nothing
|
||||
ReplaceSpecialChar = Nothing
|
||||
DocExtension = Nothing
|
||||
DocExportCheck = Nothing
|
||||
DocExportCheckTry = Nothing
|
||||
DocExportCheckMaxTrys = Nothing
|
||||
DocType = Nothing
|
||||
DocVersion = Nothing
|
||||
DocVersionSeparator = Nothing
|
||||
MandatorShortName = Nothing
|
||||
DocAccountNumber = Nothing
|
||||
DocAANGExportPath = Nothing
|
||||
DocAABExportPath = Nothing
|
||||
DocALSExportPath = Nothing
|
||||
DocAREExportPath = Nothing
|
||||
DocAANFExportPath = Nothing
|
||||
DocABExportPath = Nothing
|
||||
DocAANGConvention = Nothing
|
||||
DocAABConvention = Nothing
|
||||
DocALSConvention = Nothing
|
||||
DocAREConvention = Nothing
|
||||
DocAANFConvention = Nothing
|
||||
DocABEConvention = Nothing
|
||||
DocAANGNumber = Nothing
|
||||
DocAABNumber = Nothing
|
||||
DocALSNumber = Nothing
|
||||
DocARENumber = Nothing
|
||||
DocAANFNumber = Nothing
|
||||
DocABENumber = Nothing
|
||||
DocTargetPath = Nothing
|
||||
DocTargetFileName = Nothing
|
||||
FullPath = Nothing
|
||||
|
||||
Result = ""
|
||||
Reference in New Issue
Block a user