Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import type { CostReportConfigUpdateParameters } from '@/api-clients/cost-analys
import { useServiceQueryKey } from '@/query/query-key/use-service-query-key';
import { i18n } from '@/translations';

import { CURRENCY, CURRENCY_SYMBOL } from '@/store/display/constant';
import type { Currency } from '@/store/display/type';
import { languages } from '@/store/user/constant';
import type { LanguageCode } from '@/store/user/type';

Expand All @@ -45,6 +47,7 @@ const queryClient = useQueryClient();
const state = reactive({
// Base Settings
selectedLanguage: undefined as LanguageCode | undefined,
selectedCurrency: undefined as Currency | undefined,
lastDayOfMonth: false,
// Auto Apply Adjustments
enableAdjustments: false as boolean,
Expand All @@ -60,6 +63,7 @@ const isSaveDisabled = computed<boolean>(() => {
if (!costReportConfig.value?.cost_report_config_id) return true;
return !isAllValid.value;
});
const currencyMenuList = Object.values(CURRENCY).map((currency) => ({ label: `${CURRENCY_SYMBOL[currency]} ${currency}`, name: currency }));

const {
forms: {
Expand Down Expand Up @@ -130,6 +134,7 @@ const handleSave = () => {
enabled: state.enableAdjustments,
period: manualAdjustablePeriod.value,
},
currency: state.selectedCurrency,
});
};

Expand All @@ -147,6 +152,7 @@ const handleOpenAdjustmentsOverlay = () => {
watch(() => costReportConfig.value, (val) => {
if (val) {
state.selectedLanguage = val.language;
state.selectedCurrency = val.currency;
setForm('issueDate', val.issue_day);
if (!val.is_last_day) {
setForm('issueDate', val.issue_day);
Expand Down Expand Up @@ -179,6 +185,16 @@ watch(() => costReportConfig.value, (val) => {
/>
</p-field-group>

<p-field-group :label="$t('COST_EXPLORER.ADVANCED_SETTINGS.COST_REPORT_CURRENCY')"
required
>
<p-select-dropdown
:menu="currencyMenuList"
:selected.sync="state.selectedCurrency"
class="w-48"
/>
</p-field-group>

<p-field-group :label="$t('COST_EXPLORER.ADVANCED_SETTINGS.ISSUE_DATE')"
required
:invalid="invalidState.issueDate"
Expand Down Expand Up @@ -255,6 +271,7 @@ watch(() => costReportConfig.value, (val) => {
<p-button style-type="tertiary"
icon-left="ic_settings"
class="mt-4"
:disabled="!state.enableAdjustments"
@click="handleOpenAdjustmentsOverlay"
>
{{ $t('COST_EXPLORER.ADVANCED_SETTINGS.SET_ADJUSTMENTS') }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ watch(() => state.originUnifiedCostConfig, (unifiedCostConfig) => {
>
{{ $t('COST_EXPLORER.CURRENCY_CONVERTER_PAGE.NOTIFICATION') }}
</p-scoped-notification>
<p-field-group :label="$t('COMMON.GNB.ACCOUNT.LABEL_CURRENCY')"
<p-field-group :label="$t('COST_EXPLORER.CURRENCY_CONVERTER_PAGE.COST_ANALYSIS_CURRENCY')"
required
>
<p-select-dropdown class="currency-dropdown"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<script setup lang="ts">
import { computed, reactive, watch } from 'vue';
import {
computed, reactive, watch,
} from 'vue';

import { useQueryClient } from '@tanstack/vue-query';

Expand Down Expand Up @@ -51,6 +53,7 @@ const { key: raQueryKey } = useServiceQueryKey('cost-analysis', 'report-adjustme

const state = reactive({
loading: false,
createdPolicyIdMap: new Map<string, string>(), // Map to store new policy IDs
});
const workspaceReferenceMap = computed<WorkspaceReferenceMap>(() => allReferenceStore.getters.workspace);
const isAllValid = computed<boolean>(() => advancedSettingsPageStore.isAdjustmentPolicyValid && advancedSettingsPageStore.isAdjustmentValid);
Expand Down Expand Up @@ -123,13 +126,14 @@ const deleteAdjustmentPolicy = async (): Promise<string[]> => {
return deletedPolicyIds;
};
const createAdjustmentPolicy = async (policy: AdjustmentPolicyData, idx: number) => {
await reportAdjustmentPolicyAPI.create({
const createdPolicy = await reportAdjustmentPolicyAPI.create({
cost_report_config_id: costReportConfigId.value,
policy_filter: {
workspace_ids: policy.workspaceMenuItems?.map((item) => item.name) || [],
},
order: idx + 1,
});
state.createdPolicyIdMap.set(policy.id, createdPolicy.report_adjustment_policy_id);
};
const updateAdjustmentPolicy = async (policy: AdjustmentPolicyData, idx: number) => {
const oldPolicy = originalPolicies.value.find((p) => p.report_adjustment_policy_id === policy.id);
Expand Down Expand Up @@ -168,14 +172,16 @@ const deleteAdjustment = async (deletedPolicyIds: string[]) => {
});
};
const createAdjustment = async (adjustment: AdjustmentData, idx: number) => {
const createdPolicyId = state.createdPolicyIdMap.get(adjustment.policyId) || adjustment.policyId;
await reportAdjustmentAPI.create({
report_adjustment_policy_id: adjustment.policyId,
report_adjustment_policy_id: createdPolicyId,
name: adjustment.name,
provider: adjustment.provider,
unit: adjustment.adjustment.includes('PERCENT') ? 'PERCENT' : 'FIXED',
value: adjustment.adjustment.includes('DEDUCTION') ? -adjustment.amount : adjustment.amount,
description: adjustment.description,
order: idx + 1,
currency: costReportConfig.value?.currency,
});
};
const updateAdjustment = async (adjustment: AdjustmentData, idx: number) => {
Expand Down Expand Up @@ -267,7 +273,10 @@ watch([
() => isReportAdjustmentLoading.value,
() => isReportAdjustmentPolicyLoading.value,
], ([visible, _isReportAdjustmentLoading, _isReportAdjustmentPolicyLoading]) => {
if (visible && !_isReportAdjustmentLoading && !_isReportAdjustmentPolicyLoading) initForm();
if (visible && !_isReportAdjustmentLoading && !_isReportAdjustmentPolicyLoading) {
state.createdPolicyIdMap.clear();
initForm();
}
});
</script>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
import { useCostReportConfigApi } from '@/api-clients/cost-analysis/cost-report-config/composables/use-cost-report-config-api';
import { i18n } from '@/translations';

import { useAppContextStore } from '@/store/app-context/app-context-store';
import { languages } from '@/store/user/constant';

import { showSuccessMessage } from '@/lib/helper/notice-alert-helper';
Expand All @@ -23,7 +24,9 @@ import { getUpcomingIssueDate, getUpcomingConfirmationDate } from '@/services/co

const { costReportConfig, isLoading: isCostReportConfigLoading } = useCostReportConfigQuery();
const { costReportConfigAPI } = useCostReportConfigApi();
const appContextStore = useAppContextStore();

const isAdminMode = computed<boolean>(() => appContextStore.getters.isAdminMode);
const issueDate = computed<number|undefined>(() => costReportConfig.value?.issue_day);
const lastDayOfMonth = computed<boolean>(() => costReportConfig.value?.is_last_day || false);
const enableAdjustments = computed<boolean>(() => costReportConfig.value?.adjustment_options?.enabled || false);
Expand All @@ -44,6 +47,7 @@ const reportDateRange = computed<string>(() => {
return `${startOfNextMonth.format('YYYY-MM-DD')} ~ ${endOfNextMonth.format('YYYY-MM-DD')}`;
});
const showReissueButton = computed<boolean>(() => {
if (!isAdminMode.value) return false;
if (!upcomingReportDate.value || !confirmationDate.value) return false;
const todayDay = dayjs.utc().date();
const issueDay = dayjs(upcomingReportDate.value).date();
Expand Down
42 changes: 42 additions & 0 deletions packages/language-pack/console-translation-2.8.babel
Original file line number Diff line number Diff line change
Expand Up @@ -38970,6 +38970,27 @@
</translation>
</translations>
</concept_node>
<concept_node>
<name>COST_REPORT_CURRENCY</name>
<definition_loaded>false</definition_loaded>
<description/>
<comment/>
<default_text/>
<translations>
<translation>
<language>en-US</language>
<approved>false</approved>
</translation>
<translation>
<language>ja-JP</language>
<approved>false</approved>
</translation>
<translation>
<language>ko-KR</language>
<approved>false</approved>
</translation>
</translations>
</concept_node>
<concept_node>
<name>CURRENCY_CONVERTER</name>
<definition_loaded>false</definition_loaded>
Expand Down Expand Up @@ -39788,6 +39809,27 @@
</translation>
</translations>
</concept_node>
<concept_node>
<name>COST_ANALYSIS_CURRENCY</name>
<definition_loaded>false</definition_loaded>
<description/>
<comment/>
<default_text/>
<translations>
<translation>
<language>en-US</language>
<approved>false</approved>
</translation>
<translation>
<language>ja-JP</language>
<approved>false</approved>
</translation>
<translation>
<language>ko-KR</language>
<approved>false</approved>
</translation>
</translations>
</concept_node>
<concept_node>
<name>CURRENCY_CONVERTER</name>
<definition_loaded>false</definition_loaded>
Expand Down
2 changes: 2 additions & 0 deletions packages/language-pack/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -2127,6 +2127,7 @@
"CONFIRM_DATE_EXCEEDS_MONTH_END": "The confirmation date cannot exceed the last day of the month.",
"COST_REPORT_ADJUSTMENTS": "Cost Report Adjustments",
"COST_REPORT_CONFIGURATION": "Cost Report Configuration",
"COST_REPORT_CURRENCY": "Cost Report Currency",
"CURRENCY_CONVERTER": "Currency Converter",
"DAYS_AFTER_REPORT": "Days After Report Issuance",
"DESCRIPTION": "Description",
Expand Down Expand Up @@ -2173,6 +2174,7 @@
"CURRENCY_CONVERTER": "Currency Converter",
"CURRENCY_CONVERTER_PAGE": {
"AGGREGATION_DATE": "Aggregation Date",
"COST_ANALYSIS_CURRENCY": "Cost Analysis Currency",
"CURRENCY_CONVERTER": "Currency Converter",
"EXCHANGE_RATE_SOURCE": "Exchange Rate Source",
"LAST_DAY_OF_THE_MONTH": "Last day of the month",
Expand Down
2 changes: 2 additions & 0 deletions packages/language-pack/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -2127,6 +2127,7 @@
"CONFIRM_DATE_EXCEEDS_MONTH_END": "確定日はその月の最終日を超えることはできません。",
"COST_REPORT_ADJUSTMENTS": "コストレポート調整",
"COST_REPORT_CONFIGURATION": "コストレポート設定",
"COST_REPORT_CURRENCY": "コストレポート通貨",
"CURRENCY_CONVERTER": "為替レート設定",
"DAYS_AFTER_REPORT": "日 (レポート発行日後)",
"DESCRIPTION": "説明",
Expand Down Expand Up @@ -2173,6 +2174,7 @@
"CURRENCY_CONVERTER": "為替レート設定",
"CURRENCY_CONVERTER_PAGE": {
"AGGREGATION_DATE": "集計日",
"COST_ANALYSIS_CURRENCY": "コスト分析通貨",
"CURRENCY_CONVERTER": "為替レート設定",
"EXCHANGE_RATE_SOURCE": "為替基準",
"LAST_DAY_OF_THE_MONTH": "月末",
Expand Down
4 changes: 3 additions & 1 deletion packages/language-pack/ko.json
Original file line number Diff line number Diff line change
Expand Up @@ -930,7 +930,7 @@
"EMAIL_INVALID": "잘못된 이메일 형식입니다.",
"GREATER_THAN_OR_EQUAL_TO_1": "1 이상으로 설정해주세요.",
"HIDE": "숨기기",
"ISSUE_DATE": "발행일자 ",
"ISSUE_DATE": "발행일",
"ISSUE_DAY": "발행일(매월)",
"LANGUAGE": "언어",
"LAST_12_MONTHS": "최근 12개월",
Expand Down Expand Up @@ -2127,6 +2127,7 @@
"CONFIRM_DATE_EXCEEDS_MONTH_END": "확정일은 해당 월의 마지막 일을 초과할 수 없습니다.",
"COST_REPORT_ADJUSTMENTS": "비용 리포트 조정",
"COST_REPORT_CONFIGURATION": "비용 리포트 설정",
"COST_REPORT_CURRENCY": "비용 리포트 통화",
"CURRENCY_CONVERTER": "환율 설정",
"DAYS_AFTER_REPORT": "일 (리포트 발행일 이후)",
"DESCRIPTION": "설명",
Expand Down Expand Up @@ -2173,6 +2174,7 @@
"CURRENCY_CONVERTER": "환율 설정",
"CURRENCY_CONVERTER_PAGE": {
"AGGREGATION_DATE": "집계 날짜",
"COST_ANALYSIS_CURRENCY": "비용 분석 통화",
"CURRENCY_CONVERTER": "환율 설정",
"EXCHANGE_RATE_SOURCE": "환율 기준",
"LAST_DAY_OF_THE_MONTH": "매월 마지막일 ",
Expand Down
Loading