Skip to content

Purchasing Transaction Create (setExchangeRateValue) #188

@brunoda6

Description

@brunoda6

Hi,

Im trying to create a po from a pr. This pr has Custom exchange rate Type ("Custom") so i set the setExchangeRateValue with the value in float but i get a error saying that is empty i printed the object before send it and the value it's there but i keep receiving the error saying that the exchange rate is empty.

heres a snippet of my code:

$pt = new PurchasingTransactionCreate();
$pt->setTransactionDate($transactionDate);
$pt->setTransactionDefinition($entidade['e_transaction_definition']);
$pt->setCreatedFrom($pr['DOCID']);
$pt->setRecordNo($pt->getControlId());
//$pt->setDocumentNumber($pr['DOCNO']);
$pt->setVendorId($pr['CUSTVENDID']??'');
$pt->setVendorDocNumber($pr['VENDORDOCNO']);
$pt->setOriginalDocumentDate(DateTime::createFromFormat('d/m/Y', $pr['WHENCREATED']));
$pt->setDueDate(DateTime::createFromFormat('d/m/Y', $pr['WHENDUE']));
$pt->setMessage($pr['MESSAGE']??'');
$pt->setBaseCurrency($pr['BASECURR']);
$pt->setTransactionCurrency($pr['CURRENCY']);
$pt->setExchangeRateDate(DateTime::createFromFormat('d/m/Y', $pr['EXCHRATEDATE']));
$pt->setExchangeRateType($pr['EXCHRATETYPES.NAME']??'');
if($pr['EXCHRATETYPES.NAME'] == "Custom"){
$pt->setExchangeRateValue((float)$pr["EXCHRATE"]);
}
$pt->setState('Pending');
$pt->setLines($objLines);
$pt->setReturnToContactName($pr['SHIPTO.CONTACTNAME']??'');
$pt->setPayToContactName($pr['CONTACT.CONTACTNAME']??'');
$pt->setShippingMethod($pr['SHIPVIA']??'');
$pt->setReferenceNumber($pr['PONUMBER']??'');
$pt->setPaymentTerm($pr['TERM.NAME']??'');
$clientEntity = $this->clientEntity($pr['MEGAENTITYID']);

        if($clientEntity){
            $response = $clientEntity->execute($pt);
        }

The error is: PL03000004 Exchange rate is empty.

Note: In the sandbox panel i can convert successfully
Can someone tell me if the problem is on my end?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions