Skip to content

Commit 8388f33

Browse files
committedJan 9, 2025·
ledger account feature removed
1 parent 7d62b41 commit 8388f33

File tree

12 files changed

+55
-367
lines changed

12 files changed

+55
-367
lines changed
 

‎Modules/Client/Entities/Client.php

-27
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
use Modules\Client\Entities\Scopes\ClientGlobalScope;
1111
use Modules\Client\Entities\Traits\HasHierarchy;
1212
use Modules\Invoice\Entities\Invoice;
13-
use Modules\Invoice\Entities\LedgerAccount;
1413
use Modules\Invoice\Services\InvoiceService;
1514
use Modules\Project\Entities\Project;
1615
use Modules\Prospect\Entities\Prospect;
@@ -352,32 +351,6 @@ public function getBccEmailsAttribute()
352351
return substr_replace($bccEmails, '', -1);
353352
}
354353

355-
public function ledgerAccounts()
356-
{
357-
return $this->hasMany(LedgerAccount::class);
358-
}
359-
360-
public function ledgerAccountsOnlyCredit()
361-
{
362-
return $this->hasMany(LedgerAccount::class)->whereNotNull('credit');
363-
}
364-
365-
public function ledgerAccountsOnlyDebit()
366-
{
367-
return $this->hasMany(LedgerAccount::class)->whereNotNull('debit');
368-
}
369-
370-
public function getClientProjectsTotalLedgerAmount($quarter = null)
371-
{
372-
$amount = 0;
373-
374-
foreach ($this->clientLevelBillingProjects as $project) {
375-
$amount += $project->getTotalLedgerAmount($quarter);
376-
}
377-
378-
return $amount;
379-
}
380-
381354
public function getResourceBasedTotalAmount()
382355
{
383356
$amount = 0;

‎Modules/Invoice/Entities/LedgerAccount.php

-39
This file was deleted.

‎Modules/Invoice/Http/Controllers/InvoiceController.php

-14
Original file line numberDiff line numberDiff line change
@@ -203,20 +203,6 @@ public function yearlyInvoiceReportExport(Request $request)
203203
return $this->service->yearlyInvoiceReportExport($filters, $request);
204204
}
205205

206-
public function ledgerAccountsIndex(Request $request)
207-
{
208-
$data = $this->service->getLedgerAccountData($request->all());
209-
210-
return view('invoice::ledger-accounts.index')->with($data);
211-
}
212-
213-
public function storeLedgerAccountData(Request $request)
214-
{
215-
$this->service->storeLedgerAccountData($request->all());
216-
217-
return redirect()->back()->with('status', 'Data saved successfully.');
218-
}
219-
220206
public function createCustomInvoice()
221207
{
222208
return view('invoice::create-custom-invoice', $this->service->create());

‎Modules/Invoice/Resources/views/index.blade.php

+6-8
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ class="ml-2"
151151
@endif
152152
</a>
153153
</td>
154-
154+
155155
<td class="text-center">
156156
{{ $invoice->sent_on->format(config('invoice.default-date-format')) }}</td>
157157
<td
@@ -196,7 +196,7 @@ class="{{ $invoice->shouldHighlighted() ? 'font-weight-bold text-danger' : '' }}
196196
$index++;
197197
$currencySymbol = config('constants.currency.' . $client->currency . '.symbol');
198198
if ($client->hasCustomInvoiceTemplate()) {
199-
$amount = $currencySymbol . ($client->getResourceBasedTotalAmount() + $client->getClientProjectsTotalLedgerAmount($quarter));
199+
$amount = $currencySymbol . ($client->getResourceBasedTotalAmount());
200200
} else {
201201
$amount = $currencySymbol . $client->getTotalPayableAmountForTerm($monthToSubtract, $client->clientLevelBillingProjects);
202202
}
@@ -284,11 +284,9 @@ class="{{ $invoice->shouldHighlighted() ? 'font-weight-bold text-danger' : '' }}
284284
@endif
285285
@php
286286
$index++;
287-
287+
288288
$currencySymbol = config('constants.currency.' . $project->client->currency . '.symbol');
289-
if ($project->hasCustomInvoiceTemplate()) {
290-
$amount = $currencySymbol . $project->getTotalLedgerAmount($quarter);
291-
} elseif (optional($project->client->billingDetails)->service_rate_term == config('client.service-rate-terms.per_resource.slug')) {
289+
if (optional($project->client->billingDetails)->service_rate_term == config('client.service-rate-terms.per_resource.slug')) {
292290
$amount = $currencySymbol . $project->getResourceBillableAmount();
293291
} else {
294292
$amount = $currencySymbol . $project->getTotalPayableAmountForTerm($monthToSubtract);
@@ -414,7 +412,7 @@ class="{{ $invoice->shouldHighlighted() ? 'font-weight-bold text-danger' : '' }}
414412
{{ config('constants.finance.scheduled-invoice.status.' . $invoice->currentStatus. '.title') }}
415413
</div>
416414
</td>
417-
</tr>
415+
</tr>
418416
@endforeach
419417
@else
420418
<tr>
@@ -423,7 +421,7 @@ class="{{ $invoice->shouldHighlighted() ? 'font-weight-bold text-danger' : '' }}
423421
@endif
424422
</tbody>
425423
</table>
426-
424+
427425
@endif
428426
</div>
429427
@if (request()->invoice_status == 'ready' || $invoiceStatus == 'ready')

‎Modules/Invoice/Resources/views/ledger-accounts/index.blade.php

-151
This file was deleted.

‎Modules/Invoice/Resources/views/render/custom-invoice-template-1.blade.php

+7-31
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
border-collapse: collapse;
6565
}
6666
.table-padding {
67-
padding-left: 7%;
67+
padding-left: 7%;
6868
padding-right: 7%;
6969
}
7070
.fz-14 {
@@ -154,7 +154,7 @@
154154
</div>
155155
</td>
156156
<td>
157-
{{ $client->country->currency_symbol . ($project->getResourceBillableAmount() + $project->getTotalLedgerAmount($quarter)) }}
157+
{{ $client->country->currency_symbol . ($project->getResourceBillableAmount()) }}
158158
</td>
159159
</tr>
160160
<tr></tr>
@@ -173,7 +173,7 @@
173173
</div>
174174
</td>
175175
<td>
176-
{{ $client->country->currency_symbol . ($client->getResourceBasedTotalAmount() + $client->getClientProjectsTotalLedgerAmount($quarter)) }}
176+
{{ $client->country->currency_symbol . ($client->getResourceBasedTotalAmount()) }}
177177
</td>
178178
</tr>
179179
<tr>
@@ -188,7 +188,7 @@
188188
<tr>
189189
<td class="font-weight-bold">
190190
<div class="font-weight-bold fz-14">
191-
{{ '(' . strtoupper(App\Helpers\DecimalToWordsHelper::convertDecimalToWords(($client->getResourceBasedTotalAmount() + $client->getClientProjectsTotalLedgerAmount($quarter)), config('constants.currency.' . $client->country->currency . '.name'))) . ')' }}
191+
{{ '(' . strtoupper(App\Helpers\DecimalToWordsHelper::convertDecimalToWords($client->getResourceBasedTotalAmount(), config('constants.currency.' . $client->country->currency . '.name'))) . ')' }}
192192
</div>
193193
</td>
194194
</tr>
@@ -251,49 +251,25 @@
251251
</td>
252252
</tr>
253253
@endforeach
254-
@foreach ($projects as $project)
255-
@foreach ($project->ledgerAccountsOnlyCredit()->quarter($quarter)->get() as $ledgerAccountRow )
256-
<tr>
257-
<td class="p-5 w-70p">
258-
{{ $ledgerAccountRow->particulars }}
259-
</td>
260-
<td class="p-5 text-right">
261-
{{ $client->country->currency_symbol . $ledgerAccountRow->credit }}
262-
</td>
263-
</tr>
264-
@endforeach
265-
@endforeach
266254
<tr class="font-weight-bold">
267255
<td class="p-5 w-70p">
268256
{{ __('Total: ') }}
269257
</td>
270258
<td class="p-5 text-right">
271-
{{ $client->country->currency_symbol . ($client->getResourceBasedTotalAmount() + $client->ledgerAccountsOnlyCredit->sum('credit')) }}
259+
{{ $client->country->currency_symbol . ($client->getResourceBasedTotalAmount()) }}
272260
</td>
273261
</tr>
274-
@foreach ($projects as $project)
275-
@foreach ($project->ledgerAccountsOnlyDebit()->quarter($quarter)->get() as $ledgerAccountRow)
276-
<tr>
277-
<td class="p-5 w-70p">
278-
{{ $ledgerAccountRow->particulars }}
279-
</td>
280-
<td class="p-5 text-right">
281-
{{ __('-') . $client->country->currency_symbol . $ledgerAccountRow->debit }}
282-
</td>
283-
</tr>
284-
@endforeach
285-
@endforeach
286262
<tr class="font-weight-bold">
287263
<td class="p-5 w-70p">
288264
{{ __('Balance: ') }}
289265
</td>
290266
<td class="p-5 text-right">
291-
{{ $client->country->currency_symbol . ($client->getResourceBasedTotalAmount() + $client->getClientProjectsTotalLedgerAmount($quarter)) }}
267+
{{ $client->country->currency_symbol . ($client->getResourceBasedTotalAmount()) }}
292268
</td>
293269
</tr>
294270
</tbody>
295271
</table>
296272
</div>
297273
</div>
298274
</body>
299-
</html>
275+
</html>

‎Modules/Invoice/Routes/web.php

-4
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,3 @@
4646
Route::get('/{invoiceId}/{filename}', 'InvoiceController@getInvoiceFile')->name('invoice.get-file');
4747
Route::get('/yearly-invoice-report-export', 'InvoiceController@yearlyInvoiceReportExport')->name('invoice.yearly-report-export');
4848
});
49-
Route::middleware('auth')->group(function () {
50-
Route::get('ledger-accounts', 'InvoiceController@ledgerAccountsIndex')->name('ledger-accounts.index');
51-
Route::post('ledger-accounts', 'InvoiceController@storeLedgerAccountData')->name('ledger-accounts.store');
52-
});

‎Modules/Invoice/Services/InvoiceService.php

+2-47
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
use Modules\Invoice\Emails\SendPaymentReceivedMail;
2121
use Modules\Invoice\Emails\SendPendingInvoiceMail;
2222
use Modules\Invoice\Entities\Invoice;
23-
use Modules\Invoice\Entities\LedgerAccount;
2423
use Modules\Invoice\Exports\MonthlyGSTTaxReportExport;
2524
use Modules\Invoice\Exports\TaxReportExport;
2625
use Modules\Invoice\Exports\YearlyInvoiceReportExport;
@@ -629,14 +628,14 @@ public function createInvoice($client, $project, $term, $periodStartDate, $perio
629628

630629
if ($project) {
631630
if (optional($project->client->billingDetails)->service_rate_term == config('client.service-rate-terms.per_resource.slug')) {
632-
$amount = $project->getResourceBillableAmount() + $project->getTotalLedgerAmount();
631+
$amount = $project->getResourceBillableAmount();
633632
} else {
634633
$amount = $project->getBillableAmountForTerm($monthsToSubtract, $periodStartDate, $periodEndDate) + optional($project->client->billingDetails)->bank_charges;
635634
$gst = $project->getTaxAmountForTerm($monthsToSubtract, $periodStartDate, $periodEndDate);
636635
}
637636
} else {
638637
if (optional($client->billingDetails)->service_rate_term == config('client.service-rate-terms.per_resource.slug')) {
639-
$amount = $client->getResourceBasedTotalAmount() + $client->getClientProjectsTotalLedgerAmount();
638+
$amount = $client->getResourceBasedTotalAmount();
640639
} else {
641640
$amount = $client->getBillableAmountForTerm($monthsToSubtract, $client->clientLevelBillingProjects, $periodStartDate, $periodEndDate) + optional($client->billingDetails)->bank_charges;
642641
$gst = $client->getTaxAmountForTerm($monthsToSubtract, $client->clientLevelBillingProjects, $periodStartDate, $periodEndDate);
@@ -734,50 +733,6 @@ public function clientCurrency($clientId)
734733
return Client::find($clientId, 'id')->currency;
735734
}
736735

737-
public function getLedgerAccountData(array $data)
738-
{
739-
$clients = Client::with('projects')->orderBy('name')->get();
740-
$client = Client::find($data['client_id'] ?? null);
741-
$project = Project::find($data['project_id'] ?? null);
742-
743-
return [
744-
'clients' => $clients,
745-
'client' => $client,
746-
'project' => $project,
747-
'ledgerAccountData' => $project ? $project->ledgerAccounts->toArray() : ($client ? $client->ledgerAccounts->toArray() : []),
748-
];
749-
}
750-
751-
public function storeLedgerAccountData(array $data)
752-
{
753-
$project = Project::find($data['project_id'] ?? null);
754-
$client = Client::find($data['client_id'] ?? null);
755-
756-
if (! $client) {
757-
return;
758-
}
759-
760-
if ($project) {
761-
$ledgerAccountsIdToDelete = LedgerAccount::where('project_id', $project->id)->pluck('id')->toArray();
762-
} else {
763-
$ledgerAccountsIdToDelete = LedgerAccount::where('client_id', $client->id)->pluck('id')->toArray();
764-
}
765-
766-
foreach ($data['ledger_account_data'] as $ledgerAccountData) {
767-
if ($ledgerAccountData['id'] == null) {
768-
LedgerAccount::create($ledgerAccountData);
769-
continue;
770-
}
771-
772-
$ledgerAccount = LedgerAccount::find($ledgerAccountData['id']);
773-
$ledgerAccount->update($ledgerAccountData);
774-
$index = array_search($ledgerAccount->id, $ledgerAccountsIdToDelete);
775-
unset($ledgerAccountsIdToDelete[$index]);
776-
}
777-
778-
LedgerAccount::destroy($ledgerAccountsIdToDelete);
779-
}
780-
781736
public function updateScheduledInvoice($invoice)
782737
{
783738
$project = $invoice->project;

‎Modules/Project/Entities/Project.php

-24
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
use Modules\Client\Entities\Client;
1313
use Modules\EffortTracking\Entities\Task;
1414
use Modules\Invoice\Entities\Invoice;
15-
use Modules\Invoice\Entities\LedgerAccount;
1615
use Modules\Invoice\Services\InvoiceService;
1716
use Modules\Project\Database\Factories\ProjectFactory;
1817
use Modules\User\Entities\User;
@@ -428,29 +427,6 @@ public function scopeBillable($query, $billable = true)
428427
return $query->where('type', $billable ? '<>' : '=', 'non-billable');
429428
}
430429

431-
public function ledgerAccounts()
432-
{
433-
return $this->hasMany(LedgerAccount::class);
434-
}
435-
436-
public function ledgerAccountsOnlyCredit()
437-
{
438-
return $this->ledgerAccounts()->whereNotNull('credit');
439-
}
440-
441-
public function ledgerAccountsOnlyDebit()
442-
{
443-
return $this->ledgerAccounts()->whereNotNull('debit');
444-
}
445-
446-
public function getTotalLedgerAmount($quarter = null)
447-
{
448-
$amount = 0;
449-
$amount += optional($this->ledgerAccountsOnlyCredit()->quarter($quarter))->get()->sum('credit') - optional($this->ledgerAccountsOnlyDebit()->quarter($quarter))->get()->sum('debit');
450-
451-
return $amount;
452-
}
453-
454430
public function hasCustomInvoiceTemplate()
455431
{
456432
$template = config('invoice.templates.invoice.projects.' . $this->name);

‎app/Console/Commands/FakeProdDataCommand.php

-21
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
use Modules\HR\Entities\HRRejectionReason;
1717
use Modules\HR\Entities\UniversityContact;
1818
use Modules\Invoice\Entities\Invoice;
19-
use Modules\Invoice\Entities\LedgerAccount;
2019
use Modules\Project\Entities\Project;
2120
use Modules\Salary\Entities\EmployeeSalary;
2221

@@ -184,26 +183,6 @@ private function fakeFinanceTablesData()
184183

185184
$invoice->update();
186185
}
187-
188-
foreach (LedgerAccount::all() as $ledgerAccount) {
189-
if ($ledgerAccount->particulars) {
190-
$ledgerAccount->particulars = $this->faker->sentences(2, true);
191-
}
192-
193-
if ($ledgerAccount->credit) {
194-
$ledgerAccount->credit = $this->faker->numberBetween(100, 100000);
195-
}
196-
197-
if ($ledgerAccount->debit) {
198-
$ledgerAccount->debit = $this->faker->numberBetween(100, 100000);
199-
}
200-
201-
if ($ledgerAccount->balance) {
202-
$ledgerAccount->balance = $ledgerAccount->credit - $ledgerAccount->debit;
203-
}
204-
205-
$ledgerAccount->update();
206-
}
207186
}
208187

209188
private function fakeProjectTablesData()
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?php
2+
3+
use Illuminate\Database\Migrations\Migration;
4+
use Illuminate\Database\Schema\Blueprint;
5+
use Illuminate\Support\Facades\Schema;
6+
7+
class DropLedgerAccountsTable extends Migration
8+
{
9+
/**
10+
* Run the migrations.
11+
*
12+
* @return void
13+
*/
14+
public function up()
15+
{
16+
Schema::dropIfExists('ledger_accounts');
17+
}
18+
19+
/**
20+
* Reverse the migrations.
21+
*
22+
* @return void
23+
*/
24+
public function down()
25+
{
26+
Schema::create('ledger_accounts', function (Blueprint $table) {
27+
$table->bigIncrements('id');
28+
$table->unsignedBigInteger('client_id');
29+
$table->unsignedBigInteger('project_id')->nullable();
30+
$table->date('date');
31+
$table->text('particulars')->nullable();
32+
$table->text('credit')->nullable();
33+
$table->text('debit')->nullable();
34+
$table->text('balance')->nullable();
35+
$table->timestamps();
36+
$table->foreign('client_id')->references('id')->on('clients');
37+
$table->foreign('project_id')->references('id')->on('projects');
38+
});
39+
}
40+
}

‎resources/views/layouts/navbar.blade.php

-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@
8383
<div class="dropdown-menu z-index-1100" aria-labelledby="navbarDropdown_finance">
8484
<a class="dropdown-item" href="{{ route('reports.finance.dashboard') }}">Reports</a>
8585
<a class="dropdown-item" href="{{ route('invoice.index') }}">Invoices</a>
86-
<a class="dropdown-item" href="{{ route('ledger-accounts.index') }}">Ledger Accounts</a>
8786
@can('employee_loan.view')
8887
<a class="dropdown-item" href="{{ route('employee-loan.index') }}">Employee Loans</a>
8988
@endcan

0 commit comments

Comments
 (0)
Please sign in to comment.