Browse Source

fix: sale master

Muhammad Iqbal Afandi 3 years ago
parent
commit
aabfeb7ef6
2 changed files with 6 additions and 8 deletions
  1. 2
    2
      app/Models/SaleDetail.php
  2. 4
    6
      resources/js/pages/Sales/Composables/useCart.js

+ 2
- 2
app/Models/SaleDetail.php View File

@@ -20,8 +20,8 @@ class SaleDetail extends Model
20 20
                 $ppn = Ppn::first()->ppn;
21 21
 
22 22
                 return $this->sale->ppn
23
-                    ? HelperService::addPPN($value, $ppn)
24
-                    : $value;
23
+                    ? HelperService::addPPN($value, $ppn) * $this->qty
24
+                    : $value * $this->qty;
25 25
             }
26 26
         );
27 27
     }

+ 4
- 6
resources/js/pages/Sales/Composables/useCart.js View File

@@ -1,5 +1,5 @@
1 1
 import { reactive } from 'vue'
2
-import { FormValidationError } from '@/utils/helpers'
2
+import { FormValidationError, ppn } from '@/utils/helpers'
3 3
 
4 4
 export function useCart(form, initialProducts = []) {
5 5
   const cart = reactive(initialProducts)
@@ -83,11 +83,9 @@ export function useCart(form, initialProducts = []) {
83 83
 
84 84
   const totalCartPrice = () => {
85 85
     const itemPrices = cart.map((product) => {
86
-      if (form.checkedPpn) {
87
-        return product.price + product.price * (form.ppn / 100)
88
-      } else {
89
-        return product.price
90
-      }
86
+      return form.checkedPpn
87
+        ? ppn(product.price, form.ppn) * product.qty
88
+        : product.price * product.qty
91 89
     })
92 90
 
93 91
     return itemPrices.reduce(