Selaa lähdekoodia

sale and purchase master

Muhammad Iqbal Afandi 4 vuotta sitten
vanhempi
commit
bbc1703c51

+ 1
- 0
app/Http/Controllers/PurchaseController.php Näytä tiedosto

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

+ 24
- 101
app/Http/Controllers/SalesController.php Näytä tiedosto

6
 use App\Models\Sale;
6
 use App\Models\Sale;
7
 use Inertia\Inertia;
7
 use Inertia\Inertia;
8
 use App\Models\Customer;
8
 use App\Models\Customer;
9
-use App\Models\SaleDetail;
10
 use App\Models\StockProduct;
9
 use App\Models\StockProduct;
11
 use App\Services\HelperService;
10
 use App\Services\HelperService;
12
 use Illuminate\Support\Facades\DB;
11
 use Illuminate\Support\Facades\DB;
42
                         "phone" => $sale->customer->phone,
41
                         "phone" => $sale->customer->phone,
43
                         "email" => $sale->customer->email,
42
                         "email" => $sale->customer->email,
44
                         "price" => HelperService::setRupiahFormat(
43
                         "price" => HelperService::setRupiahFormat(
45
-                            SaleDetail::totalPrice($sale)
44
+                            $sale->saleDetail->sum("price")
46
                         ),
45
                         ),
47
                         "status" => $sale->status,
46
                         "status" => $sale->status,
48
                     ]
47
                     ]
75
                             "number" => $stockProduct->product_number,
74
                             "number" => $stockProduct->product_number,
76
                             "name" => $stockProduct->product->name,
75
                             "name" => $stockProduct->product->name,
77
                             "price" => $stockProduct->price,
76
                             "price" => $stockProduct->price,
77
+                            "ppn" => $stockProduct->ppn,
78
                             "qty" => $stockProduct->qty,
78
                             "qty" => $stockProduct->qty,
79
                             "unit" => $stockProduct->product->unit,
79
                             "unit" => $stockProduct->product->unit,
80
                         ]
80
                         ]
91
      */
91
      */
92
     public function store(StoreSaleRequest $request)
92
     public function store(StoreSaleRequest $request)
93
     {
93
     {
94
-        dd($request->validated());
95
-
96
         DB::beginTransaction();
94
         DB::beginTransaction();
97
 
95
 
98
         try {
96
         try {
118
                 $sale->saleDetail()->create($validated);
116
                 $sale->saleDetail()->create($validated);
119
 
117
 
120
                 if ($request->status == "success") {
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
             DB::commit();
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
         } catch (QueryException $e) {
132
         } catch (QueryException $e) {
136
             DB::rollBack();
133
             DB::rollBack();
137
 
134
 
147
      */
144
      */
148
     public function show(Sale $sale)
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
             "id" => $sale->id,
148
             "id" => $sale->id,
163
             "number" => $sale->number,
149
             "number" => $sale->number,
164
             "ppn" => Ppn::first()->ppn,
150
             "ppn" => Ppn::first()->ppn,
165
             "status" => $sale->status,
151
             "status" => $sale->status,
166
             "ppnChecked" => $sale->ppn ? true : false,
152
             "ppnChecked" => $sale->ppn ? true : false,
167
             "customer" => $sale->customer,
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
             "saleDetail" => $sale->saleDetail->transform(
154
             "saleDetail" => $sale->saleDetail->transform(
185
                 fn($sale) => [
155
                 fn($sale) => [
186
                     "id" => $sale->id,
156
                     "id" => $sale->id,
187
                     "number" => $sale->product_number,
157
                     "number" => $sale->product_number,
188
                     "name" => $sale->product->name,
158
                     "name" => $sale->product->name,
189
-                    "price" => $sale->price,
159
+                    "price" => $sale->getRawOriginal("price"),
190
                     "qty" => $sale->qty,
160
                     "qty" => $sale->qty,
191
                     "unit" => $sale->product->unit,
161
                     "unit" => $sale->product->unit,
192
                 ]
162
                 ]
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
      * Update the specified resource in storage.
179
      * Update the specified resource in storage.
199
      *
180
      *
203
      */
184
      */
204
     public function update(UpdateSaleRequest $request, Sale $sale)
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 Näytä tiedosto

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

+ 39
- 0
app/Models/SaleDetail.php Näytä tiedosto

12
     use HasFactory;
12
     use HasFactory;
13
 
13
 
14
     protected $fillable = ["price", "qty", "sale_number", "product_number"];
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 Näytä tiedosto

2
 
2
 
3
 namespace App\Models;
3
 namespace App\Models;
4
 
4
 
5
-use Illuminate\Database\Eloquent\Factories\HasFactory;
5
+use App\Models\Ppn;
6
+use App\Services\HelperService;
6
 use Illuminate\Database\Eloquent\Model;
7
 use Illuminate\Database\Eloquent\Model;
8
+use Illuminate\Database\Eloquent\Casts\Attribute;
9
+use Illuminate\Database\Eloquent\Factories\HasFactory;
7
 
10
 
8
 class StockProduct extends Model
11
 class StockProduct extends Model
9
 {
12
 {
11
 
14
 
12
     protected $fillable = ["price", "qty", "ppn", "product_number"];
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
     public function product()
30
     public function product()
15
     {
31
     {
16
         return $this->belongsTo(Product::class, "product_number", "number");
32
         return $this->belongsTo(Product::class, "product_number", "number");

+ 63
- 64
lang/en/messages.php Näytä tiedosto

1
 <?php
1
 <?php
2
 
2
 
3
 return [
3
 return [
4
-
5
     /*
4
     /*
6
     |--------------------------------------------------------------------------
5
     |--------------------------------------------------------------------------
7
     | Authentication Language Lines
6
     | Authentication Language Lines
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 Näytä tiedosto

1
 <?php
1
 <?php
2
 
2
 
3
 return [
3
 return [
4
-
5
     /*
4
     /*
6
     |--------------------------------------------------------------------------
5
     |--------------------------------------------------------------------------
7
     | Authentication Language Lines
6
     | Authentication Language Lines
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 Näytä tiedosto

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

+ 4
- 2
resources/js/pages/Purchases/Create.vue Näytä tiedosto

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

+ 1
- 1
resources/js/pages/Purchases/Index.vue Näytä tiedosto

67
             v-else
67
             v-else
68
             icon="pi pi-eye"
68
             icon="pi pi-eye"
69
             class="p-button-icon-only p-button-rounded p-button-text"
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
             :href="route('purchases.show', data.id)"
71
             :href="route('purchases.show', data.id)"
72
           />
72
           />
73
         </template>
73
         </template>

+ 41
- 12
resources/js/pages/Purchases/Show.vue Näytä tiedosto

22
   checkedPpn: props.ppnChecked,
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
 </script>
29
 </script>
28
 
30
 
29
 <template>
31
 <template>
40
               </template>
42
               </template>
41
               <template #content>
43
               <template #content>
42
                 <div class="grid">
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
                   </div>
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
                   </div>
83
                   </div>
55
                 </div>
84
                 </div>
56
               </template>
85
               </template>

+ 15
- 1
resources/js/pages/Sales/Components/Cart.vue Näytä tiedosto

14
     required: true,
14
     required: true,
15
     type: Array,
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
   checkedPpn: Boolean,
29
   checkedPpn: Boolean,
18
 })
30
 })
19
 
31
 
42
         <input
54
         <input
43
           type="checkbox"
55
           type="checkbox"
44
           id="ppn"
56
           id="ppn"
57
+          :disabled="btnPpnDisabled"
45
           :checked="checkedPpn"
58
           :checked="checkedPpn"
46
           @input="$emit('update:checkedPpn', $event.target.checked)"
59
           @input="$emit('update:checkedPpn', $event.target.checked)"
47
         />
60
         />
80
       </template>
93
       </template>
81
     </Column>
94
     </Column>
82
 
95
 
83
-    <Column :row-editor="true" />
96
+    <Column v-if="btnEditShow" :row-editor="true" />
84
 
97
 
85
     <Column>
98
     <Column>
86
       <template #body="{ index }">
99
       <template #body="{ index }">
87
         <Button
100
         <Button
101
+          v-if="btnDeleteShow"
88
           icon="pi pi-trash"
102
           icon="pi pi-trash"
89
           class="p-button-icon-only p-button-rounded p-button-text"
103
           class="p-button-icon-only p-button-rounded p-button-text"
90
           v-tooltip.bottom="'hapus'"
104
           v-tooltip.bottom="'hapus'"

+ 22
- 6
resources/js/pages/Sales/Create.vue Näytä tiedosto

1
 <script setup>
1
 <script setup>
2
+import { computed } from 'vue'
2
 import { optionStatus } from './config'
3
 import { optionStatus } from './config'
3
 import { cartTable } from './config'
4
 import { cartTable } from './config'
4
 import Details from './Components/Details.vue'
5
 import Details from './Components/Details.vue'
26
 })
27
 })
27
 
28
 
28
 const form = useForm({
29
 const form = useForm({
29
-  status: 'pending',
30
+  status: 'success',
30
   price: null,
31
   price: null,
31
   qty: null,
32
   qty: null,
32
   customer: null,
33
   customer: null,
48
       onSuccess: () => {
49
       onSuccess: () => {
49
         form.reset()
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
 const {
61
 const {
57
   productCart,
62
   productCart,
58
   onAddProduct,
63
   onAddProduct,
64
+  onClearProductCart,
59
   onDeleteProduct,
65
   onDeleteProduct,
60
   onEditProduct,
66
   onEditProduct,
61
-  onClearProduct,
62
   totalProductPrice,
67
   totalProductPrice,
63
 } = useProductCart(form)
68
 } = useProductCart(form)
64
 
69
 
81
                     <AppDropdown
86
                     <AppDropdown
82
                       label="Status"
87
                       label="Status"
83
                       placeholder="status"
88
                       placeholder="status"
84
-                      :options="optionStatus"
89
+                      :options="dropdownStatus"
85
                       :error="form.errors.status"
90
                       :error="form.errors.status"
86
                       v-model="form.status"
91
                       v-model="form.status"
87
                     />
92
                     />
151
                     </AppAutoComplete>
156
                     </AppAutoComplete>
152
                   </div>
157
                   </div>
153
 
158
 
159
+                  <Divider type="dashed" />
160
+
154
                   <template v-if="form.product?.number">
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
                     <div class="col-12 md:col-6">
166
                     <div class="col-12 md:col-6">
156
                       <AppInputText
167
                       <AppInputText
157
                         disabled
168
                         disabled
164
                     <div class="col-12 md:col-6">
175
                     <div class="col-12 md:col-6">
165
                       <AppInputNumber
176
                       <AppInputNumber
166
                         disabled
177
                         disabled
167
-                        label="Harga Beli"
168
-                        placeholder="harga beli produk"
178
+                        class="mb-0"
179
+                        label="Harga"
180
+                        placeholder="harga"
169
                         v-model="form.product.price"
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
                     </div>
187
                     </div>
172
 
188
 
173
                     <div class="col-12 md:col-6">
189
                     <div class="col-12 md:col-6">

+ 3
- 3
resources/js/pages/Sales/Index.vue Näytä tiedosto

58
       <Column>
58
       <Column>
59
         <template #body="{ data }">
59
         <template #body="{ data }">
60
           <AppButtonLink
60
           <AppButtonLink
61
-            icon="pi pi-pencil"
61
+            icon="pi pi-eye"
62
             class="p-button-icon-only p-button-rounded p-button-text"
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
         </template>
66
         </template>
67
       </Column>
67
       </Column>

+ 103
- 0
resources/js/pages/Sales/Show.vue Näytä tiedosto

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 Näytä tiedosto

13
   { field: 'updatedAt', header: 'Tanggal' },
13
   { field: 'updatedAt', header: 'Tanggal' },
14
   { field: 'name', header: 'Nama Pelanggan' },
14
   { field: 'name', header: 'Nama Pelanggan' },
15
   { field: 'phone', header: 'No HP Pelanggan' },
15
   { field: 'phone', header: 'No HP Pelanggan' },
16
-  { field: 'email', header: 'Email Pelanggan' },
17
   { field: 'price', header: 'Total Harga' },
16
   { field: 'price', header: 'Total Harga' },
18
   { field: 'status', header: 'Status' },
17
   { field: 'status', header: 'Status' },
19
 ]
18
 ]