PluginProbe
VikBooking Hotel Booking Engine & PMS / 1.8.16
VikBooking Hotel Booking Engine & PMS v1.8.16
1.8.16 1.8.15 1.8.14 1.8.13 1.8.12 1.8.11 1.8.10 1.8.9 1.8.6 1.8.7 1.8.8 trunk 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 1.6.6 1.6.7 1.6.8 1.6.9 1.7.0 1.7.1 1.7.2 All 37 releases
← All changes | admin/helpers/src/taxonomy/summary.php +40 -11 1.6.9 → 1.8.16 View file →
@@ -127,8 +127,38 @@
127 127 return [(float)$record['aliq'], $record['name']];
128 128 }
129 129
130 130 /**
131 + * Gets the tax record data assigned to the given rate plan ID.
132 + *
133 + * @param int $ratep_id The rate plan ID.
134 + *
135 + * @return array Empty array or tax record found.
136 + *
137 + * @since 1.18.8 (J) - 1.8.8 (WP)
138 + */
139 + public static function getTaxRecordFromRatePlan(int $ratep_id)
140 + {
141 + $dbo = JFactory::getDbo();
142 +
143 + $dbo->setQuery(
144 + $dbo->getQuery(true)
145 + ->select([
146 + $dbo->qn('p.id'),
147 + $dbo->qn('p.idiva'),
148 + $dbo->qn('t.name'),
149 + $dbo->qn('t.aliq'),
150 + $dbo->qn('t.taxcap'),
151 + ])
152 + ->from($dbo->qn('#__vikbooking_prices', 'p'))
153 + ->leftJoin($dbo->qn('#__vikbooking_iva', 't') . ' ON ' . $dbo->qn('p.idiva') . ' = ' . $dbo->qn('t.id'))
154 + ->where($dbo->qn('p.id') . ' = ' . $ratep_id)
155 + );
156 +
157 + return $dbo->loadAssoc() ?: [];
158 + }
159 +
160 + /**
131 161 * Gets the tax rate assigned to the given tax ID.
132 162 *
133 163 * @param int $tax_id the tax ID.
134 164 *
@@ -154,38 +184,37 @@
154 184
155 185 /**
156 186 * Returns the whole tax rate record from the given ID.
157 187 *
158 - * @param int $tax_id the tax record ID.
188 + * @param ?int $tax_id The tax record ID.
159 189 *
160 190 * @return array
161 191 *
162 - * @since 1.16.1 (J) - 1.6.1 (WP)
192 + * @since 1.18.8 (J) - 1.8.8 (WP) argument is nullable.
163 193 */
164 - public static function getTaxRateRecord($tax_id)
194 + public static function getTaxRateRecord(?int $tax_id)
165 195 {
166 196 static $tax_map = [];
167 197
168 - $tax_id = (int)$tax_id;
198 + $tax_id = (int) $tax_id;
169 199
170 200 if (isset($tax_map[$tax_id])) {
171 201 return $tax_map[$tax_id];
172 202 }
173 203
204 + if (empty($tax_id)) {
205 + return [];
206 + }
207 +
174 208 $dbo = JFactory::getDbo();
175 209
176 210 $q = "SELECT * FROM `#__vikbooking_iva` WHERE `id`=" . $tax_id;
177 211 $dbo->setQuery($q, 0, 1);
178 - $record = $dbo->loadAssoc();
179 212
180 - if (!$record) {
181 - $record = [];
182 - }
183 -
184 213 // cache value and return it
185 - $tax_map[$tax_id] = $record;
214 + $tax_map[$tax_id] = (array) $dbo->loadAssoc();
186 215
187 - return $record;
216 + return $tax_map[$tax_id];
188 217 }
189 218
190 219 /**
191 220 * Gets the tax summary associative array.