Skip to content
This repository has been archived by the owner on Mar 4, 2019. It is now read-only.

Commit

Permalink
Merge pull request #801 from opencollective/fixInvoicePDF
Browse files Browse the repository at this point in the history
use the proper address from the host
  • Loading branch information
xdamman authored May 15, 2018
2 parents deeaa6e + c19c769 commit 1c3a6a2
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions frontend/src/components/Invoice.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ export default class Invoice extends Component {
const collective = transaction.type === 'CREDIT'
? transaction.collective
: transaction.fromCollective;
const fromCollective = transaction.type === 'CREDIT'
? transaction.fromCollective
: transaction.collective;

const localeDateFormat = (collective.currency === 'USD') ? 'en' : 'fr';
i18n.moment.locale(localeDateFormat);
Expand All @@ -49,8 +52,17 @@ export default class Invoice extends Component {
amount: <Currency value={amount} currency={transaction.currency} />
});

const hostBillingAddress = { __html : (transaction.host.billingAddress || '').replace(/\n/g,'<br />') };
const userBillingAddress = { __html : (transaction.createdByUser.billingAddress || '').replace(/\n/g,'<br />') };
let hostAddress = '';
if (transaction.host.locationName) {
hostAddress = `${transaction.host.locationName}\n`;
}
const hostBillingAddress = { __html : `${hostAddress}${transaction.host.address || ''}`.replace(/\n/g,'<br />') };

let userAddress = '';
if (fromCollective.locationName) {
userAddress = `${fromCollective.address}\n`;
}
const userBillingAddress = { __html : (transaction.createdByUser.billingAddress || userAddress || '').replace(/\n/g,'<br />') };
const styles = getGroupCustomStyles(collective);

// We need to load images in absolute path for PhantomJS
Expand Down Expand Up @@ -101,7 +113,7 @@ export default class Invoice extends Component {
</div>
<div className="userBillingAddress">
<h2>{i18n.getString('billTo')}:</h2>
{transaction.collective.name}<br />
{fromCollective.name}<br />
<div dangerouslySetInnerHTML={userBillingAddress} />
</div>
</div>
Expand Down

0 comments on commit 1c3a6a2

Please sign in to comment.