Workday

Vor der Übertragung eines Beleges an einen Workday ERP Tenant ist es möglich Werte anzupassen oder zu ergänzen. 
 Hier ein Beispiel: 
 <?php

use Squeeze\xDoc;
use Squeeze\xReturnObject;

// vor Squeeze 2.5: BeforeExportWorkday statt BeforeWorkdayExport
function BeforeWorkdayExport(xDoc $doc, array $workdayDoc): xReturnObject
{ 
 // This UserExit allows to modify the 
 // Workday data structure right before the document is submitted.

 try {
 $logger = Logger::getLogger("main");
 
 if (isset($workdayDoc['Supplier_Invoice_Data'])) {
 $isInvoice = true;
 $rootTag = 'Supplier_Invoice_Data';
 } else {
 $isInvoice = false;
 $rootTag = 'Supplier_Invoice_Adjustment_Data';
 }

 if ($isInvoice) {
 $workdayDoc[$rootTag]['Adjustment_Reason_Reference']['ID']['_'] = 'Other';
 }

 // Remove Accounting_Date_Override (PostingDate)
 unset($workdayDoc[$rootTag]['Accounting_Date_Override']);
 
 // =================================================
 // iterate over every line item of the document
 // =================================================
 for($i = 0; $i < count($workdayDoc[$rootTag]['Invoice_Line_Replacement_Data']); $i++) {
 
 // =================================================
 // Check if Tax Option is set
 // this means it's a reverse charge line item
 // =================================================
 if (isset($workdayDoc[$rootTag]['Invoice_Line_Replacement_Data'][$i]['Tax_Rate_Options_Data']['Tax_Option_1_Reference']['ID'])) {
 
 // If the Tax Option is set also set the Tax Recoverability
 $workdayDoc[$rootTag]['Invoice_Line_Replacement_Data'][$i]['Tax_Rate_Options_Data']['Tax_Recoverability_1_Reference']['ID'] = array('_' => '100%_Fully Recoverable', 'type' => 'Tax_Recoverability_Object_ID');
 $logger->debug('Tax Option is set. Set Tax Recoverability to 100%_Fully Recoverable');
 }
 }

 return new xReturnObject(true, 200, 'UserExit BeforeExportWorkday successful', $workdayDoc);

 } catch (Exception $e) {
 $logger = Logger::getLogger("main");
 $logger->error($e->getMessage());
 return new xReturnObject(false, 500, $e->getMessage(), $workdayDoc);
 }
}