Dynamics365
Es ist möglich vor der Übergabe an Dynamics365 weitere Felder hinzuzufügen oder Werte anzupassen.
Hier ein Beispiel um den Netto und Steuerbetrag hinzuzufügen:
<?php
use Squeeze\SqueezeAmount;
use Squeeze\xDoc;
function BeforeDynamics365HeaderExport(xDoc $doc, array $fieldList)
{
// ============================================
// fieldList is an array of fields with the
// following attributes
//
// fieldList[]['name'] = Squeeze field name
// fieldList[]['externalName'] = Squeeze field external name
// fieldList[]['type'] = Squeeze field type (Text, Amount, Date)
// fieldList[]['value'] = Squeeze field value
//
// ============================================
//$logger = Logger::getLogger("main");
$netAmount = $doc->getFieldByName('NetAmount');
if($netAmount == null) {
throw new \Exception('Field NetAmount does not exist.');
}
$fieldList['CustomNetAmount']['name'] = 'NetAmount';
$fieldList['CustomNetAmount']['externalName'] = 'InvoiceAmountExcludingTaxCC';
$fieldList['CustomNetAmount']['type'] = 'Amount';
$fieldList['CustomNetAmount']['value'] = SqueezeAmount::formatAndCalc($netAmount->getValue()->value);
$taxAmount = $doc->getFieldByName('TaxAmount');
if($taxAmount == null) {
throw new \Exception('Field TaxAmount does not exist.');
}
$fieldList['CustomTaxAmount']['name'] = 'TaxAmount';
$fieldList['CustomTaxAmount']['externalName'] = 'TaxAmountCC';
$fieldList['CustomTaxAmount']['type'] = 'Amount';
$fieldList['CustomTaxAmount']['value'] = SqueezeAmount::formatAndCalc($taxAmount->getValue()->value);
return new \Squeeze\xReturnObject(true, 200, 'UserExit BeforeDynamics365HeaderExport successful', $fieldList);
}
No Comments