Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix exchange rate issue with automated invoicing in qbo #1325

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,8 @@
"wpackagist-theme/twentyten": "*",
"wpackagist-theme/twentytwentytwo": "*",
"wpackagist-theme/twentytwentythree": "*",
"wpackagist-theme/twentytwentyfour": "*"
"wpackagist-theme/twentytwentyfour": "*",
"quickbooks/v3-php-sdk": "*"
},
"scripts": {
"format": "phpcbf -p",
Expand Down
121 changes: 90 additions & 31 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions public_html/wp-content/plugins/wordcamp-qbo/wordcamp-qbo.php
Original file line number Diff line number Diff line change
Expand Up @@ -493,9 +493,31 @@ protected static function build_qbo_create_invoice_request( int $invoice_id ) {
* for the first time, so we don't need any code to automatically activate them.
*/
if ( 'USD' != $currency_code ) {
$response = wp_remote_get(
sprintf(
'%s/v3/company/%d/exchangerate?sourcecurrencycode=%s',
self::$api_base_url,
rawurlencode( $realm_id ),
$currency_code,
),
array(
'timeout' => self::REMOTE_REQUEST_TIMEOUT,
'headers' => array(
'Authorization' => $oauth_header,
'Accept' => 'application/json',
'Content-Type' => 'application/json',
),
)
);

$body = json_decode( wp_remote_retrieve_body( $response ), true );
$exchange_rate = $body['ExchangeRate']['Rate'];
pkevan marked this conversation as resolved.
Show resolved Hide resolved

$payload['CurrencyRef'] = array(
'value' => $currency_code,
);

$payload['ExchangeRate'] = $exchange_rate;
}

$request_url = sprintf(
Expand Down
Loading