Преглед на файлове

sale and purchase master

Muhammad Iqbal Afandi преди 3 години
родител
ревизия
bbc1703c51

+ 1
- 0
app/Http/Controllers/PurchaseController.php Целия файл

@@ -147,6 +147,7 @@ class PurchaseController extends Controller
147 147
             "ppn" => Ppn::first()->ppn,
148 148
             "status" => $purchase->status,
149 149
             "ppnChecked" => $purchase->ppn ? true : false,
150
+            "supplier" => $purchase->supplier,
150 151
             "purchaseDetail" => $purchase->purchaseDetail->transform(
151 152
                 fn($purchase) => [
152 153
                     "id" => $purchase->id,

+ 24
- 101
app/Http/Controllers/SalesController.php Целия файл

@@ -6,7 +6,6 @@ use App\Models\Ppn;
6 6
 use App\Models\Sale;
7 7
 use Inertia\Inertia;
8 8
 use App\Models\Customer;
9
-use App\Models\SaleDetail;
10 9
 use App\Models\StockProduct;
11 10
 use App\Services\HelperService;
12 11
 use Illuminate\Support\Facades\DB;
@@ -42,7 +41,7 @@ class SalesController extends Controller
42 41
                         "phone" => $sale->customer->phone,
43 42
                         "email" => $sale->customer->email,
44 43
                         "price" => HelperService::setRupiahFormat(
45
-                            SaleDetail::totalPrice($sale)
44
+                            $sale->saleDetail->sum("price")
46 45
                         ),
47 46
                         "status" => $sale->status,
48 47
                     ]
@@ -75,6 +74,7 @@ class SalesController extends Controller
75 74
                             "number" => $stockProduct->product_number,
76 75
                             "name" => $stockProduct->product->name,
77 76
                             "price" => $stockProduct->price,
77
+                            "ppn" => $stockProduct->ppn,
78 78
                             "qty" => $stockProduct->qty,
79 79
                             "unit" => $stockProduct->product->unit,
80 80
                         ]
@@ -91,8 +91,6 @@ class SalesController extends Controller
91 91
      */
92 92
     public function store(StoreSaleRequest $request)
93 93
     {
94
-        dd($request->validated());
95
-
96 94
         DB::beginTransaction();
97 95
 
98 96
         try {
@@ -118,20 +116,19 @@ class SalesController extends Controller
118 116
                 $sale->saleDetail()->create($validated);
119 117
 
120 118
                 if ($request->status == "success") {
121
-                    $validated = [
122
-                        "sale_number" => $sale->number,
123
-                        "price" => $product["price"],
124
-                        "qty" => $product["qty"],
125
-                        "product_number" => $product["number"],
126
-                    ];
127
-
128
-                    StockProduct::create($validated);
119
+                    StockProduct::where(
120
+                        "product_number",
121
+                        $product["number"]
122
+                    )->decrement("qty", $product["qty"]);
129 123
                 }
130 124
             }
131 125
 
132 126
             DB::commit();
133 127
 
134
-            return back()->with("success", __("messages.success.store.sale"));
128
+            return to_route("sales.show", $sale)->with(
129
+                "success",
130
+                __("messages.success.store.sale")
131
+            );
135 132
         } catch (QueryException $e) {
136 133
             DB::rollBack();
137 134
 
@@ -147,46 +144,19 @@ class SalesController extends Controller
147 144
      */
148 145
     public function show(Sale $sale)
149 146
     {
150
-        //
151
-    }
152
-
153
-    /**
154
-     * Show the form for editing the specified resource.
155
-     *
156
-     * @param  Sale $sale
157
-     * @return \Illuminate\Http\Response
158
-     */
159
-    public function edit(Sale $sale)
160
-    {
161
-        return inertia("Sales/Edit", [
147
+        return inertia("Sales/Show", [
162 148
             "id" => $sale->id,
163 149
             "number" => $sale->number,
164 150
             "ppn" => Ppn::first()->ppn,
165 151
             "status" => $sale->status,
166 152
             "ppnChecked" => $sale->ppn ? true : false,
167 153
             "customer" => $sale->customer,
168
-            "stockProducts" => Inertia::lazy(
169
-                fn() => StockProduct::filter([
170
-                    "search" => request("stockProduct"),
171
-                ])
172
-                    ->get()
173
-                    ->transform(
174
-                        fn($stockProduct) => [
175
-                            "number" => $stockProduct->product_number,
176
-                            "name" => $stockProduct->product->name,
177
-                            "price" => $stockProduct->price,
178
-                            "qty" => $stockProduct->qty,
179
-                            "unit" => $stockProduct->product->unit,
180
-                            "profit" => $stockProduct->product->profit,
181
-                        ]
182
-                    )
183
-            ),
184 154
             "saleDetail" => $sale->saleDetail->transform(
185 155
                 fn($sale) => [
186 156
                     "id" => $sale->id,
187 157
                     "number" => $sale->product_number,
188 158
                     "name" => $sale->product->name,
189
-                    "price" => $sale->price,
159
+                    "price" => $sale->getRawOriginal("price"),
190 160
                     "qty" => $sale->qty,
191 161
                     "unit" => $sale->product->unit,
192 162
                 ]
@@ -194,6 +164,17 @@ class SalesController extends Controller
194 164
         ]);
195 165
     }
196 166
 
167
+    /**
168
+     * Show the form for editing the specified resource.
169
+     *
170
+     * @param  Sale $sale
171
+     * @return \Illuminate\Http\Response
172
+     */
173
+    public function edit(Sale $sale)
174
+    {
175
+        //
176
+    }
177
+
197 178
     /**
198 179
      * Update the specified resource in storage.
199 180
      *
@@ -203,65 +184,7 @@ class SalesController extends Controller
203 184
      */
204 185
     public function update(UpdateSaleRequest $request, Sale $sale)
205 186
     {
206
-        dd($sale);
207
-
208
-        DB::beginTransaction();
209
-
210
-        try {
211
-            $ppn = Ppn::first()->ppn;
212
-
213
-            $validated = $request
214
-                ->safe()
215
-                ->merge([
216
-                    "ppn" => $request->ppn ? $ppn : 0,
217
-                ])
218
-                ->all();
219
-
220
-            $sale->update($validated);
221
-
222
-            foreach ($request->products as $product) {
223
-                $validated = [
224
-                    "product_number" => $product["number"],
225
-                    "price" => $product["price"],
226
-                    "qty" => $product["qty"],
227
-                ];
228
-
229
-                if (!empty($product["label"])) {
230
-                    if ($product["label"] == "add") {
231
-                        $sale->saleDetail()->create($validated);
232
-                    }
233
-
234
-                    if ($product["label"] == "edit") {
235
-                        $sale->saleDetail
236
-                            ->find($product["id"])
237
-                            ->update($validated);
238
-                    }
239
-
240
-                    if ($product["label"] == "delete") {
241
-                        $sale->saleDetail->find($product["id"])->delete();
242
-                    }
243
-                }
244
-
245
-                if ($request->status == "success") {
246
-                    $validated = [
247
-                        "sale_number" => $sale->number,
248
-                        "price" => $product["price"],
249
-                        "qty" => $product["qty"],
250
-                        "product_number" => $product["number"],
251
-                    ];
252
-
253
-                    StockProduct::create($validated);
254
-                }
255
-            }
256
-
257
-            DB::commit();
258
-
259
-            return back()->with("success", __("messages.success.update.sale"));
260
-        } catch (QueryException $e) {
261
-            DB::rollBack();
262
-
263
-            return back()->with("error", __("messages.error.update.sale"));
264
-        }
187
+        //
265 188
     }
266 189
 
267 190
     /**

+ 1
- 1
app/Models/PurchaseDetail.php Целия файл

@@ -43,7 +43,7 @@ class PurchaseDetail extends Model
43 43
                 $query,
44 44
                 $search
45 45
             ) {
46
-                $query->whereRelation("product", "number", $search);
46
+                $query->where("product_number", $search);
47 47
             })
48 48
             ->when($filters["supplierId"] ?? null, function ($query, $search) {
49 49
                 $query->whereHas("purchase", function ($query) use ($search) {

+ 39
- 0
app/Models/SaleDetail.php Целия файл

@@ -12,4 +12,43 @@ class SaleDetail extends Model
12 12
     use HasFactory;
13 13
 
14 14
     protected $fillable = ["price", "qty", "sale_number", "product_number"];
15
+
16
+    protected function price(): Attribute
17
+    {
18
+        return Attribute::make(
19
+            get: function ($value) {
20
+                $ppn = Ppn::first()->ppn;
21
+
22
+                return $this->sale->ppn
23
+                    ? HelperService::addPPN($value, $ppn)
24
+                    : $value;
25
+            }
26
+        );
27
+    }
28
+
29
+    public function product()
30
+    {
31
+        return $this->belongsTo(Product::class, "product_number", "number");
32
+    }
33
+
34
+    public function sale()
35
+    {
36
+        return $this->belongsTo(Sale::class, "sale_number", "number");
37
+    }
38
+
39
+    public function scopeHistoryProductSale($query, array $filters)
40
+    {
41
+        $query
42
+            ->when($filters["productNumber"] ?? null, function (
43
+                $query,
44
+                $search
45
+            ) {
46
+                $query->where("product_number", $search);
47
+            })
48
+            ->when($filters["customerId"] ?? null, function ($query, $search) {
49
+                $query->whereHas("sale", function ($query) use ($search) {
50
+                    $query->where("customer_id", $search);
51
+                });
52
+            });
53
+    }
15 54
 }

+ 17
- 1
app/Models/StockProduct.php Целия файл

@@ -2,8 +2,11 @@
2 2
 
3 3
 namespace App\Models;
4 4
 
5
-use Illuminate\Database\Eloquent\Factories\HasFactory;
5
+use App\Models\Ppn;
6
+use App\Services\HelperService;
6 7
 use Illuminate\Database\Eloquent\Model;
8
+use Illuminate\Database\Eloquent\Casts\Attribute;
9
+use Illuminate\Database\Eloquent\Factories\HasFactory;
7 10
 
8 11
 class StockProduct extends Model
9 12
 {
@@ -11,6 +14,19 @@ class StockProduct extends Model
11 14
 
12 15
     protected $fillable = ["price", "qty", "ppn", "product_number"];
13 16
 
17
+    protected function price(): Attribute
18
+    {
19
+        return Attribute::make(
20
+            get: function ($value) {
21
+                $ppn = Ppn::first()->ppn;
22
+
23
+                return $this->ppn
24
+                    ? HelperService::addPPN($value, $ppn)
25
+                    : $value;
26
+            }
27
+        );
28
+    }
29
+
14 30
     public function product()
15 31
     {
16 32
         return $this->belongsTo(Product::class, "product_number", "number");

+ 63
- 64
lang/en/messages.php Целия файл

@@ -1,7 +1,6 @@
1 1
 <?php
2 2
 
3 3
 return [
4
-
5 4
     /*
6 5
     |--------------------------------------------------------------------------
7 6
     | Authentication Language Lines
@@ -12,75 +11,75 @@ return [
12 11
     |
13 12
      */
14 13
 
15
-    'user' => [
16
-        'active_user' => 'Successfully active the user',
17
-        'no_active_user' => 'Successfully block user'
14
+    "user" => [
15
+        "active_user" => "Successfully active the user",
16
+        "no_active_user" => "Successfully block user",
18 17
     ],
19 18
 
20
-    'success' => [
21
-        'email' => [
22
-            'verify_email' => 'Email Verification link successfully sent'
19
+    "success" => [
20
+        "email" => [
21
+            "verify_email" => "Email Verification link successfully sent",
22
+        ],
23
+        "store" => [
24
+            "parking_fee" => "Parking fee successfully added",
25
+            "type_vehicle" => "Type vehicle successfully added",
26
+            "top_up" => "Top Up successfully",
27
+            "member" => "Member successfully added",
28
+            "type_member" => "Jenis member successfully added",
29
+            "discount" => "Discount successfully added",
30
+            "expense" => "Expense successfully added",
31
+            "transaction" => "Transaction successfully added",
32
+            "user" => "User Account successfully added",
33
+            "reset_password" => "Password successfully reset",
34
+            "customer" => "Customer successfully added",
35
+            "supplier" => "Supplier successfully added",
36
+            "product" => "Product successfully added",
37
+            "sale" => "Sale successfully",
38
+            "purchase" => "Purchase successfully added",
23 39
         ],
24
-        'store' => [
25
-            'parking_fee' => 'Parking fee successfully added',
26
-            'type_vehicle' => 'Type vehicle successfully added',
27
-            'top_up' => 'Top Up successfully',
28
-            'member' => 'Member successfully added',
29
-            'type_member' => 'Jenis member successfully added',
30
-            'discount' => 'Discount successfully added',
31
-            'expense' => 'Expense successfully added',
32
-            'transaction' => 'Transaction successfully added',
33
-            'user' => 'User Account successfully added',
34
-            'reset_password' => 'Password successfully reset',
35
-            'customer' => 'Customer successfully added',
36
-            'supplier' => 'Supplier successfully added',
37
-            'product' => 'Product successfully added',
38
-            'sale' => 'Sale successfully added',
39
-            'purchase' => 'Purchase successfully added'
40
+        "update" => [
41
+            "type_vehicle" => "Type vehicle successfully changed",
42
+            "top_up" => "Top Up successfully changed",
43
+            "member" => "Member successfully changed",
44
+            "type_member" => "Jenis member successfully changed",
45
+            "change_password" => "Password successfully changed",
46
+            "transaction_status" => "Transaction Status successfully changed",
47
+            "user" => "User Account successfully changed",
48
+            "customer" => "Customer successfully changed",
49
+            "supplier" => "Supplier successfully changed",
50
+            "product" => "Product successfully changed",
51
+            "sale" => "Sale successfully changed",
52
+            "ppn" => "Tax successfully changed",
53
+            "purchase" => "Purchase successfully added",
40 54
         ],
41
-        'update' => [
42
-            'type_vehicle' => 'Type vehicle successfully changed',
43
-            'top_up' => 'Top Up successfully changed',
44
-            'member' => 'Member successfully changed',
45
-            'type_member' => 'Jenis member successfully changed',
46
-            'change_password' => 'Password successfully changed',
47
-            'transaction_status' => 'Transaction Status successfully changed',
48
-            'user' => 'User Account successfully changed',
49
-            'customer' => 'Customer successfully changed',
50
-            'supplier' => 'Supplier successfully changed',
51
-            'product' => 'Product successfully changed',
52
-            'sale' => 'Sale successfully changed',
53
-            'ppn' => 'Tax successfully changed',
54
-            'purchase' => 'Purchase successfully added'
55
+        "destroy" => [
56
+            "type_member" => "Jenis member successfully deleted",
57
+            "type_vehicle" => "Type vehicle successfully deleted",
58
+            "top_up" => "Top Up successfully deleted",
59
+            "member" => "Member Account successfully deleted",
60
+            "user" => "User Account successfully deleted",
61
+            "customer" => "Customer successfully deleted",
62
+            "product" => "Product successfully deleted",
63
+            "supplier" => "Supplier successfully deleted",
55 64
         ],
56
-        'destroy' => [
57
-            'type_member' => 'Jenis member successfully deleted',
58
-            'type_vehicle' => 'Type vehicle successfully deleted',
59
-            'top_up' => 'Top Up successfully deleted',
60
-            'member' => 'Member Account successfully deleted',
61
-            'user' => 'User Account successfully deleted',
62
-            'customer' => 'Customer successfully deleted',
63
-            'product' => 'Product successfully deleted',
64
-            'supplier' => 'Supplier successfully deleted'
65
-        ]
66 65
     ],
67 66
 
68
-    'error' => [
69
-        'store' => [
70
-            'top_up' => 'Top up failed to be added',
71
-            'type_member' => 'Type member failed to be added',
72
-            'member' => 'member failed to be added',
73
-            'change_password' => 'Password invalid',
74
-            'expense' => 'Expense failed to be added',
75
-            'transaction' => 'Transaction failed to be added',
76
-            'sale' => 'Sale failed to be added',
77
-            'purchase' => 'Purchase failed to be added'
67
+    "error" => [
68
+        "store" => [
69
+            "top_up" => "Top up failed to be added",
70
+            "type_member" => "Type member failed to be added",
71
+            "member" => "member failed to be added",
72
+            "change_password" => "Password invalid",
73
+            "expense" => "Expense failed to be added",
74
+            "transaction" => "Transaction failed to be added",
75
+            "sale" => "Sale failed",
76
+            "purchase" => "Purchase failed to be added",
78 77
         ],
79
-        'update' => [
80
-            'type_member' => 'Type member failed to be changed',
81
-            'member' => 'Member failed to be changed',
82
-            'sale' => 'Sale failed to be changed',
83
-            'purchase' => 'Purchase failed to be changed'
84
-        ]
85
-    ]
78
+        "update" => [
79
+            "type_member" => "Type member failed to be changed",
80
+            "member" => "Member failed to be changed",
81
+            "sale" => "Sale failed to be changed",
82
+            "purchase" => "Purchase failed to be changed",
83
+        ],
84
+    ],
86 85
 ];

+ 63
- 64
lang/id/messages.php Целия файл

@@ -1,7 +1,6 @@
1 1
 <?php
2 2
 
3 3
 return [
4
-
5 4
     /*
6 5
     |--------------------------------------------------------------------------
7 6
     | Authentication Language Lines
@@ -12,75 +11,75 @@ return [
12 11
     |
13 12
      */
14 13
 
15
-    'user' => [
16
-        'active_user' => 'Sukses mengaktifkan user',
17
-        'no_active_user' => 'Sukses memblokir user'
14
+    "user" => [
15
+        "active_user" => "Sukses mengaktifkan user",
16
+        "no_active_user" => "Sukses memblokir user",
18 17
     ],
19 18
 
20
-    'success' => [
21
-        'email' => [
22
-            'verify_email' => 'Link verifikasi email berhasil terkirim'
19
+    "success" => [
20
+        "email" => [
21
+            "verify_email" => "Link verifikasi email berhasil terkirim",
22
+        ],
23
+        "store" => [
24
+            "parking_fee" => "Tarif parkir berhasil ditambahkan",
25
+            "type_vehicle" => "Jenis kendaraan berhasil ditambahkan",
26
+            "top_up" => "Top Up berhasil",
27
+            "member" => "Member berhasil ditambahkan",
28
+            "type_member" => "Jenis member berhasil ditambahkan",
29
+            "discount" => "Diskon berhasil diubah",
30
+            "expense" => "Pengeluaran berhasil ditambahkan",
31
+            "transaction" => "Transaksi berhasil ditambahkan",
32
+            "user" => "Akun user berhasil ditambahkan",
33
+            "reset_password" => "Kata sandi berhasil di reset",
34
+            "customer" => "Pelanggan berhasil ditambahkan",
35
+            "supplier" => "Supplier berhasil ditambahkan",
36
+            "product" => "Produk berhasil ditambahkan",
37
+            "sale" => "Penjualan berhasil",
38
+            "purchase" => "Pembelian berhasil ditambahkan",
23 39
         ],
24
-        'store' => [
25
-            'parking_fee' => 'Tarif parkir berhasil ditambahkan',
26
-            'type_vehicle' => 'Jenis kendaraan berhasil ditambahkan',
27
-            'top_up' => 'Top Up berhasil',
28
-            'member' => 'Member berhasil ditambahkan',
29
-            'type_member' => 'Jenis member berhasil ditambahkan',
30
-            'discount' => 'Diskon berhasil diubah',
31
-            'expense' => 'Pengeluaran berhasil ditambahkan',
32
-            'transaction' => 'Transaksi berhasil ditambahkan',
33
-            'user' => 'Akun user berhasil ditambahkan',
34
-            'reset_password' => 'Kata sandi berhasil di reset',
35
-            'customer' => 'Pelanggan berhasil ditambahkan',
36
-            'supplier' => 'Supplier berhasil ditambahkan',
37
-            'product' => 'Produk berhasil ditambahkan',
38
-            'sale' => 'Penjualan berhasil ditambahkan',
39
-            'purchase' => 'Pembelian berhasil ditambahkan'
40
+        "update" => [
41
+            "type_vehicle" => "Jenis kendaraan berhasil diubah",
42
+            "top_up" => "Top Up berhasil diubah",
43
+            "member" => "Member berhasil diubah",
44
+            "type_member" => "Jenis member berhasil diubah",
45
+            "change_password" => "Password berhasil diubah",
46
+            "transaction_status" => "Status transaksi berhasil diubah",
47
+            "user" => "Akun user berhasil diubah",
48
+            "customer" => "Pelanggan berhasil diubah",
49
+            "supplier" => "Supplier berhasil diubah",
50
+            "product" => "Produk berhasil diubah",
51
+            "sale" => "Penjualan berhasil diubah",
52
+            "ppn" => "Pajak pertambahan nilai berhasil diubah",
53
+            "purchase" => "Pembelian berhasil diubah",
40 54
         ],
41
-        'update' => [
42
-            'type_vehicle' => 'Jenis kendaraan berhasil diubah',
43
-            'top_up' => 'Top Up berhasil diubah',
44
-            'member' => 'Member berhasil diubah',
45
-            'type_member' => 'Jenis member berhasil diubah',
46
-            'change_password' => 'Password berhasil diubah',
47
-            'transaction_status' => 'Status transaksi berhasil diubah',
48
-            'user' => 'Akun user berhasil diubah',
49
-            'customer' => 'Pelanggan berhasil diubah',
50
-            'supplier' => 'Supplier berhasil diubah',
51
-            'product' => 'Produk berhasil diubah',
52
-            'sale' => 'Penjualan berhasil diubah',
53
-            'ppn' => 'Pajak pertambahan nilai berhasil diubah',
54
-            'purchase' => 'Pembelian berhasil diubah'
55
+        "destroy" => [
56
+            "type_member" => "Jenis member berhasil dihapus",
57
+            "type_vehicle" => "Jenis kendaraan berhasil dihapus",
58
+            "top_up" => "Top Up berhasil dihapus",
59
+            "member" => "Akun member berhasil dihapus",
60
+            "user" => "Akun user berhasil dihapus",
61
+            "customer" => "Pelanggan berhasil dihapus",
62
+            "product" => "Product berhasil dihapus",
63
+            "supplier" => "Supplier berhasil dihapus",
55 64
         ],
56
-        'destroy' => [
57
-            'type_member' => 'Jenis member berhasil dihapus',
58
-            'type_vehicle' => 'Jenis kendaraan berhasil dihapus',
59
-            'top_up' => 'Top Up berhasil dihapus',
60
-            'member' => 'Akun member berhasil dihapus',
61
-            'user' => 'Akun user berhasil dihapus',
62
-            'customer' => 'Pelanggan berhasil dihapus',
63
-            'product' => 'Product berhasil dihapus',
64
-            'supplier' => 'Supplier berhasil dihapus'
65
-        ]
66 65
     ],
67 66
 
68
-    'error' => [
69
-        'store' => [
70
-            'top_up' => 'Top up gagal ditambahkan',
71
-            'type_member' => 'Jenis member gagal ditambahkan',
72
-            'member' => 'Member gagal ditambahkan',
73
-            'change_password' => 'Password lama salah',
74
-            'expense' => 'Pengeluaran gagal ditambahkan',
75
-            'transaction' => 'Transaksi gagal ditambahkan',
76
-            'sale' => 'Penjualan gagal ditambahkan',
77
-            'purchase' => 'Pembelian gagal ditambahkan'
67
+    "error" => [
68
+        "store" => [
69
+            "top_up" => "Top up gagal ditambahkan",
70
+            "type_member" => "Jenis member gagal ditambahkan",
71
+            "member" => "Member gagal ditambahkan",
72
+            "change_password" => "Password lama salah",
73
+            "expense" => "Pengeluaran gagal ditambahkan",
74
+            "transaction" => "Transaksi gagal ditambahkan",
75
+            "sale" => "Penjualan gagal",
76
+            "purchase" => "Pembelian gagal ditambahkan",
78 77
         ],
79
-        'update' => [
80
-            'type_member' => 'Jenis member gagal diubah',
81
-            'member' => 'Member gagal diubah',
82
-            'sale' => 'Penjualan gagal dibuah',
83
-            'purchase' => 'Pembelian gagal dibuah'
84
-        ]
85
-    ]
78
+        "update" => [
79
+            "type_member" => "Jenis member gagal diubah",
80
+            "member" => "Member gagal diubah",
81
+            "sale" => "Penjualan gagal dibuah",
82
+            "purchase" => "Pembelian gagal dibuah",
83
+        ],
84
+    ],
86 85
 ];

+ 2
- 1
resources/js/pages/Purchases/Components/HistoryProduct.vue Целия файл

@@ -30,11 +30,12 @@ watch(
30 30
     <div class="col-12">
31 31
       <h3 class="text-lg">Riwayat Produk Sebelumnya</h3>
32 32
     </div>
33
+
33 34
     <div class="col-12 md:col-6">
34 35
       <AppInputNumber
35 36
         disabled
36 37
         class="mb-0"
37
-        label="Harga"
38
+        label="Harga "
38 39
         placeholder="harga"
39 40
         v-model="$page.props.historyProductPurchase.price"
40 41
       />

+ 4
- 2
resources/js/pages/Purchases/Create.vue Целия файл

@@ -177,6 +177,8 @@ const { onShowCreateProduct, onShowCreateSupplier } = onShowDialog()
177 177
                     />
178 178
                   </div>
179 179
 
180
+                  <Divider type="dashed" />
181
+
180 182
                   <HistoryProduct
181 183
                     :product="form.product"
182 184
                     :supplier="form.supplier"
@@ -187,8 +189,8 @@ const { onShowCreateProduct, onShowCreateSupplier } = onShowDialog()
187 189
                   <div class="col-12 md:col-6">
188 190
                     <AppInputNumber
189 191
                       :disabled="!form.supplier?.id"
190
-                      label="Harga"
191
-                      placeholder="harga"
192
+                      label="Harga Terbaru"
193
+                      placeholder="harga terbaru"
192 194
                       v-model="form.price"
193 195
                     />
194 196
                   </div>

+ 1
- 1
resources/js/pages/Purchases/Index.vue Целия файл

@@ -67,7 +67,7 @@ defineProps({
67 67
             v-else
68 68
             icon="pi pi-eye"
69 69
             class="p-button-icon-only p-button-rounded p-button-text"
70
-            v-tooltip.bottom="'Lihat Pembelian'"
70
+            v-tooltip.bottom="'Lihat Detail Pembelian'"
71 71
             :href="route('purchases.show', data.id)"
72 72
           />
73 73
         </template>

+ 41
- 12
resources/js/pages/Purchases/Show.vue Целия файл

@@ -22,8 +22,10 @@ const form = useForm({
22 22
   checkedPpn: props.ppnChecked,
23 23
 })
24 24
 
25
-const { productCart, onDeleteProduct, onEditProduct, totalProductPrice } =
26
-  useProductCart(form, props.purchaseDetail)
25
+const { productCart, totalProductPrice } = useProductCart(
26
+  form,
27
+  props.purchaseDetail
28
+)
27 29
 </script>
28 30
 
29 31
 <template>
@@ -40,17 +42,44 @@ const { productCart, onDeleteProduct, onEditProduct, totalProductPrice } =
40 42
               </template>
41 43
               <template #content>
42 44
                 <div class="grid">
43
-                  <div class="col">
44
-                    <h3 class="text-base">Nomor Pembelian</h3>
45
-                    <span>{{ number }}</span>
45
+                  <div class="col-12">
46
+                    <div class="grid">
47
+                      <div class="col">
48
+                        <h3 class="text-base">Nama</h3>
49
+                        <span>{{ supplier.name }}</span>
50
+                      </div>
51
+                      <div class="col">
52
+                        <h3 class="text-base">Alamat</h3>
53
+                        <span>{{ supplier.address }}</span>
54
+                      </div>
55
+                      <div class="col">
56
+                        <h3 class="text-base">No HP</h3>
57
+                        <span>{{ supplier.phone }}</span>
58
+                      </div>
59
+                      <div class="col">
60
+                        <h3 class="text-base">NPWP</h3>
61
+                        <span>{{ supplier.npwp }}</span>
62
+                      </div>
63
+                    </div>
46 64
                   </div>
47
-                  <div class="col">
48
-                    <h3 class="text-base">Status Pembelian</h3>
49
-                    <span>{{ status }}</span>
50
-                  </div>
51
-                  <div class="col">
52
-                    <h3 class="text-base">Total Harga</h3>
53
-                    <span>{{ IDRCurrencyFormat(totalProductPrice()) }}</span>
65
+                  <div class="col-12">
66
+                    <div class="grid">
67
+                      <div class="col">
68
+                        <h3 class="text-base">Nomor Pembelian</h3>
69
+                        <span>{{ number }}</span>
70
+                      </div>
71
+                      <div class="col">
72
+                        <h3 class="text-base">Status Pembelian</h3>
73
+                        <span>{{ status }}</span>
74
+                      </div>
75
+                      <div class="col">
76
+                        <h3 class="text-base">Total Harga</h3>
77
+                        <span>{{
78
+                          IDRCurrencyFormat(totalProductPrice())
79
+                        }}</span>
80
+                      </div>
81
+                      <div class="col"></div>
82
+                    </div>
54 83
                   </div>
55 84
                 </div>
56 85
               </template>

+ 15
- 1
resources/js/pages/Sales/Components/Cart.vue Целия файл

@@ -14,6 +14,18 @@ defineProps({
14 14
     required: true,
15 15
     type: Array,
16 16
   },
17
+  btnEditShow: {
18
+    default: true,
19
+    type: Boolean,
20
+  },
21
+  btnDeleteShow: {
22
+    default: true,
23
+    type: Boolean,
24
+  },
25
+  btnPpnDisabled: {
26
+    default: false,
27
+    type: Boolean,
28
+  },
17 29
   checkedPpn: Boolean,
18 30
 })
19 31
 
@@ -42,6 +54,7 @@ const editingRows = ref([])
42 54
         <input
43 55
           type="checkbox"
44 56
           id="ppn"
57
+          :disabled="btnPpnDisabled"
45 58
           :checked="checkedPpn"
46 59
           @input="$emit('update:checkedPpn', $event.target.checked)"
47 60
         />
@@ -80,11 +93,12 @@ const editingRows = ref([])
80 93
       </template>
81 94
     </Column>
82 95
 
83
-    <Column :row-editor="true" />
96
+    <Column v-if="btnEditShow" :row-editor="true" />
84 97
 
85 98
     <Column>
86 99
       <template #body="{ index }">
87 100
         <Button
101
+          v-if="btnDeleteShow"
88 102
           icon="pi pi-trash"
89 103
           class="p-button-icon-only p-button-rounded p-button-text"
90 104
           v-tooltip.bottom="'hapus'"

+ 22
- 6
resources/js/pages/Sales/Create.vue Целия файл

@@ -1,4 +1,5 @@
1 1
 <script setup>
2
+import { computed } from 'vue'
2 3
 import { optionStatus } from './config'
3 4
 import { cartTable } from './config'
4 5
 import Details from './Components/Details.vue'
@@ -26,7 +27,7 @@ const props = defineProps({
26 27
 })
27 28
 
28 29
 const form = useForm({
29
-  status: 'pending',
30
+  status: 'success',
30 31
   price: null,
31 32
   qty: null,
32 33
   customer: null,
@@ -48,17 +49,21 @@ const onSubmit = () => {
48 49
       onSuccess: () => {
49 50
         form.reset()
50 51
 
51
-        onClearProduct()
52
+        onClearProductCart()
52 53
       },
53 54
     })
54 55
 }
55 56
 
57
+const dropdownStatus = computed(() => {
58
+  return optionStatus.filter((val) => val.value != 'pending')
59
+})
60
+
56 61
 const {
57 62
   productCart,
58 63
   onAddProduct,
64
+  onClearProductCart,
59 65
   onDeleteProduct,
60 66
   onEditProduct,
61
-  onClearProduct,
62 67
   totalProductPrice,
63 68
 } = useProductCart(form)
64 69
 
@@ -81,7 +86,7 @@ const { onShowCustomerCreate } = onShowDialog()
81 86
                     <AppDropdown
82 87
                       label="Status"
83 88
                       placeholder="status"
84
-                      :options="optionStatus"
89
+                      :options="dropdownStatus"
85 90
                       :error="form.errors.status"
86 91
                       v-model="form.status"
87 92
                     />
@@ -151,7 +156,13 @@ const { onShowCustomerCreate } = onShowDialog()
151 156
                     </AppAutoComplete>
152 157
                   </div>
153 158
 
159
+                  <Divider type="dashed" />
160
+
154 161
                   <template v-if="form.product?.number">
162
+                    <div class="col-12">
163
+                      <h3 class="text-lg">Riwayat Pembelian Sebelumnya</h3>
164
+                    </div>
165
+
155 166
                     <div class="col-12 md:col-6">
156 167
                       <AppInputText
157 168
                         disabled
@@ -164,10 +175,15 @@ const { onShowCustomerCreate } = onShowDialog()
164 175
                     <div class="col-12 md:col-6">
165 176
                       <AppInputNumber
166 177
                         disabled
167
-                        label="Harga Beli"
168
-                        placeholder="harga beli produk"
178
+                        class="mb-0"
179
+                        label="Harga"
180
+                        placeholder="harga"
169 181
                         v-model="form.product.price"
170 182
                       />
183
+
184
+                      <span v-if="form.product.ppn" class="text-xs">
185
+                        Harga sudah termasuk PPN {{ ppn }} %
186
+                      </span>
171 187
                     </div>
172 188
 
173 189
                     <div class="col-12 md:col-6">

+ 3
- 3
resources/js/pages/Sales/Index.vue Целия файл

@@ -58,10 +58,10 @@ defineProps({
58 58
       <Column>
59 59
         <template #body="{ data }">
60 60
           <AppButtonLink
61
-            icon="pi pi-pencil"
61
+            icon="pi pi-eye"
62 62
             class="p-button-icon-only p-button-rounded p-button-text"
63
-            v-tooltip.bottom="'Ubah Penjualan'"
64
-            :href="route('sales.edit', data.id)"
63
+            v-tooltip.bottom="'Lihat Detail Penjualan'"
64
+            :href="route('sales.show', data.id)"
65 65
           />
66 66
         </template>
67 67
       </Column>

+ 103
- 0
resources/js/pages/Sales/Show.vue Целия файл

@@ -0,0 +1,103 @@
1
+<script setup>
2
+import { useForm } from '@/composables/useForm'
3
+import { IDRCurrencyFormat } from '@/utils/currencyFormat'
4
+import { cartTable } from './config'
5
+import Cart from './Components/Cart.vue'
6
+import { useProductCart } from './Composables/useProductCart'
7
+import DashboardLayout from '@/layouts/Dashboard/DashboardLayout.vue'
8
+
9
+const props = defineProps({
10
+  number: String,
11
+  ppn: Number,
12
+  status: String,
13
+  ppnChecked: Boolean,
14
+  customer: Object,
15
+  saleDetail: Array,
16
+})
17
+
18
+const form = useForm({
19
+  status: props.status,
20
+  customer: props.customer,
21
+  ppn: props.ppn,
22
+  checkedPpn: props.ppnChecked,
23
+})
24
+
25
+const { productCart, totalProductPrice } = useProductCart(
26
+  form,
27
+  props.saleDetail
28
+)
29
+</script>
30
+
31
+<template>
32
+  <DashboardLayout title="Lihat Pembelian">
33
+    <DynamicDialog />
34
+
35
+    <div class="grid">
36
+      <div class="col-12 md:col-8">
37
+        <div class="grid">
38
+          <div class="col-12">
39
+            <Card>
40
+              <template #title>
41
+                <h2 class="text-2xl font-bold">Detail Pembelian</h2>
42
+              </template>
43
+              <template #content>
44
+                <div class="grid">
45
+                  <div class="col-12">
46
+                    <div class="grid">
47
+                      <div class="col">
48
+                        <h3 class="text-base">Nama</h3>
49
+                        <span>{{ customer.name }}</span>
50
+                      </div>
51
+                      <div class="col">
52
+                        <h3 class="text-base">Alamat</h3>
53
+                        <span>{{ customer.address }}</span>
54
+                      </div>
55
+                      <div class="col">
56
+                        <h3 class="text-base">No HP</h3>
57
+                        <span>{{ customer.phone }}</span>
58
+                      </div>
59
+                      <div class="col">
60
+                        <h3 class="text-base">NPWP</h3>
61
+                        <span>{{ customer.npwp }}</span>
62
+                      </div>
63
+                    </div>
64
+                  </div>
65
+                  <div class="col-12">
66
+                    <div class="grid">
67
+                      <div class="col">
68
+                        <h3 class="text-base">Nomor Pembelian</h3>
69
+                        <span>{{ number }}</span>
70
+                      </div>
71
+                      <div class="col">
72
+                        <h3 class="text-base">Status Pembelian</h3>
73
+                        <span>{{ status }}</span>
74
+                      </div>
75
+                      <div class="col">
76
+                        <h3 class="text-base">Total Harga</h3>
77
+                        <span>{{
78
+                          IDRCurrencyFormat(totalProductPrice())
79
+                        }}</span>
80
+                      </div>
81
+                      <div class="col"></div>
82
+                    </div>
83
+                  </div>
84
+                </div>
85
+              </template>
86
+            </Card>
87
+          </div>
88
+          <div class="col-12">
89
+            <Cart
90
+              title="Keranjang Produk"
91
+              :product-cart="productCart"
92
+              :header-table="cartTable"
93
+              :btn-ppn-disabled="true"
94
+              :btn-delete-show="false"
95
+              :btn-edit-show="false"
96
+              v-model:checked-ppn="form.checkedPpn"
97
+            />
98
+          </div>
99
+        </div>
100
+      </div>
101
+    </div>
102
+  </DashboardLayout>
103
+</template>

+ 0
- 1
resources/js/pages/Sales/config.js Целия файл

@@ -13,7 +13,6 @@ export const indexTable = [
13 13
   { field: 'updatedAt', header: 'Tanggal' },
14 14
   { field: 'name', header: 'Nama Pelanggan' },
15 15
   { field: 'phone', header: 'No HP Pelanggan' },
16
-  { field: 'email', header: 'Email Pelanggan' },
17 16
   { field: 'price', header: 'Total Harga' },
18 17
   { field: 'status', header: 'Status' },
19 18
 ]