Rename discount type Normal => Percentage #kbcqjv
This commit is contained in:
parent
e8720c6a8a
commit
5aa6071e9b
@ -45,7 +45,7 @@ class CreateDocumentItem extends Job
|
||||
if (!empty($this->request['discount'])) {
|
||||
$discount = $this->request['discount'];
|
||||
|
||||
if ($this->request['discount_type'] === 'normal') {
|
||||
if ($this->request['discount_type'] === 'percentage') {
|
||||
$item_discounted_amount = $item_amount -= ($item_amount * ($this->request['discount'] / 100));
|
||||
} else {
|
||||
$item_discounted_amount = $item_amount -= $this->request['discount'];
|
||||
@ -150,10 +150,10 @@ class CreateDocumentItem extends Job
|
||||
$item_tax_total += $tax_amount;
|
||||
}
|
||||
|
||||
if (!empty($this->request['discount_type']) && $this->request['discount_type'] === 'normal') {
|
||||
$item_amount = ($item_amount - $item_tax_total) / (1 - $discount / 100);
|
||||
} else {
|
||||
if (!empty($this->request['discount_type']) && $this->request['discount_type'] === 'fixed') {
|
||||
$item_amount = ($item_amount - $item_tax_total) - $discount;
|
||||
} else {
|
||||
$item_amount = ($item_amount - $item_tax_total) / (1 - $discount / 100);
|
||||
}
|
||||
}
|
||||
|
||||
@ -186,7 +186,7 @@ class CreateDocumentItem extends Job
|
||||
$this->request['quantity'] = (double) $this->request['quantity'];
|
||||
$this->request['price'] = round($this->request['price'], $precision);
|
||||
$this->request['tax'] = round($item_tax_total, $precision);
|
||||
$this->request['discount_type'] = !empty($this->request['discount_type']) ? $this->request['discount_type'] : 'normal';
|
||||
$this->request['discount_type'] = !empty($this->request['discount_type']) ? $this->request['discount_type'] : 'percentage';
|
||||
$this->request['discount_rate'] = !empty($this->request['discount']) ? $this->request['discount'] : 0;
|
||||
$this->request['total'] = round($item_amount, $precision);
|
||||
|
||||
|
@ -71,7 +71,7 @@ class CreateDocumentItemsAndTotals extends Job
|
||||
}
|
||||
|
||||
if (!empty($this->request['discount'])) {
|
||||
if ($this->request['discount_type'] === 'normal') {
|
||||
if ($this->request['discount_type'] === 'percentage') {
|
||||
$discount_total = $sub_total * ($this->request['discount'] / 100);
|
||||
} else {
|
||||
$discount_total = $this->request['discount'];
|
||||
@ -195,7 +195,7 @@ class CreateDocumentItemsAndTotals extends Job
|
||||
$discount_amount = 0;
|
||||
|
||||
if (!empty($item['discount'])) {
|
||||
if ($item['discount_type'] === 'normal') {
|
||||
if ($item['discount_type'] === 'percentage') {
|
||||
$discount_amount = ($item_amount * ($item['discount'] / 100));
|
||||
} else {
|
||||
$discount_amount = $item['discount'];
|
||||
|
10
resources/assets/js/views/common/documents.js
vendored
10
resources/assets/js/views/common/documents.js
vendored
@ -70,7 +70,7 @@ const app = new Vue({
|
||||
},
|
||||
|
||||
mounted() {
|
||||
this.form.discount_type = 'normal';
|
||||
this.form.discount_type = 'percentage';
|
||||
|
||||
if ((document.getElementById('items') != null) && (document.getElementById('items').rows)) {
|
||||
this.colspan = document.getElementById("items").rows[0].cells.length - 1;
|
||||
@ -118,7 +118,7 @@ const app = new Vue({
|
||||
let line_discount_amount = 0;
|
||||
|
||||
if (item.discount) {
|
||||
if (item.discount_type === 'normal') {
|
||||
if (item.discount_type === 'percentage') {
|
||||
if (item.discount > 100) {
|
||||
item.discount = 100;
|
||||
}
|
||||
@ -249,7 +249,7 @@ const app = new Vue({
|
||||
|
||||
// Apply discount to total
|
||||
if (global_discount) {
|
||||
if (this.form.discount_type === 'normal') {
|
||||
if (this.form.discount_type === 'percentage') {
|
||||
discount_total = parseFloat(sub_total + inclusive_tax_total) * (global_discount / 100);
|
||||
} else {
|
||||
discount_total = global_discount;
|
||||
@ -398,7 +398,7 @@ const app = new Vue({
|
||||
},
|
||||
|
||||
onAddLineDiscount(item_index) {
|
||||
this.items[item_index].discount_type = 'normal';
|
||||
this.items[item_index].discount_type = 'percentage';
|
||||
this.items[item_index].add_discount = true;
|
||||
},
|
||||
|
||||
@ -415,7 +415,7 @@ const app = new Vue({
|
||||
onAddTotalDiscount() {
|
||||
let discount = document.getElementById('pre-discount').value;
|
||||
|
||||
if (this.form.discount_type === 'normal') {
|
||||
if (this.form.discount_type === 'percentage') {
|
||||
if (discount < 0) {
|
||||
discount = 0;
|
||||
} else if (discount > 100) {
|
||||
|
@ -163,8 +163,8 @@
|
||||
<div class="form-group mb-0 w-100" style="display: inline-block; position: relative;">
|
||||
<div class="input-group mb-0 select-tax">
|
||||
<div class="input-group-prepend">
|
||||
<button class="btn btn-sm" :class="[{'btn-outline-primary' : row.discount_type !== 'normal'}, {'btn-primary' : row.discount_type === 'normal'}]"
|
||||
@click="onChangeLineDiscountType(index, 'normal')" type="button">
|
||||
<button class="btn btn-sm" :class="[{'btn-outline-primary' : row.discount_type !== 'percentage'}, {'btn-primary' : row.discount_type === 'percentage'}]"
|
||||
@click="onChangeLineDiscountType(index, 'percentage')" type="button">
|
||||
<i class="fa fa-percent fa-sm"></i>
|
||||
</button>
|
||||
<button class="btn btn-sm" :class="[{'btn-outline-primary' : row.discount_type !== 'fixed'}, {'btn-primary' : row.discount_type === 'fixed'}]"
|
||||
|
@ -57,8 +57,8 @@
|
||||
<div class="col-sm-8">
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend">
|
||||
<button class="btn btn-sm" :class="[{'btn-outline-primary' : form.discount_type !== 'normal'}, {'btn-primary' : form.discount_type === 'normal'}]"
|
||||
@click="onChangeDiscountType('normal')" type="button">
|
||||
<button class="btn btn-sm" :class="[{'btn-outline-primary' : form.discount_type !== 'percentage'}, {'btn-primary' : form.discount_type === 'percentage'}]"
|
||||
@click="onChangeDiscountType('percentage')" type="button">
|
||||
<i class="fa fa-percent fa-sm"></i>
|
||||
</button>
|
||||
<button class="btn btn-sm" :class="[{'btn-outline-primary' : form.discount_type !== 'fixed'}, {'btn-primary' : form.discount_type === 'fixed'}]"
|
||||
|
@ -33,7 +33,7 @@
|
||||
@if (!$hideDiscount)
|
||||
@if (in_array(setting('localisation.discount_location', 'total'), ['item', 'both']))
|
||||
@stack('discount_td_start')
|
||||
@if ($item->discount_type === 'normal')
|
||||
@if ($item->discount_type === 'percentage')
|
||||
<td class="discount">{{ $item->discount }}</td>
|
||||
@else
|
||||
<td class="discount">@money($item->discount, $document->currency_code, true)</td>
|
||||
|
Loading…
x
Reference in New Issue
Block a user