diff --git a/src/app/Http/Controllers/API/V4/UsersController.php b/src/app/Http/Controllers/API/V4/UsersController.php
--- a/src/app/Http/Controllers/API/V4/UsersController.php
+++ b/src/app/Http/Controllers/API/V4/UsersController.php
@@ -113,10 +113,11 @@
$response['skus'] = [];
foreach ($user->entitlements as $ent) {
$sku = $ent->sku;
- $response['skus'][$sku->id] = [
-// 'cost' => $ent->cost,
- 'count' => isset($response['skus'][$sku->id]) ? $response['skus'][$sku->id]['count'] + 1 : 1,
- ];
+ if (!isset($response['skus'][$sku->id])) {
+ $response['skus'][$sku->id] = ['costs' => [], 'count' => 0];
+ }
+ $response['skus'][$sku->id]['count']++;
+ $response['skus'][$sku->id]['costs'][] = $ent->cost;
}
return response()->json($response);
diff --git a/src/resources/js/app.js b/src/resources/js/app.js
--- a/src/resources/js/app.js
+++ b/src/resources/js/app.js
@@ -248,19 +248,15 @@
price(price, currency) {
return ((price || 0) / 100).toLocaleString('de-DE', { style: 'currency', currency: currency || 'CHF' })
},
- priceLabel(cost, units = 1, discount) {
+ priceLabel(cost, discount) {
let index = ''
- if (units < 0) {
- units = 1
- }
-
if (discount) {
cost = Math.floor(cost * ((100 - discount) / 100))
index = '\u00B9'
}
- return this.price(cost * units) + '/month' + index
+ return this.price(cost) + '/month' + index
},
clickRecord(event) {
if (!/^(a|button|svg|path)$/i.test(event.target.nodeName)) {
diff --git a/src/resources/vue/Admin/User.vue b/src/resources/vue/Admin/User.vue
--- a/src/resources/vue/Admin/User.vue
+++ b/src/resources/vue/Admin/User.vue
@@ -454,18 +454,18 @@
.then(response => {
// "merge" SKUs with user entitlement-SKUs
response.data.forEach(sku => {
- if (sku.id in this.user.skus) {
- let count = this.user.skus[sku.id].count
+ const userSku = this.user.skus[sku.id]
+ if (userSku) {
+ let cost = userSku.costs.reduce((sum, current) => sum + current)
let item = {
id: sku.id,
name: sku.name,
- cost: sku.cost,
- units: count - sku.units_free,
- price: this.$root.priceLabel(sku.cost, count - sku.units_free, this.discount)
+ cost: cost,
+ price: this.$root.priceLabel(cost, this.discount)
}
if (sku.range) {
- item.name += ' ' + count + ' ' + sku.range.unit
+ item.name += ' ' + userSku.count + ' ' + sku.range.unit
}
this.skus.push(item)
@@ -587,7 +587,7 @@
this.discount_description = this.wallet.discount_description
this.skus.forEach(sku => {
- sku.price = this.$root.priceLabel(sku.cost, sku.units, this.discount)
+ sku.price = this.$root.priceLabel(sku.cost, this.discount)
})
}
}
diff --git a/src/resources/vue/User/Info.vue b/src/resources/vue/User/Info.vue
--- a/src/resources/vue/User/Info.vue
+++ b/src/resources/vue/User/Info.vue
@@ -88,7 +88,7 @@
- {{ $root.priceLabel(pkg.cost, 1, discount) }}
+ {{ $root.priceLabel(pkg.cost, discount) }}
|
|
- {{ $root.priceLabel(sku.cost, 1, discount) }}
+ {{ $root.priceLabel(sku.cost, discount) }}
|
|