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

Commit

Permalink
Merge pull request #1727 from OpenBazaar/fixCaseCryptoQuantity
Browse files Browse the repository at this point in the history
Fix case crypto quantity
  • Loading branch information
rmisio authored Mar 25, 2019
2 parents 534d9ad + e88f522 commit f1d0415
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions js/models/order/Case.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,14 @@ export default class extends BaseOrder {
return false;
}

convertCryptoQuantity(contract = {}) {
convertQuantity(contract = {}) {
contract.buyerOrder.items.forEach((item, index) => {
const listing = contract.vendorListings[index];

// standardize the quantity field
item.quantity = item.quantity === 0 ?
item.quantity64 : item.quantity;

if (listing.metadata.contractType === 'CRYPTOCURRENCY') {
const coinDivisibility = listing.metadata
.coinDivisibility;
Expand Down Expand Up @@ -120,7 +124,7 @@ export default class extends BaseOrder {
integerToDecimal(response.buyerContract.buyerOrder.payment.amount,
paymentCoin);

response.buyerContract = this.convertCryptoQuantity(response.buyerContract);
response.buyerContract = this.convertQuantity(response.buyerContract);
}

if (response.vendorContract) {
Expand All @@ -133,6 +137,8 @@ export default class extends BaseOrder {
response.vendorContract.buyerOrder.payment.amount =
integerToDecimal(response.vendorContract.buyerOrder.payment.amount,
paymentCoin);

response.vendorContract = this.convertQuantity(response.vendorContract);
}

if (response.resolution) {
Expand Down

0 comments on commit f1d0415

Please sign in to comment.