diff --git a/composer.json b/composer.json index aa69d5fe..82e41759 100644 --- a/composer.json +++ b/composer.json @@ -46,6 +46,7 @@ }, "require-dev": { "goetas-webservices/xsd2php": "^0", + "nette/php-generator": "*", "pdepend/pdepend": "^2", "phploc/phploc": "^7", "phpmd/phpmd": "^2", diff --git a/make/.gitignore b/make/.gitignore new file mode 100644 index 00000000..e5a1774f --- /dev/null +++ b/make/.gitignore @@ -0,0 +1,2 @@ +classes/ +download/ diff --git a/make/gencodelists b/make/gencodelists new file mode 100644 index 00000000..9cadfc77 --- /dev/null +++ b/make/gencodelists @@ -0,0 +1,4 @@ +#!/bin/bash + +sudo -u www-data php -f ./gencodelists.php +sudo -u www-data ../vendor/bin/phpcbf --standard=./../build/phpcsrules_psr12.xml -q ./classes/ diff --git a/make/gencodelists.php b/make/gencodelists.php new file mode 100644 index 00000000..225a6004 --- /dev/null +++ b/make/gencodelists.php @@ -0,0 +1,617 @@ + $dummy) { + $downloadFromUrl = $fileToDownload[DOWNLOADDEF_KEY_URL][$idx]; + $saveToFile = $fileToDownload[DOWNLOADDEF_KEY_TOFILE][$idx]; + $saveToDirectory = dirname($saveToFile); + + if (!is_file($saveToDirectory)) { + @mkdir($saveToDirectory); + } + + outputLine(sprintf("Downloading from\n %s\nand saving to file\n %s...", $downloadFromUrl, $saveToFile)); + + if (file_exists($saveToFile)) { + continue; + } + + $ch = curl_init(); + curl_setopt($ch, CURLOPT_URL, $downloadFromUrl); + curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:123.0) Gecko/20100101 Firefox/123.0"); + curl_setopt($ch, CURLOPT_HEADER, 0); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + curl_setopt($ch, CURLOPT_TIMEOUT, 10); + $output = curl_exec($ch); + curl_close($ch); + + if (file_put_contents($saveToFile, $output) === false) { + throw new \Exception('Failed saved the downloaded file.'); + } + } +} + +/** + * Download a bunch of files + * + * @param array $filesToDownload + * @return void + */ +function downloadLists(array $filesToDownload): void +{ + foreach ($filesToDownload as $fileToDownload) { + downloadList($fileToDownload); + } +} + +/** + * Create a code class + * + * @return void + */ +function createCodeClassFromKositJson(array $fileToDownload): void +{ + // Define some internal variables + + $classNamespace = $fileToDownload[DOWNLOADDEF_KEY_CLASSNAMESPACE]; + $className = $fileToDownload[DOWNLOADDEF_KEY_CLASSNAME]; + $classDir = PathUtils::combineAllPaths(dirname(__FILE__), "classes"); + $classTitle = $fileToDownload[DOWNLOADDEF_KEY_TITLE]; + $classTitleList = $fileToDownload[DOWNLOADDEF_KEY_TITLE_LIST]; + $classHomepageUrls = !is_array($fileToDownload[DOWNLOADDEF_KEY_URL_HP]) ? [$fileToDownload[DOWNLOADDEF_KEY_URL_HP]] : $fileToDownload[DOWNLOADDEF_KEY_URL_HP]; + $classShortIdentifiers = $fileToDownload[DOWNLOADDEF_KEY_SHORTIDENTIFIERS]; + $classFilename = PathUtils::combinePathWithFile($classDir, sprintf('%s.php', $className)); + $classConstantPrefixes = !is_array($fileToDownload[DOWNLOADDEF_KEY_CLASSCONSTANT_PREFIX]) ? [$fileToDownload[DOWNLOADDEF_KEY_CLASSCONSTANT_PREFIX]] : $fileToDownload[DOWNLOADDEF_KEY_CLASSCONSTANT_PREFIX]; + + $dataCodeIndex = $fileToDownload[DOWNLOADDEF_KEY_DATA_CODEINDEX] ?? 0; + $dataDescIndex = $fileToDownload[DOWNLOADDEF_KEY_DATA_DESCINDEX] ?? 1; + $dataDescLongIndex = $fileToDownload[DOWNLOADDEF_KEY_DATA_DESCLONGINDEX] ?? 2; + $dataSortIndex = $fileToDownload[DOWNLOADDEF_KEY_DATA_SORTINDEX] ?? ($fileToDownload[DOWNLOADDEF_KEY_DATA_CODEINDEX] ?? 0); + + $libName = $fileToDownload[DOWNLOADDEF_LIB_NAME]; + $libTitle = $fileToDownload[DOWNLOADDEF_LIB_TITLE]; + + // Check destination directory + + if (!is_file($classDir)) { + @mkdir($classDir); + } + + // Remove existing class file + + if (file_exists($classFilename)) { + @unlink($classFilename); + } + + // Create PHP Printer + + $phpPrinter = new Nette\PhpGenerator\Printer; + + // Create PHP File + + $phpFile = new Nette\PhpGenerator\PhpFile; + $phpFile->addComment(sprintf("This file is a part of horstoeko/%s.\n\nFor the full copyright and license information, please view the LICENSE\nfile that was distributed with this source code.", $libName)); + + // Create PHP Class + + $phpClass = $phpFile->addNamespace($classNamespace)->addClass($className); + $phpClass->addComment(sprintf("Class representing %s\nName of list: %s\n\n@category %s\n@package %s\n@author D. Erling \n@license https://opensource.org/licenses/MIT MIT\n@link https://github.com/horstoeko/zugferd", $classTitle, $classTitleList, $libTitle, $libTitle)); + foreach ($classHomepageUrls as $classHomepageUrl) { + $phpClass->addComment(sprintf("@see %s", $classHomepageUrl)); + } + + // Fill PHP Class + + foreach ($fileToDownload[DOWNLOADDEF_KEY_TOFILE] as $idx => $dummy) { + $downloadedContent = file_get_contents($fileToDownload[DOWNLOADDEF_KEY_TOFILE][$idx]); + $downloadedContentObject = json_decode($downloadedContent, true); + $downloadedContentObjectData = $downloadedContentObject["daten"]; + $constantPrefix = $classConstantPrefixes[$idx] ?? ""; + + usort( + $downloadedContentObjectData, + function ($a, $b) use ($dataSortIndex) { + return strcasecmp($a[$dataSortIndex], $b[$dataSortIndex]); + } + ); + + foreach ($downloadedContentObjectData as $line) { + $phpClass + ->addConstant(sprintf('%s%s', $constantPrefix, strIdentifier($line[$dataDescIndex], $classShortIdentifiers)), $line[$dataCodeIndex]) + ->addComment("\n" . (strComment($line[$dataDescIndex] ?? "")) . " (" . (strComment($line[$dataCodeIndex] ?? "")) . ")") + ->addComment("\n" . strComment($line[$dataDescLongIndex] ?? ($line[$dataDescIndex] ?? ""))); + } + } + + // Should methods be added + + if ($fileToDownload[DOWNLOADDEF_KEY_ADDMETHODS] === true) { + // Add method which returns a list of all codes to generated class + + $phpClassMethod = $phpClass->addMethod('getAllCodes'); + $phpClassMethod->setFinal(); + $phpClassMethod->setStatic(); + $phpClassMethod->setReturnType('array'); + $phpClassMethod->addComment("Returns an array of all available codes\n"); + $phpClassMethod->addComment("@return array"); + $phpClassMethod->addComment("@codeCoverageIgnore"); + $phpClassMethod->addBody('return ['); + + foreach ($fileToDownload[DOWNLOADDEF_KEY_TOFILE] as $idx => $dummy) { + $downloadedContent = file_get_contents($fileToDownload[DOWNLOADDEF_KEY_TOFILE][$idx]); + $downloadedContentObject = json_decode($downloadedContent, true); + $downloadedContentObjectData = $downloadedContentObject["daten"]; + $constantPrefix = $classConstantPrefixes[$idx] ?? ""; + + usort( + $downloadedContentObjectData, + function ($a, $b) use ($dataSortIndex) { + return strcasecmp($a[$dataSortIndex], $b[$dataSortIndex]); + } + ); + + foreach ($downloadedContentObjectData as $line) { + $phpClassMethod->addBody(sprintf(" static::%s%s,", $constantPrefix, strIdentifier($line[$dataDescIndex], $classShortIdentifiers))); + } + } + + $phpClassMethod->addBody('];'); + + // Add method which returns an associate array for code => description + + $phpClassMethod = $phpClass->addMethod('getAllCodeDescriptions'); + $phpClassMethod->setFinal(); + $phpClassMethod->setStatic(); + $phpClassMethod->setReturnType('array'); + $phpClassMethod->addComment("Returns an array of code descriptions indexed by code\n"); + $phpClassMethod->addComment("@return array"); + $phpClassMethod->addComment("@codeCoverageIgnore"); + $phpClassMethod->addBody('return ['); + + foreach ($fileToDownload[DOWNLOADDEF_KEY_TOFILE] as $idx => $dummy) { + $downloadedContent = file_get_contents($fileToDownload[DOWNLOADDEF_KEY_TOFILE][$idx]); + $downloadedContentObject = json_decode($downloadedContent, true); + $downloadedContentObjectData = $downloadedContentObject["daten"]; + $constantPrefix = $classConstantPrefixes[$idx] ?? ""; + + usort( + $downloadedContentObjectData, + function ($a, $b) use ($dataSortIndex) { + return strcasecmp($a[$dataSortIndex], $b[$dataSortIndex]); + } + ); + + foreach ($downloadedContentObjectData as $line) { + $phpClassMethod->addBody(sprintf(" static::%s%s => '%s',", $constantPrefix, strIdentifier($line[$dataDescIndex], $classShortIdentifiers), strDesc($line[$dataDescIndex]))); + } + } + + $phpClassMethod->addBody('];'); + + // Add method which returns an boolean true when code exists otherwise false + + $phpClassMethod = $phpClass->addMethod('checkCodeExists'); + $phpClassMethod->setFinal(); + $phpClassMethod->setStatic(); + $phpClassMethod->setReturnType('bool'); + $phpClassMethod->addComment("Returns true if a code exists in the list, otherwise false\n"); + $phpClassMethod->addComment("@param string \$code"); + $phpClassMethod->addComment("@return boolean"); + $phpClassMethod->addComment("@codeCoverageIgnore"); + $phpClassMethod->addParameter('code')->setType("string"); + $phpClassMethod->addBody('return isset(static::getAllCodes()[$code]);'); + + // Add method which returns the description of a code + + $phpClassMethod = $phpClass->addMethod('getCodeDescription'); + $phpClassMethod->setFinal(); + $phpClassMethod->setStatic(); + $phpClassMethod->setReturnType('string'); + $phpClassMethod->addComment("Returns the description of a code. If code is not found an empty string is returned\n"); + $phpClassMethod->addComment("@param string \$code"); + $phpClassMethod->addComment("@return string"); + $phpClassMethod->addComment("@codeCoverageIgnore"); + $phpClassMethod->addParameter('code')->setType("string"); + $phpClassMethod->addBody('if (static::checkCodeExists($code) === true) {'); + $phpClassMethod->addBody(' return static::getAllCodeDescriptions()[$code];'); + $phpClassMethod->addBody('}'); + $phpClassMethod->addBody(''); + $phpClassMethod->addBody('return "";'); + } + + // Save generated class to file + + outputLine(sprintf("Saving class to directory\n %s", $classFilename)); + + file_put_contents($classFilename, $phpPrinter->printFile($phpFile)); +} + +/** + * Create code classes + * + * @param array $filesToDownload + * @return void + */ +function createCodeClasses(array $filesToDownload): void +{ + foreach ($filesToDownload as $fileToDownload) { + $classCreatorFunc = $filesToDownload[DOWNLOADDEF_KEY_CLASSCREATORFUNC] ?? DOWNLOADDEF_KEY_CLASSCREATORFUNC_DEFAULT; + $classCreatorFunc($fileToDownload); + } +} + +/* ---------------------------------------------------------------------------------------------------------- + Main + ---------------------------------------------------------------------------------------------------------- */ + +$filesToDownload = [ + [ + DOWNLOADDEF_LIB_NAME => 'zugferd', + DOWNLOADDEF_LIB_TITLE => 'Zugferd', + DOWNLOADDEF_KEY_URL => [ + "https://www.xrepository.de/api/xrepository/urn:xoev-de:kosit:codeliste:untdid.7161_3/download/UNTDID_7161_3.json", + "https://www.xrepository.de/api/xrepository/urn:xoev-de:kosit:codeliste:untdid.5189_3/download/UNTDID_5189_3.json", + ], + DOWNLOADDEF_KEY_TOFILE => [ + PathUtils::combinePathWithFile(PathUtils::combineAllPaths(dirname(__FILE__), "download"), "UNTDID_7161.json"), + PathUtils::combinePathWithFile(PathUtils::combineAllPaths(dirname(__FILE__), "download"), "UNTDID_5189.json"), + ], + DOWNLOADDEF_KEY_URL_HP => "https://www.xrepository.de/details/urn:xoev-de:kosit:codeliste:untdid.7161", + DOWNLOADDEF_KEY_CLASSNAMESPACE => "horstoeko\zugferd\codelists", + DOWNLOADDEF_KEY_CLASSNAME => "ZugferdAllowanceChargeCodes", + DOWNLOADDEF_KEY_TITLE => "list of allowance and charge identification codes", + DOWNLOADDEF_KEY_TITLE_LIST => "UNTDID 7161 Special service description code, UNTDID 5189 Allowance or charge identification code", + DOWNLOADDEF_KEY_SHORTIDENTIFIERS => true, + DOWNLOADDEF_KEY_ADDMETHODS => DOWNLOADDEF_KEY_ADDMETHODS_DEFAULT, + DOWNLOADDEF_KEY_DATA_SORTINDEX => 1, + DOWNLOADDEF_KEY_CLASSCONSTANT_PREFIX => [], + ], + [ + DOWNLOADDEF_LIB_NAME => 'zugferd', + DOWNLOADDEF_LIB_TITLE => 'Zugferd', + DOWNLOADDEF_KEY_URL => [ + "https://www.xrepository.de/api/xrepository/urn:xoev-de:kosit:codeliste:country-codes_8/download/Country_Codes_8.json", + ], + DOWNLOADDEF_KEY_TOFILE => [ + PathUtils::combinePathWithFile(PathUtils::combineAllPaths(dirname(__FILE__), "download"), "ISO_COUNTRY_CODES.json"), + ], + DOWNLOADDEF_KEY_URL_HP => "https://www.xrepository.de/details/urn:xoev-de:kosit:codeliste:country-codes", + DOWNLOADDEF_KEY_CLASSNAMESPACE => "horstoeko\zugferd\codelists", + DOWNLOADDEF_KEY_CLASSNAME => "ZugferdCountryCodes", + DOWNLOADDEF_KEY_TITLE => "list of country codes", + DOWNLOADDEF_KEY_TITLE_LIST => "ISO", + DOWNLOADDEF_KEY_SHORTIDENTIFIERS => true, + DOWNLOADDEF_KEY_ADDMETHODS => DOWNLOADDEF_KEY_ADDMETHODS_DEFAULT, + DOWNLOADDEF_KEY_DATA_CODEINDEX => 0, + DOWNLOADDEF_KEY_DATA_DESCINDEX => 2, + DOWNLOADDEF_KEY_DATA_DESCLONGINDEX => 0, + DOWNLOADDEF_KEY_DATA_SORTINDEX => 2, + DOWNLOADDEF_KEY_CLASSCONSTANT_PREFIX => [], + ], + [ + DOWNLOADDEF_LIB_NAME => 'zugferd', + DOWNLOADDEF_LIB_TITLE => 'Zugferd', + DOWNLOADDEF_KEY_URL => [ + "https://www.xrepository.de/api/xrepository/urn:xoev-de:kosit:codeliste:currency-codes_3/download/Currency_Codes_3.json", + ], + DOWNLOADDEF_KEY_TOFILE => [ + PathUtils::combinePathWithFile(PathUtils::combineAllPaths(dirname(__FILE__), "download"), "ISO_CURRENCY_CODES.json"), + ], + DOWNLOADDEF_KEY_URL_HP => "https://www.xrepository.de/details/urn:xoev-de:kosit:codeliste:currency-codes", + DOWNLOADDEF_KEY_CLASSNAMESPACE => "horstoeko\zugferd\codelists", + DOWNLOADDEF_KEY_CLASSNAME => "ZugferdCurrencyCodes", + DOWNLOADDEF_KEY_TITLE => "list of currency codes", + DOWNLOADDEF_KEY_TITLE_LIST => "ISO", + DOWNLOADDEF_KEY_SHORTIDENTIFIERS => false, + DOWNLOADDEF_KEY_ADDMETHODS => DOWNLOADDEF_KEY_ADDMETHODS_DEFAULT, + DOWNLOADDEF_KEY_DATA_CODEINDEX => 0, + DOWNLOADDEF_KEY_DATA_DESCINDEX => 1, + DOWNLOADDEF_KEY_DATA_DESCLONGINDEX => 1, + DOWNLOADDEF_KEY_DATA_SORTINDEX => 1, + DOWNLOADDEF_KEY_CLASSCONSTANT_PREFIX => [], + ], + [ + DOWNLOADDEF_LIB_NAME => 'zugferd', + DOWNLOADDEF_LIB_TITLE => 'Zugferd', + DOWNLOADDEF_KEY_URL => [ + "https://www.xrepository.de/api/xrepository/urn:xoev-de:kosit:codeliste:untdid.5305_3/download/UNTDID_5305_3.json", + ], + DOWNLOADDEF_KEY_TOFILE => [ + PathUtils::combinePathWithFile(PathUtils::combineAllPaths(dirname(__FILE__), "download"), "UNTDID_5305.json"), + ], + DOWNLOADDEF_KEY_URL_HP => "https://www.xrepository.de/details/urn:xoev-de:kosit:codeliste:untdid.5305", + DOWNLOADDEF_KEY_CLASSNAMESPACE => "horstoeko\zugferd\codelists", + DOWNLOADDEF_KEY_CLASSNAME => "ZugferdDutyTaxFeeCategories", + DOWNLOADDEF_KEY_TITLE => "list of duty or tax or fee category codes", + DOWNLOADDEF_KEY_TITLE_LIST => "UNTDID 5305 Duty or tax or fee category code", + DOWNLOADDEF_KEY_SHORTIDENTIFIERS => false, + DOWNLOADDEF_KEY_ADDMETHODS => DOWNLOADDEF_KEY_ADDMETHODS_DEFAULT, + DOWNLOADDEF_KEY_DATA_CODEINDEX => 0, + DOWNLOADDEF_KEY_DATA_DESCINDEX => 1, + DOWNLOADDEF_KEY_DATA_DESCLONGINDEX => 1, + DOWNLOADDEF_KEY_DATA_SORTINDEX => 1, + DOWNLOADDEF_KEY_CLASSCONSTANT_PREFIX => [], + ], + [ + DOWNLOADDEF_LIB_NAME => 'zugferd', + DOWNLOADDEF_LIB_TITLE => 'Zugferd', + DOWNLOADDEF_KEY_URL => [ + "https://www.xrepository.de/api/xrepository/urn:xoev-de:kosit:codeliste:untdid.1001_4/download/UNTDID_1001_4.json", + ], + DOWNLOADDEF_KEY_TOFILE => [ + PathUtils::combinePathWithFile(PathUtils::combineAllPaths(dirname(__FILE__), "download"), "UNTDID_1001.json"), + ], + DOWNLOADDEF_KEY_URL_HP => "https://www.xrepository.de/details/urn:xoev-de:kosit:codeliste:untdid.1001", + DOWNLOADDEF_KEY_CLASSNAMESPACE => "horstoeko\zugferd\codelists", + DOWNLOADDEF_KEY_CLASSNAME => "ZugferdDocumentType", + DOWNLOADDEF_KEY_TITLE => "list of document name codes", + DOWNLOADDEF_KEY_TITLE_LIST => "UNTDID 1001 Document name code", + DOWNLOADDEF_KEY_SHORTIDENTIFIERS => false, + DOWNLOADDEF_KEY_ADDMETHODS => DOWNLOADDEF_KEY_ADDMETHODS_DEFAULT, + DOWNLOADDEF_KEY_DATA_SORTINDEX => 1, + DOWNLOADDEF_KEY_CLASSCONSTANT_PREFIX => [], + ], + [ + DOWNLOADDEF_LIB_NAME => 'zugferd', + DOWNLOADDEF_LIB_TITLE => 'Zugferd', + DOWNLOADDEF_KEY_URL => [ + "https://www.xrepository.de/api/xrepository/urn:xoev-de:kosit:codeliste:untdid.7143_4/download/UNTDID_7143_4.json", + ], + DOWNLOADDEF_KEY_TOFILE => [ + PathUtils::combinePathWithFile(PathUtils::combineAllPaths(dirname(__FILE__), "download"), "UNTDID_7143.json"), + ], + DOWNLOADDEF_KEY_URL_HP => "https://www.xrepository.de/details/urn:xoev-de:kosit:codeliste:untdid.7143", + DOWNLOADDEF_KEY_CLASSNAMESPACE => "horstoeko\zugferd\codelists", + DOWNLOADDEF_KEY_CLASSNAME => "ZugferdItemTypeIdentificationCodes", + DOWNLOADDEF_KEY_TITLE => "list of item type identification codes", + DOWNLOADDEF_KEY_TITLE_LIST => "UNTDID 7143 Item type identification code", + DOWNLOADDEF_KEY_SHORTIDENTIFIERS => true, + DOWNLOADDEF_KEY_ADDMETHODS => DOWNLOADDEF_KEY_ADDMETHODS_DEFAULT, + DOWNLOADDEF_KEY_DATA_SORTINDEX => 1, + DOWNLOADDEF_KEY_CLASSCONSTANT_PREFIX => [], + ], + [ + DOWNLOADDEF_LIB_NAME => 'zugferd', + DOWNLOADDEF_LIB_TITLE => 'Zugferd', + DOWNLOADDEF_KEY_URL => [ + "https://www.xrepository.de/api/xrepository/urn:xoev-de:xrechnung:codeliste:untdid.4461_3/download/UNTDID_4461_3.json", + ], + DOWNLOADDEF_KEY_TOFILE => [ + PathUtils::combinePathWithFile(PathUtils::combineAllPaths(dirname(__FILE__), "download"), "UNTDID_4461.json"), + ], + DOWNLOADDEF_KEY_URL_HP => "https://www.xrepository.de/details/urn:xoev-de:xrechnung:codeliste:untdid.4461", + DOWNLOADDEF_KEY_CLASSNAMESPACE => "horstoeko\zugferd\codelists", + DOWNLOADDEF_KEY_CLASSNAME => "ZugferdPaymentMeans", + DOWNLOADDEF_KEY_TITLE => "list of payment means codes", + DOWNLOADDEF_KEY_TITLE_LIST => "UNTDID 4461 Payment means code", + DOWNLOADDEF_KEY_SHORTIDENTIFIERS => true, + DOWNLOADDEF_KEY_ADDMETHODS => DOWNLOADDEF_KEY_ADDMETHODS_DEFAULT, + DOWNLOADDEF_KEY_DATA_SORTINDEX => 1, + DOWNLOADDEF_KEY_CLASSCONSTANT_PREFIX => [], + ], + [ + DOWNLOADDEF_LIB_NAME => 'zugferd', + DOWNLOADDEF_LIB_TITLE => 'Zugferd', + DOWNLOADDEF_KEY_URL => [ + "https://www.xrepository.de/api/xrepository/urn:xoev-de:kosit:codeliste:untdid.1153_3/download/UNTDID_1153_3.json", + ], + DOWNLOADDEF_KEY_TOFILE => [ + PathUtils::combinePathWithFile(PathUtils::combineAllPaths(dirname(__FILE__), "download"), "UNTDID_1153.json"), + ], + DOWNLOADDEF_KEY_URL_HP => "https://www.xrepository.de/details/urn:xoev-de:kosit:codeliste:untdid.1153", + DOWNLOADDEF_KEY_CLASSNAMESPACE => "horstoeko\zugferd\codelists", + DOWNLOADDEF_KEY_CLASSNAME => "ZugferdReferenceCodeQualifiers", + DOWNLOADDEF_KEY_TITLE => "list of reference code qualifiers", + DOWNLOADDEF_KEY_TITLE_LIST => "UNTDID 1153 Reference code qualifier", + DOWNLOADDEF_KEY_SHORTIDENTIFIERS => true, + DOWNLOADDEF_KEY_ADDMETHODS => DOWNLOADDEF_KEY_ADDMETHODS_DEFAULT, + DOWNLOADDEF_KEY_DATA_SORTINDEX => 1, + DOWNLOADDEF_KEY_CLASSCONSTANT_PREFIX => [], + ], + [ + DOWNLOADDEF_LIB_NAME => 'zugferd', + DOWNLOADDEF_LIB_TITLE => 'Zugferd', + DOWNLOADDEF_KEY_URL => [ + "https://www.xrepository.de/api/xrepository/urn:xoev-de:kosit:codeliste:untdid.4451_4/download/UNTDID_4451_4.json", + ], + DOWNLOADDEF_KEY_TOFILE => [ + PathUtils::combinePathWithFile(PathUtils::combineAllPaths(dirname(__FILE__), "download"), "UNTDID_4451.json"), + ], + DOWNLOADDEF_KEY_URL_HP => "https://www.xrepository.de/details/urn:xoev-de:kosit:codeliste:untdid.4451", + DOWNLOADDEF_KEY_CLASSNAMESPACE => "horstoeko\zugferd\codelists", + DOWNLOADDEF_KEY_CLASSNAME => "ZugferdTextSubjectCodeQualifiers", + DOWNLOADDEF_KEY_TITLE => "list of text subject code qualifiers", + DOWNLOADDEF_KEY_TITLE_LIST => "UNTDID 4451 Text subject code qualifier", + DOWNLOADDEF_KEY_SHORTIDENTIFIERS => true, + DOWNLOADDEF_KEY_ADDMETHODS => DOWNLOADDEF_KEY_ADDMETHODS_DEFAULT, + DOWNLOADDEF_KEY_DATA_SORTINDEX => 1, + DOWNLOADDEF_KEY_CLASSCONSTANT_PREFIX => [], + ], + [ + DOWNLOADDEF_LIB_NAME => 'zugferd', + DOWNLOADDEF_LIB_TITLE => 'Zugferd', + DOWNLOADDEF_KEY_URL => [ + "https://www.xrepository.de/api/xrepository/urn:xoev-de:kosit:codeliste:icd_5/download/ICD_5.json", + ], + DOWNLOADDEF_KEY_TOFILE => [ + PathUtils::combinePathWithFile(PathUtils::combineAllPaths(dirname(__FILE__), "download"), "ICD_5.json"), + ], + DOWNLOADDEF_KEY_URL_HP => "https://www.xrepository.de/details/urn:xoev-de:kosit:codeliste:icd", + DOWNLOADDEF_KEY_CLASSNAMESPACE => "horstoeko\zugferd\codelists", + DOWNLOADDEF_KEY_CLASSNAME => "ZugferdSchemeIdentifiers", + DOWNLOADDEF_KEY_TITLE => "list of codes for the identification of organizations and organization parts", + DOWNLOADDEF_KEY_TITLE_LIST => "ISO/IEC 17 6523 - Identifier scheme code (ICD)", + DOWNLOADDEF_KEY_SHORTIDENTIFIERS => true, + DOWNLOADDEF_KEY_ADDMETHODS => DOWNLOADDEF_KEY_ADDMETHODS_DEFAULT, + DOWNLOADDEF_KEY_DATA_SORTINDEX => 1, + DOWNLOADDEF_KEY_CLASSCONSTANT_PREFIX => [], + ], + [ + DOWNLOADDEF_LIB_NAME => 'zugferd', + DOWNLOADDEF_LIB_TITLE => 'Zugferd', + DOWNLOADDEF_KEY_URL => [ + "https://www.xrepository.de/api/xrepository/urn:xoev-de:kosit:codeliste:rec20_3/download/UN_ECE_Recommendation_N_20_3.json", + "https://www.xrepository.de/api/xrepository/urn:xoev-de:kosit:codeliste:rec21_3/download/UN_ECE_Recommendation_N_21_3.json", + ], + DOWNLOADDEF_KEY_TOFILE => [ + PathUtils::combinePathWithFile(PathUtils::combineAllPaths(dirname(__FILE__), "download"), "UNECE_REC_20.json"), + PathUtils::combinePathWithFile(PathUtils::combineAllPaths(dirname(__FILE__), "download"), "UNECE_REC_21.json"), + ], + DOWNLOADDEF_KEY_URL_HP => [ + "https://www.xrepository.de/details/urn:xoev-de:kosit:codeliste:rec20", + "https://www.xrepository.de/details/urn:xoev-de:kosit:codeliste:rec21", + ], + DOWNLOADDEF_KEY_CLASSNAMESPACE => "horstoeko\zugferd\codelists", + DOWNLOADDEF_KEY_CLASSNAME => "ZugferdUnitCodes", + DOWNLOADDEF_KEY_TITLE => "list of codes for units of measure used in international trade", + DOWNLOADDEF_KEY_TITLE_LIST => "UN/ECE Recommendation N°20 and N°21", + DOWNLOADDEF_KEY_SHORTIDENTIFIERS => true, + DOWNLOADDEF_KEY_ADDMETHODS => DOWNLOADDEF_KEY_ADDMETHODS_DEFAULT, + DOWNLOADDEF_KEY_DATA_SORTINDEX => 1, + DOWNLOADDEF_KEY_CLASSCONSTANT_PREFIX => ["REC20_", "REC21_"], + ], +]; + +outputLine("\n\nCodelist Generator v1.0\n----------------------------------------\n"); + +downloadLists($filesToDownload); +createCodeClasses($filesToDownload); + +outputLine("\n");