Skip to content

Commit

Permalink
Removed is_writable in ZugferdDocumentReader::setBinaryDataDirectory
Browse files Browse the repository at this point in the history
  • Loading branch information
HorstOeko committed Oct 3, 2023
1 parent b5e8565 commit 1d8899c
Showing 1 changed file with 48 additions and 49 deletions.
97 changes: 48 additions & 49 deletions src/ZugferdDocumentReader.php
Original file line number Diff line number Diff line change
Expand Up @@ -204,10 +204,8 @@ class ZugferdDocumentReader extends ZugferdDocument
*/
public function setBinaryDataDirectory(string $binarydatadirectory): ZugferdDocumentReader
{
$this->binarydatadirectory = "";

if ($binarydatadirectory) {
if (is_dir($binarydatadirectory) && is_writable($binarydatadirectory)) {
if (is_dir($binarydatadirectory)) {
$this->binarydatadirectory = $binarydatadirectory;
}
}
Expand Down Expand Up @@ -440,9 +438,9 @@ public function getDocumentNotes(?array &$notes): ZugferdDocumentReader
$notes = $this->convertToArray(
$notes,
[
"contentcode" => ["getContentCode.value", ""],
"subjectcode" => ["getSubjectCode.value", ""],
"content" => ["getContent.value", ""],
"contentcode" => ["getContentCode.value", ""],
"subjectcode" => ["getSubjectCode.value", ""],
"content" => ["getContent.value", ""],
]
);

Expand Down Expand Up @@ -2477,7 +2475,8 @@ public function getDocumentAdditionalReferencedDocument(?string &$issuerassigned
);
$binarydatafilename = $this->getInvoiceValueByPathFrom($addRefDoc, "getAttachmentBinaryObject.getFilename", "");
$binarydata = $this->getInvoiceValueByPathFrom($addRefDoc, "getAttachmentBinaryObject.value", "");
if (StringUtils::stringIsNullOrEmpty($binarydatafilename) === false
if (
StringUtils::stringIsNullOrEmpty($binarydatafilename) === false
&& StringUtils::stringIsNullOrEmpty($binarydata) === false
&& StringUtils::stringIsNullOrEmpty($this->binarydatadirectory) === false
) {
Expand All @@ -2504,12 +2503,12 @@ public function getDocumentAdditionalReferencedDocuments(?array &$refdocs): Zugf
$refdocs = $this->convertToArray(
$refdocs,
[
"IssuerAssignedID" => ["getIssuerAssignedID.value", ""],
"URIID" => ["getURIID.value", ""],
"LineID" => ["getLineID.value", ""],
"TypeCode" => ["getTypeCode.value", ""],
"ReferenceTypeCode" => ["getReferenceTypeCode.value", ""],
"FormattedIssueDateTime" => ["getFormattedIssueDateTime.getDateTimeString.value", ""],
"IssuerAssignedID" => ["getIssuerAssignedID.value", ""],
"URIID" => ["getURIID.value", ""],
"LineID" => ["getLineID.value", ""],
"TypeCode" => ["getTypeCode.value", ""],
"ReferenceTypeCode" => ["getReferenceTypeCode.value", ""],
"FormattedIssueDateTime" => ["getFormattedIssueDateTime.getDateTimeString.value", ""],
]
);

Expand Down Expand Up @@ -2945,30 +2944,30 @@ public function getDocumentAllowanceCharges(?array &$allowanceCharge): ZugferdDo
$allowanceCharge = $this->convertToArray(
$allowanceCharge,
[
"chargeindicator" => ["getChargeIndicator.getIndicator", false],
"sequencenumeric" => ["getSequenceNumeric.value", 0],
"calculationpercent" => ["getCalculationPercent.value", 0.0],
"basisamount" => ["getBasisAmount.value", 0.0],
"basisquantity" => ["getBasisQuantity.value", 0.0],
"actualAmount" => ["getActualAmount.value", 0.0],
"reasoncode" => ["getReasonCode.value", ""],
"reason" => ["getReason.value", ""],
"taxcalculatedamount" => ["getCategoryTradeTax.getCalculatedAmount.value", 0.0],
"taxtypecode" => ["getCategoryTradeTax.getTypeCode.value", ""],
"taxexemptionreason" => ["getCategoryTradeTax.getExemptionReason.value", ""],
"taxbasisamount" => ["getCategoryTradeTax.getBasisAmount.value", 0.0],
"taxlinetotalbasisamount" => ["getCategoryTradeTax.getLineTotalBasisAmount.value", 0.0],
"taxallowancechargebasisamount" => ["getCategoryTradeTax.getAllowanceChargeBasisAmount.value", 0.0],
"taxcategorycode" => ["getCategoryTradeTax.getCategoryCode.value", ""],
"taxexemptionreasoncode" => ["getCategoryTradeTax.getExemptionReasonCode.value", ""],
"taxpointdate" => function ($item) {
return $this->objectHelper->toDateTime(
$this->objectHelper->tryCallByPathAndReturn($item, "getCategoryTradeTax.getTaxPointDate.getDateString.value"),
$this->objectHelper->tryCallByPathAndReturn($item, "getCategoryTradeTax.getTaxPointDate.getDateString.getFormat")
);
},
"taxduedatetypecode" => ["getCategoryTradeTax.getDueDateTypeCode.value", ""],
"taxrateapplicablepercent" => ["getCategoryTradeTax.getRateApplicablePercent.value", 0.0],
"chargeindicator" => ["getChargeIndicator.getIndicator", false],
"sequencenumeric" => ["getSequenceNumeric.value", 0],
"calculationpercent" => ["getCalculationPercent.value", 0.0],
"basisamount" => ["getBasisAmount.value", 0.0],
"basisquantity" => ["getBasisQuantity.value", 0.0],
"actualAmount" => ["getActualAmount.value", 0.0],
"reasoncode" => ["getReasonCode.value", ""],
"reason" => ["getReason.value", ""],
"taxcalculatedamount" => ["getCategoryTradeTax.getCalculatedAmount.value", 0.0],
"taxtypecode" => ["getCategoryTradeTax.getTypeCode.value", ""],
"taxexemptionreason" => ["getCategoryTradeTax.getExemptionReason.value", ""],
"taxbasisamount" => ["getCategoryTradeTax.getBasisAmount.value", 0.0],
"taxlinetotalbasisamount" => ["getCategoryTradeTax.getLineTotalBasisAmount.value", 0.0],
"taxallowancechargebasisamount" => ["getCategoryTradeTax.getAllowanceChargeBasisAmount.value", 0.0],
"taxcategorycode" => ["getCategoryTradeTax.getCategoryCode.value", ""],
"taxexemptionreasoncode" => ["getCategoryTradeTax.getExemptionReasonCode.value", ""],
"taxpointdate" => function ($item) {
return $this->objectHelper->toDateTime(
$this->objectHelper->tryCallByPathAndReturn($item, "getCategoryTradeTax.getTaxPointDate.getDateString.value"),
$this->objectHelper->tryCallByPathAndReturn($item, "getCategoryTradeTax.getTaxPointDate.getDateString.getFormat")
);
},
"taxduedatetypecode" => ["getCategoryTradeTax.getDueDateTypeCode.value", ""],
"taxrateapplicablepercent" => ["getCategoryTradeTax.getRateApplicablePercent.value", 0.0],
]
);

Expand Down Expand Up @@ -3187,19 +3186,19 @@ public function getDocumentLogisticsServiceCharge(?string &$description, ?float
$taxTypeCodes = $this->convertToArray(
$appliedTradeTax,
[
"typecode" => ["getTypeCode.value", ""],
"typecode" => ["getTypeCode.value", ""],
]
);
$taxCategpryCodes = $this->convertToArray(
$appliedTradeTax,
[
"categorycode" => ["getCategoryCode.value", ""],
"categorycode" => ["getCategoryCode.value", ""],
]
);
$rateApplicablePercents = $this->convertToArray(
$appliedTradeTax,
[
"percent" => ["getRateApplicablePercent.value", 0.0],
"percent" => ["getRateApplicablePercent.value", 0.0],
]
);

Expand All @@ -3218,15 +3217,15 @@ public function getDocumentPaymentTerms(?array &$paymentTerms): ZugferdDocumentR
$paymentTerms = $this->convertToArray(
$paymentTerms,
[
"description" => ["getDescription.value", ""],
"duedate" => function ($item) {
return $this->objectHelper->toDateTime(
$this->objectHelper->tryCallByPathAndReturn($item, "getDueDateDateTime.getDateTimeString.value"),
$this->objectHelper->tryCallByPathAndReturn($item, "getDueDateDateTime.getDateTimeString.getFormat")
);
},
"directdebitmandateid" => ["getDirectDebitMandateID.value", ""],
"partialpaymentamount" => ["getPartialPaymentAmount.value", 0.0],
"description" => ["getDescription.value", ""],
"duedate" => function ($item) {
return $this->objectHelper->toDateTime(
$this->objectHelper->tryCallByPathAndReturn($item, "getDueDateDateTime.getDateTimeString.value"),
$this->objectHelper->tryCallByPathAndReturn($item, "getDueDateDateTime.getDateTimeString.getFormat")
);
},
"directdebitmandateid" => ["getDirectDebitMandateID.value", ""],
"partialpaymentamount" => ["getPartialPaymentAmount.value", 0.0],
]
);

Expand Down

0 comments on commit 1d8899c

Please sign in to comment.