Merge remote-tracking branch 'origin/master'

This commit is contained in:
omair saleh
2021-09-23 15:35:19 +08:00
12 changed files with 300 additions and 53 deletions
@@ -0,0 +1,75 @@
<?php
namespace App\Classes\Modules\Accounts\ControllersLogic;
use App\Classes\Exceptions\ErrorException;
use App\Classes\General\Abstracts\AbstractControllerLogic;
use App\Classes\Modules\Accounts\Processors\CreateUserProcessor;
use App\Classes\Modules\Accounts\Processors\GenerateEmailVerificationAttemptProcessor;
use App\Classes\Modules\Companies\DataTransferObjects\EmploymentObject;
use App\Classes\Modules\Companies\Processors\AssignEmployeeProcessor;
use App\Classes\ValueObjects\Constants\ApprovalStatus;
use App\Classes\ValueObjects\Constants\RoleTypes;
use App\Models\User;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\App;
use Illuminate\Support\Facades\Auth;
class AddNewMemberLogic extends AbstractControllerLogic
{
/**
* @var AssignEmployeeProcessor
*/
private $assignEmployeeProcessor;
/** @var CreateUserProcessor */
private $createUserProcessor;
/**
* @var GenerateEmailVerificationAttemptProcessor
*/
private $generateEmailVerificationAttemptProcessor;
public function notification(): array
{
return [
'title' => 'Updated Email',
'message' => 'Successfully updated email'
];
}
public function __construct(CreateUserProcessor $createUserProcessor, AssignEmployeeProcessor $assignEmployeeProcessor, GenerateEmailVerificationAttemptProcessor $generateEmailVerificationAttemptProcessor)
{
$this->createUserProcessor = $createUserProcessor;
$this->assignEmployeeProcessor = $assignEmployeeProcessor;
$this->generateEmailVerificationAttemptProcessor = $generateEmailVerificationAttemptProcessor;
}
public function logic(Request $request): JsonResponse
{
$new_email = $request->input('name');
$user = Auth::user();
$company = $user->company()->first();
$user->email = $new_email;
request()->request->add([
'name' => $user->name,
'email' => $new_email,
'password' => $user->getAuthPassword(),
'password_confirmation' => $user->getAuthPassword()
]);
/** @var User $user */
$user = $this->createUserProcessor->execute($request, RoleTypes::USER, ApprovalStatus::PENDING_VERIFICATION);
$Object = new EmploymentObject($company, $user);
$this->assignEmployeeProcessor->execute($Object);
$this->generateEmailVerificationAttemptProcessor->execute($user);
return $this->response([
'message' => 'test'
]);
}
}
@@ -12,16 +12,24 @@ class CalculatesBookingCurrencyAverageRate
public function execute(Booking $booking, $type){
if ($type == TransactionType::PAYMENT) {
return $booking->transactions()
$amount_without_service = $booking->transactions()
->where('type', TransactionType::PAYMENT)
->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])
->avg('currency_rate');
->selectRaw('ROUND(amount,2)-ROUND(service_charge,2) AS amount_without_service')
->get()->sum('amount_without_service');
return number_format($booking->fix_amount/$amount_without_service,2);
}
else if ($type == TransactionType::BILL) {
return $booking->transactions()
$amount_without_service = $booking->transactions()
->where('type', TransactionType::BILL)
->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])
->avg('currency_rate');
->selectRaw('ROUND(amount,2)-ROUND(service_charge,2) AS amount_without_service')
->get()->sum('amount_without_service');
return number_format($booking->fix_amount/$amount_without_service,2);
}
}
@@ -0,0 +1,17 @@
<?php
namespace App\Http\Controllers\Companies;
use App\Classes\Modules\Accounts\ControllersLogic\AddNewMemberLogic;
use App\Http\Controllers\Controller;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
class AddNewMemberController
{
public function create(Request $request, AddNewMemberLogic $execute) : JsonResponse
{
return $execute->logic($request);
}
}
@@ -39,7 +39,7 @@
</div>
</div>
<div class="col-auto p-l-5 p-r-5 bg-success requestModal pointer" data-type="paymentProofModal">
<div class="row align-items-center h-100">
<div @click="selectedID(item.id)" class="row align-items-center h-100">
<div class="col">
<svg xmlns="http://www.w3.org/2000/svg" x="0px" y="0px"
width="30" height="30"
@@ -49,7 +49,7 @@
</div>
</div>
<modal-component type="paymentProofModal">
<payment-proof-form-component section="paymentProofSection" :id="item.id" :data="item"></payment-proof-form-component>
<payment-proof-form-component v-if="selected_id == item.id" section="paymentProofSection" :id="item.id" :data="item"></payment-proof-form-component>
</modal-component>
</div>
</div>
@@ -63,6 +63,16 @@
<script>
import componentHandler from '../../../general/mixins/componentHandler';
export default {
data(){
return {
selected_id: '',
}
},
methods: {
selectedID(id){
this.selected_id = id;
}
},
mixins: [componentHandler]
}
</script>
@@ -37,7 +37,7 @@
<div class="font-heading fs-11 muted" v-text="$store.getters.getUserEmail"></div>
</div>
<div class="col-auto p-r-0">
<div class="btn btn-xs btn-default bg-master-lighter btn-rounded p-r-20 p-l-15">
<div class="btn btn-xs btn-default bg-master-lighter btn-rounded p-r-20 p-l-15 requestModal" data-type="editEmail">
<i class="fa fa-envelope-open-o m-r-10"></i>Request Email Change
</div>
</div>
@@ -50,6 +50,10 @@
<modal-component class="animate__animated animate__fast animate__fadeIn" styleType="fill-in" type="resetPassword">
<reset-user-password-form-component :data="{email: $store.getters.getUserEmail}" section="resetPassword"></reset-user-password-form-component>
</modal-component>
<modal-component class="animate__animated animate__fast animate__fadeIn" styleType="fill-in" type="editEmail">
<edit-email-form-component :data="{email: $store.getters.getUserEmail}" section="editEmail"></edit-email-form-component>
</modal-component>
</div>
</template>
@@ -0,0 +1,51 @@
<template>
<div class="row">
<div class="col">
<div class="row">
<div class="col">
<div class="row m-b-10">
<div class="col">
<h3 class="all-caps m-b-5 bold no-margin">Edit Email Address</h3>
</div>
</div>
<div class="row m-b-10">
<div class="col">
<div class="fs-12">Email Address</div>
<validation-wrapper-component :validator="$v.parameters.name">
<input type="text" class="form-control" v-model="parameters.name">
</validation-wrapper-component>
</div>
</div>
<div class="row m-b-5 animate__animated animate__fadeInUpBig animate__fast" v-if="error">
<div class="col">
<small class="bold fs-10 text-danger">{{error}}</small>
</div>
</div>
<div class="row">
<div class="col p-r-5">
<div class="btn btn-sm btn-default bg-master-lightest btn-block b-rad-none" data-dismiss="modal">Cancel</div>
</div>
<div class="col p-l-5">
<div class="btn btn-sm btn-success btn-block b-rad-none" @click="submit(route('api.company.team.create', $store.getters.getUserId), 'post', section, true, true)">Update</div>
</div>
</div>
</div>
</div>
</div>
</div>
</template>
<script>
import updateProfileFormValidation from '../../../general/mixins/accounts/validation/updateProfileFormValidation';
export default {
data(){
return {
error: '',
parameters: {
name: ''
}
}
},
mixins: [updateProfileFormValidation]
}
</script>
@@ -34,7 +34,7 @@
<div class="ref">REF: {{ $invoice_transaction->payment_reference ?? '-' }}</div>
<div class="date">Date: {{ $invoice_transaction->created_at }}</div>
<div class="date">Date: {{ $po_order_transaction->created_at }}</div>
<div>&nbsp;</div>
</div>
</td>
@@ -77,18 +77,22 @@
<th class="stock-code" width="10%">Stock Code</th>
<th class="description">Description</th>
<th width="10%">Quantity</th>
<th width="12%">Unit Price (RM)</th>
<th width="15%">Unit Price (RM)</th>
<th width="10%">Total Amount<br>(RM)</th>
</tr>
</thead>
<tbody>
@php
$subtotal = 0;
@endphp
@foreach ($po_order_transaction->transactionDetails as $key => $transaction_detail)
<tr>
<td width="5%" class="center top">{{ $key + 1 }}</td>
<td class="stock-code top" width="10%">{{ $transaction_detail->product_code }}</td>
<td class="description">{{ $transaction_detail->product_name }}</td>
<td width="10%" class="center top">{{ $transaction_detail->quantity }}</td>
<td width="12%" class="center top">
<td width="15%" class="center top">
@if($invoice_transaction->booking()->first()->fix_currency_id !== 1)
{{ number_format( (1/$invoice_transaction->currency_rate) * $transaction_detail->price, 2) }}
@else
@@ -97,9 +101,18 @@
</td>
<td width="20%" class="right top">
@if($invoice_transaction->booking()->first()->fix_currency_id !== 1)
{{ number_format( (1/$invoice_transaction->currency_rate) * $transaction_detail->amount, 2) }}
@else
{{ number_format($transaction_detail->amount, 2) }}
{{ number_format((float)number_format( (1/$invoice_transaction->currency_rate) * $transaction_detail->price, 2,'.','')*$transaction_detail->quantity,2) }}
@php
$subtotal += number_format((float)number_format( (1/$invoice_transaction->currency_rate) * $transaction_detail->price, 2,'.','')*$transaction_detail->quantity,2,'.','');
@endphp
@else
{{ number_format((float)number_format($transaction_detail->price, 2,'.','')*$transaction_detail->quantity,2) }}
@php
$subtotal += number_format((float)number_format($transaction_detail->price, 2,'.','')*$transaction_detail->quantity,2,'.','');
@endphp
@endif
</td>
</tr>
@@ -110,11 +123,7 @@
<td colspan="4"></td>
<td class="right middle">Subtotal</td>
<td class="right middle">
@if($invoice_transaction->booking()->first()->fix_currency_id !== 1)
{{ number_format( (1/$invoice_transaction->currency_rate) * $invoice_transaction->amount, 2) }}
@else
{{ number_format($invoice_transaction->amount, 2) }}
@endif
{{ number_format($subtotal, 2) }}
</td>
</tr>
<tr class="billingcharges">
@@ -124,6 +133,17 @@
{{ number_format($invoice_transaction->service_charge, 2) }}
</td>
</tr>
<tr class="billingcharges">
<td colspan="4"></td>
<td class="right">Adjustment</td>
<td class="right">
@if($invoice_transaction->booking()->first()->fix_currency_id !== 1)
{{ number_format((float)number_format( (1/$invoice_transaction->currency_rate) * $invoice_transaction->amount, 2,'.','') - (float)number_format($subtotal, 2,'.',''),2) }}
@else
{{ number_format((float)number_format($invoice_transaction->amount, 2,'.','') - (float)number_format($subtotal, 2,'.',''),2) }}
@endif
</td>
</tr>
@if($invoice_transaction->tax > 0)
<tr class="billingcharges">
<td colspan="4"></td>
+31 -11
View File
@@ -33,7 +33,7 @@
<div class="ref">Ref# {{ $invoice_transaction->payment_reference ?? '-' }}</div>
<div class="date">Date: {{ $invoice_transaction->created_at }}</div>
<div class="date">Date: {{ $po_order_transaction->created_at }}</div>
<div>&nbsp;</div>
</div>
</td>
@@ -76,18 +76,22 @@
<th class="stock-code" width="10%">Stock Code</th>
<th class="description">Description</th>
<th width="10%">Quantity</th>
<th width="12%">Unit Price (RM)</th>
<th width="15%">Unit Price (RM)</th>
<th width="10%">Total Amount<br>(RM)</th>
</tr>
</thead>
<tbody>
@php
$subtotal = 0;
@endphp
@foreach ($po_order_transaction->transactionDetails as $key => $transaction_detail)
<tr>
<td width="5%" class="center top">{{ $key + 1 }}</td>
<td class="stock-code top" width="10%">{{ $transaction_detail->product_code }}</td>
<td class="description">{{ $transaction_detail->product_name }}</td>
<td width="10%" class="center top">{{ $transaction_detail->quantity }}</td>
<td width="12%" class="center top">
<td width="15%" class="center top">
@if($invoice_transaction->booking()->first()->fix_currency_id !== 1)
{{ number_format( (1/$invoice_transaction->currency_rate) * $transaction_detail->price, 2) }}
@else
@@ -96,9 +100,18 @@
</td>
<td width="20%" class="right top">
@if($invoice_transaction->booking()->first()->fix_currency_id !== 1)
{{ number_format( (1/$invoice_transaction->currency_rate) * $transaction_detail->amount, 2) }}
@else
{{ number_format($transaction_detail->amount, 2) }}
{{ number_format((float)number_format( (1/$invoice_transaction->currency_rate) * $transaction_detail->price, 2,'.','')*$transaction_detail->quantity,2) }}
@php
$subtotal += number_format((float)number_format( (1/$invoice_transaction->currency_rate) * $transaction_detail->price, 2,'.','')*$transaction_detail->quantity,2,'.','');
@endphp
@else
{{ number_format((float)number_format($transaction_detail->price, 2,'.','')*$transaction_detail->quantity,2) }}
@php
$subtotal += number_format((float)number_format($transaction_detail->price, 2,'.','')*$transaction_detail->quantity,2,'.','');
@endphp
@endif
</td>
</tr>
@@ -109,11 +122,7 @@
<td colspan="4"></td>
<td class="right middle">Subtotal</td>
<td class="right middle">
@if($invoice_transaction->booking()->first()->fix_currency_id !== 1)
{{ number_format( (1/$invoice_transaction->currency_rate) * $invoice_transaction->amount, 2) }}
@else
{{ number_format($invoice_transaction->amount, 2) }}
@endif
{{ number_format($subtotal, 2) }}
</td>
</tr>
<tr class="billingcharges">
@@ -123,6 +132,17 @@
{{ number_format($invoice_transaction->service_charge, 2) }}
</td>
</tr>
<tr class="billingcharges">
<td colspan="4"></td>
<td class="right">Adjustment</td>
<td class="right">
@if($invoice_transaction->booking()->first()->fix_currency_id !== 1)
{{ number_format((float)number_format( (1/$invoice_transaction->currency_rate) * $invoice_transaction->amount, 2,'.','') - (float)number_format($subtotal, 2,'.',''),2) }}
@else
{{ number_format((float)number_format($invoice_transaction->amount, 2,'.','') - (float)number_format($subtotal, 2,'.',''),2) }}
@endif
</td>
</tr>
@if($invoice_transaction->tax > 0)
<tr class="billingcharges">
<td colspan="4"></td>
@@ -81,18 +81,22 @@
<th class="stock-code" width="10%">Stock Code</th>
<th class="description">Description</th>
<th width="10%">Quantity</th>
<th width="12%">Unit Price (RM)</th>
<th width="15%">Unit Price (RM)</th>
<th width="10%">Total Amount<br>(RM)</th>
</tr>
</thead>
<tbody>
@php
$subtotal = 0;
@endphp
@foreach ($po_order_transaction->transactionDetails as $key => $transaction_detail)
<tr>
<td width="5%" class="center top">{{ $key + 1 }}</td>
<td class="stock-code top" width="10%">{{ $transaction_detail->product_code }}</td>
<td class="description">{{ $transaction_detail->product_name }}</td>
<td width="10%" class="center top">{{ $transaction_detail->quantity }}</td>
<td width="12%" class="center top">
<td width="15%" class="center top">
@if($invoice_transaction->booking()->first()->fix_currency_id !== 1)
{{ number_format( (1/$invoice_transaction->currency_rate) * $transaction_detail->price, 2) }}
@else
@@ -101,9 +105,18 @@
</td>
<td width="20%" class="right top">
@if($invoice_transaction->booking()->first()->fix_currency_id !== 1)
{{ number_format( (1/$invoice_transaction->currency_rate) * $transaction_detail->amount, 2) }}
@else
{{ number_format($transaction_detail->amount, 2) }}
{{ number_format((float)number_format( (1/$invoice_transaction->currency_rate) * $transaction_detail->price, 2,'.','')*$transaction_detail->quantity,2) }}
@php
$subtotal += number_format((float)number_format( (1/$invoice_transaction->currency_rate) * $transaction_detail->price, 2,'.','')*$transaction_detail->quantity,2,'.','');
@endphp
@else
{{ number_format((float)number_format($transaction_detail->price, 2,'.','')*$transaction_detail->quantity,2) }}
@php
$subtotal += number_format((float)number_format($transaction_detail->price, 2,'.','')*$transaction_detail->quantity,2,'.','');
@endphp
@endif
</td>
</tr>
@@ -112,13 +125,9 @@
<tfoot>
<tr class="subtotal">
<td colspan="4"></td>
<td class="right middle">Subtotal</td>
<td class="right middle">Subtotal</td>
<td class="right middle">
@if($invoice_transaction->booking()->first()->fix_currency_id !== 1)
{{ number_format( (1/$invoice_transaction->currency_rate) * $invoice_transaction->amount, 2) }}
@else
{{ number_format($invoice_transaction->amount, 2) }}
@endif
{{ number_format($subtotal, 2) }}
</td>
</tr>
<tr class="billingcharges">
@@ -128,6 +137,17 @@
{{ number_format($invoice_transaction->service_charge, 2) }}
</td>
</tr>
<tr class="billingcharges">
<td colspan="4"></td>
<td class="right">Adjustment</td>
<td class="right">
@if($invoice_transaction->booking()->first()->fix_currency_id !== 1)
{{ number_format((float)number_format( (1/$invoice_transaction->currency_rate) * $invoice_transaction->amount, 2,'.','') - (float)number_format($subtotal, 2,'.',''),2) }}
@else
{{ number_format((float)number_format($invoice_transaction->amount, 2,'.','') - (float)number_format($subtotal, 2,'.',''),2) }}
@endif
</td>
</tr>
@if($invoice_transaction->tax > 0)
<tr class="billingcharges">
<td colspan="4"></td>
@@ -20,7 +20,7 @@
<td class="document-detail">
PO#: {{ $supplier_deliver_order_transaction->bill_no }} <br>
Ref#: {{ $supplier_deliver_order_transaction->payment_reference ?? '-' }} <br>
Date: {{ $supplier_deliver_order_transaction->created_at }}
Date: {{ $po_order_transaction->created_at }}
</td>
</tr>
</table>
@@ -66,18 +66,22 @@
<th class="stock-code" width="10%">Stock Code</th>
<th class="description">Description</th>
<th width="10%">Quantity</th>
<th width="12%">Unit Price (RM)</th>
<th width="15%">Unit Price (RM)</th>
<th width="10%">Total Amount<br>(RM)</th>
</tr>
</thead>
<tbody>
@php
$subtotal = 0;
@endphp
@foreach ($po_order_transaction->transactionDetails as $key => $transaction_detail)
<tr>
<td width="5%" class="center top">{{ $key + 1 }}</td>
<td class="stock-code top" width="10%">{{ $transaction_detail->product_code }}</td>
<td class="description">{{ $transaction_detail->product_name }}</td>
<td width="10%" class="center top">{{ $transaction_detail->quantity }}</td>
<td width="12%" class="center top">
<td width="15%" class="center top">
@if($supplier_deliver_order_transaction->booking()->first()->fix_currency_id !== 1)
{{ number_format( (1/$supplier_deliver_order_transaction->currency_rate) * $transaction_detail->price, 2) }}
@else
@@ -86,9 +90,18 @@
</td>
<td width="20%" class="right top">
@if($supplier_deliver_order_transaction->booking()->first()->fix_currency_id !== 1)
{{ number_format( (1/$supplier_deliver_order_transaction->currency_rate) * $transaction_detail->amount, 2) }}
@else
{{ number_format($transaction_detail->amount, 2) }}
{{ number_format((float)number_format( (1/$supplier_deliver_order_transaction->currency_rate) * $transaction_detail->price, 2,'.','')*$transaction_detail->quantity,2) }}
@php
$subtotal += number_format((float)number_format( (1/$supplier_deliver_order_transaction->currency_rate) * $transaction_detail->price, 2,'.','')*$transaction_detail->quantity,2,'.','');
@endphp
@else
{{ number_format((float)number_format($transaction_detail->price, 2,'.','')*$transaction_detail->quantity,2) }}
@php
$subtotal += number_format((float)number_format($transaction_detail->price, 2,'.','')*$transaction_detail->quantity,2,'.','');
@endphp
@endif
</td>
</tr>
@@ -99,10 +112,17 @@
<td colspan="4"></td>
<td class="right middle">Subtotal</td>
<td class="right middle">
@if($supplier_deliver_order_transaction->booking()->first()->fix_currency_id !== 1)
{{ number_format( (1/$supplier_deliver_order_transaction->currency_rate) * $supplier_deliver_order_transaction->amount, 2) }}
@else
{{ number_format($supplier_deliver_order_transaction->amount, 2) }}
{{ number_format($subtotal, 2) }}
</td>
</tr>
<tr class="billingcharges">
<td colspan="4"></td>
<td class="right">Adjustment</td>
<td class="right">
@if($supplier_deliver_order_transaction->booking()->first()->fix_currency_id !== 1)
{{ number_format((float)number_format( (1/$supplier_deliver_order_transaction->currency_rate) * $supplier_deliver_order_transaction->amount, 2,'.','') - (float)number_format($subtotal, 2,'.',''),2) }}
@else
{{ number_format((float)number_format($supplier_deliver_order_transaction->amount, 2,'.','') - (float)number_format($subtotal, 2,'.',''),2) }}
@endif
</td>
</tr>
+2 -2
View File
@@ -515,7 +515,7 @@
<div class="col-4 p-r-0">
<div class="row">
<div class="col">
<div class="row tabsContainer" v-if="$store.getters.isAdmin">
<div class="row tabsContainer">
<div class="col">
<div class="row m-l-0 m-r-0 d-none d-md-flex">
<div class="col" v-if="$store.getters.isAdmin">
@@ -570,7 +570,7 @@
<div class="row tabsContainer tabContent" tab-name="customer-list" v-if="$store.getters.isAdmin">
<company-quick-view-section-component></company-quick-view-section-component>
</div>
<div class="row tabsContainer tabContent hide" tab-name="announcement-list">
<div class="row tabsContainer tabContent hide" v-else tab-name="announcement-list">
<announcement-quick-view-section-component></announcement-quick-view-section-component>
</div>
<div class="row tabsContainer hide tabContent" tab-name="PO">
+3 -1
View File
@@ -9,6 +9,8 @@ Route::group(['prefix' => 'company', 'as' => 'company.', 'namespace' => 'Compani
Route::put('/update/{id}', 'UpdateCompanyController@update')->name('update');
Route::delete('/delete/{id}', 'DeleteCompanyController@destroy')->name('delete');
Route::post('/team/create', 'AddNewMemberController@create')->name('team.create');
Route::group(['prefix' => '{id}/segment', 'as' => 'segment.'], function () {
Route::post('/assign', 'AssignCompanyToSegmentController@assign')->name('assign');
Route::delete('/detach/{segment_id}', 'RemoveCompanyFromSegmentController@detach')->name('detach');
@@ -25,4 +27,4 @@ Route::group(['prefix' => 'company', 'as' => 'company.', 'namespace' => 'Compani
Route::put('/{document_id}/approval/{status}', 'ApproveIdentificationDocumentController@approve')->where('status', 'approve|reject')->name('approval');
});
});
});