Skip to content

Commit

Permalink
Support business operation currency
Browse files Browse the repository at this point in the history
  • Loading branch information
TatianaFomina committed Nov 10, 2024
1 parent 35961c2 commit bd98e5e
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 10 deletions.
5 changes: 4 additions & 1 deletion schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -762,8 +762,11 @@ type PayloadOfWorkspacePlanPurchase {
"""Workspace to which the payment is debited"""
workspace: Workspace!

"""Amount of payment in US cents"""
"""Amount of payment * 100 """
amount: Long!

"""Currency of payment"""
currency: String!
}

"""Input for single payment"""
Expand Down
1 change: 1 addition & 0 deletions src/api/billing/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export const FRAGMENT_BUSINESS_OPERATION = `
name
}
amount
currency
}
}
}
Expand Down
6 changes: 5 additions & 1 deletion src/components/utils/billing/History.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
/>
</div>
<div class="billing-history__amount">
{{ operation.payload.amount | centsToDollars }}$
{{ getAmountString(operation.payload.amount, operation.payload.currency) }}
</div>
<div class="billing-history__description">
{{ getDescription(operation) }}
Expand Down Expand Up @@ -57,6 +57,7 @@ import EntityImage from './../EntityImage.vue';
import { BusinessOperationType } from '@/types/business-operation-type';
import i18n from './../../../i18n';
import { BusinessOperation, PayloadOfWorkspacePlanPurchase } from '@/types/business-operation';
import { getCurrencySign } from '@/utils';
export default Vue.extend({
name: 'BillingHistory',
Expand Down Expand Up @@ -101,6 +102,9 @@ export default Vue.extend({
},
},
methods: {
getAmountString(amount: number, currency: string): string {
return (amount / 100) + getCurrencySign(currency);
},
/**
* Get a status key to show it on the page
*
Expand Down
10 changes: 2 additions & 8 deletions src/components/workspace/settings/BillingOverview.vue
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ import PositiveButton from '../../utils/PostivieButton.vue';
import notifier from 'codex-notifier';
import { CANCEL_SUBSCRIPTION } from '../../../store/modules/workspaces/actionTypes';
import { FETCH_PLANS } from '../../../store/modules/plans/actionTypes';
import { getCurrencySign } from '@/utils';
/**
* Const value for the whole project
Expand Down Expand Up @@ -222,14 +223,7 @@ export default Vue.extend({
* Return currency sign depending on plan currency
*/
planCurrencySign(): string {
switch (this.plan.monthlyChargeCurrency) {
case 'USD':
return '$';
case 'RUB':
return '';
default:
return '';
}
return getCurrencySign(this.plan.monthlyChargeCurrency);
},
/**
* Total number of errors since the last charge date
Expand Down
11 changes: 11 additions & 0 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,17 @@ import mergeWith from 'lodash.mergewith';
import cloneDeep from 'lodash.clonedeep';
import { HawkEventDailyInfo, HawkEventPayload, HawkEventRepetition } from './types/events';

export function getCurrencySign(currency: string): string {
switch (currency) {
case 'USD':
return '$';
case 'RUB':
return '₽';
default:
return '';
}
}

/**
* Returns entity color from predefined list
*
Expand Down

0 comments on commit bd98e5e

Please sign in to comment.