PluginProbe
Yatra – Travel Booking & Tour Operator Software / 3.0.16
Yatra – Travel Booking & Tour Operator Software v3.0.16
3.0.16 3.0.15 3.0.14 3.0.14.1 3.0.14.2 3.0.12 3.0.13 3.0.11 3.0.10 3.0.9 3.0.8 3.0.7 3.0.6 3.0.5 3.0.5.1 3.0.4 3.0.3 3.0.2.9 3.0.2.7 3.0.2.8 3.0.2.6 trunk 1.0.0 2.0.0 2.0.1 All 84 releases
← All changes | resources/js/services/TaxService.ts +12 -6 3.0.2.8 → 3.0.16 View file →
@@ -6,8 +6,12 @@
6 6 * @package Yatra.Services
7 7 * @since 3.0.0
8 8 */
9 9
10 +import { formatYatraMoney } from "../lib/currency-display";
11 +import { apiClient } from "../lib/api-client";
12 +import { API_ENDPOINTS } from "../lib/api-endpoints";
13 +
10 14 interface TaxDetails {
11 15 tax_amount: number;
12 16 tax_rate: number;
13 17 tax_inclusive: boolean;
@@ -53,11 +57,13 @@
53 57 * Load tax settings from API
54 58 */
55 59 async loadTaxSettings(): Promise<void> {
56 60 try {
57 - const response = await fetch("/wp-json/yatra/v1/settings");
58 - const settings = await response.json();
59 - this.taxSettings = settings;
61 + // Through the shared client so the REST nonce is sent — a bare fetch()
62 + // was answered with 401 on every admin booking form, so tax settings
63 + // never actually loaded here.
64 + const settings = await apiClient.get(API_ENDPOINTS.SETTINGS);
65 + this.taxSettings = (settings as any)?.data ?? settings;
60 66 } catch (error) {
61 67 console.error("Failed to load tax settings:", error);
62 68 }
63 69 }
@@ -250,11 +256,11 @@
250 256 * Format price display
251 257 */
252 258 formatPrice(amount: number): string {
253 259 const currency = this.taxSettings?.currency || "USD";
254 - const currencySymbol = this.getCurrencySymbol(currency);
255 -
256 - return `${currencySymbol}${amount.toFixed(2)}`;
260 + return formatYatraMoney(Number(amount) || 0, currency, {
261 + zeroAsUnknown: false,
262 + });
257 263 }
258 264
259 265 /**
260 266 * Get currency symbol