+ Hyperviseur and Superviseur history
This commit is contained in:
parent
848d9428c7
commit
3b330e1595
|
@ -141,8 +141,8 @@ class NanoCreditController extends Controller
|
|||
$walletHyper = Wallet::findOrFail($walletHyper->wallet_id);
|
||||
$walletUser = WalletsUser::where('idUser', $request->id_user)->firstOrFail();
|
||||
|
||||
$demande_credit->date_demande = new \DateTime();
|
||||
$demande_credit->date_remboursement_prevu = $demande_credit->date_demande->modify('+' . $request->duree_mois . ' month');
|
||||
$demande_credit->date_validation = new \DateTime();
|
||||
$demande_credit->date_remboursement_prevu = $demande_credit->date_validation->modify('+' . $request->duree_mois . ' month');
|
||||
$demande_credit->etat = 'VALIDE';
|
||||
|
||||
$montant_total = $demande_credit->montant + $demande_credit->interet + $demande_credit->taxe;
|
||||
|
@ -186,10 +186,6 @@ class NanoCreditController extends Controller
|
|||
|
||||
}
|
||||
|
||||
function sortFunction($a, $b)
|
||||
{
|
||||
return strtotime($b->date_creation) - strtotime($a->date_creation);
|
||||
}
|
||||
|
||||
// Demandes de nano credit et d'epargnes
|
||||
public function getAllNanoCreditsDemands($id_user, Request $request)
|
||||
|
@ -197,45 +193,69 @@ class NanoCreditController extends Controller
|
|||
$demandes = DB::select("SELECT 'N' as type_historique , i.* FROM infos_users_demandes_credits i WHERE id_user = :id ;", ['id' => $id_user]);
|
||||
$savings = DB::select("SELECT 'E' as type_historique , i.* FROM infos_users_epargnes i WHERE id_user = :id;", ['id' => $id_user]);
|
||||
|
||||
$merge = array_merge($demandes, $savings);
|
||||
usort($merge, array($this, 'sortFunction'));
|
||||
// Supprimer les underscore sur les etats
|
||||
$merge = array_map(function ($demand) {
|
||||
$demand->etat = str_replace('_', ' ', $demand->etat);
|
||||
return $demand;
|
||||
}, array_merge($demandes, $savings));
|
||||
|
||||
// return $this->successResponse($this->arrayPaginator($merge,$request));
|
||||
usort($merge, array($this, 'sortFunction')); // Trier le tout par date
|
||||
|
||||
return $this->successResponse($merge);
|
||||
return $this->successResponse($this->arrayPaginator($merge, $request));
|
||||
}
|
||||
|
||||
public function getNanoCreditsDemands($id_user)
|
||||
{
|
||||
$demandes = DB::select('SELECT * FROM infos_users_demandes_credits WHERE id_user = :id ORDER BY date_creation DESC;', ['id' => $id_user]);
|
||||
return $this->successResponse($demandes);
|
||||
|
||||
$result = array_map(function ($demand) {
|
||||
$demand->etat = str_replace('_', ' ', $demand->etat);
|
||||
return $demand;
|
||||
}, $demandes);
|
||||
return $this->successResponse($result);
|
||||
}
|
||||
|
||||
// Demandes de credits en cours pour le remboursement
|
||||
public function getNanoCreditsDemandsInProgress($id_user)
|
||||
{
|
||||
$demandes = DB::select("SELECT * FROM infos_users_demandes_credits WHERE id_user = :id AND etat = 'VALIDE' ORDER BY date_creation DESC;", ['id' => $id_user]);
|
||||
return $this->successResponse($demandes);
|
||||
$result = array_map(function ($demand) {
|
||||
$demand->etat = str_replace('_', ' ', $demand->etat);
|
||||
return $demand;
|
||||
}, $demandes);
|
||||
return $this->successResponse($result);
|
||||
}
|
||||
|
||||
public function getGuaranteeNanoCreditsDemands($id_wallet_agent)
|
||||
{
|
||||
$demandes = DB::select('SELECT * FROM infos_users_demandes_credits WHERE id_wallet_agent = :id ORDER BY date_creation DESC;'
|
||||
, ['id' => $id_wallet_agent]);
|
||||
return $this->successResponse($demandes);
|
||||
$result = array_map(function ($demand) {
|
||||
$demand->etat = str_replace('_', ' ', $demand->etat);
|
||||
return $demand;
|
||||
}, $demandes);
|
||||
return $this->successResponse($result);
|
||||
}
|
||||
|
||||
public function getSavingsDemands($id_user)
|
||||
{
|
||||
$savings = DB::select('SELECT * FROM infos_users_epargnes WHERE id_user = :id ORDER BY date_creation DESC;', ['id' => $id_user]);
|
||||
return $this->successResponse($savings);
|
||||
$result = array_map(function ($demand) {
|
||||
$demand->etat = str_replace('_', ' ', $demand->etat);
|
||||
return $demand;
|
||||
}, $savings);
|
||||
return $this->successResponse($result);
|
||||
}
|
||||
|
||||
// Demandes d'epargnes pour la cassation
|
||||
public function getSavingsDemandsInProgress($id_user)
|
||||
{
|
||||
$savings = DB::select("SELECT * FROM infos_users_epargnes WHERE id_user = :id AND etat = 'EN_COURS' ORDER BY date_creation DESC;", ['id' => $id_user]);
|
||||
return $this->successResponse($savings);
|
||||
$result = array_map(function ($demand) {
|
||||
$demand->etat = str_replace('_', ' ', $demand->etat);
|
||||
return $demand;
|
||||
}, $savings);
|
||||
return $this->successResponse($result);
|
||||
}
|
||||
|
||||
// Cautionner une demande de credit
|
||||
|
@ -280,8 +300,8 @@ class NanoCreditController extends Controller
|
|||
return $this->errorResponse(trans('errors.insufficient_balance'));
|
||||
|
||||
|
||||
$demande_credit->date_demande = new \DateTime();
|
||||
$demande_credit->date_remboursement_prevu = $demande_credit->date_demande->modify('+' . $demande_credit->duree_mois . ' month');
|
||||
$demande_credit->date_validation = new \DateTime();
|
||||
$demande_credit->date_remboursement_prevu = $demande_credit->date_validation->modify('+' . $demande_credit->duree_mois . ' month');
|
||||
$demande_credit->etat = 'VALIDE';
|
||||
$demande_credit->id_wallet_agent = $walletAgent->id;
|
||||
$user->balance_credit += $montant_total;
|
||||
|
@ -528,6 +548,7 @@ class NanoCreditController extends Controller
|
|||
{
|
||||
$demand = UsersDemandesCredit::where('id_demande', $id_demand)->first();
|
||||
if ($demand) {
|
||||
$demand->etat = str_replace('_', ' ', $demand->etat);
|
||||
return $this->successResponse($demand);
|
||||
} else {
|
||||
return $this->errorResponse(trans('errors.nano_credit_not_found'));
|
||||
|
@ -538,6 +559,7 @@ class NanoCreditController extends Controller
|
|||
{
|
||||
$demand = UsersEpargne::where('id_epargne', $id_saving)->first();
|
||||
if ($demand) {
|
||||
$demand->etat = str_replace('_', ' ', $demand->etat);
|
||||
return $this->successResponse($demand);
|
||||
} else {
|
||||
return $this->errorResponse(trans('errors.savings_not_found'));
|
||||
|
|
|
@ -4,6 +4,7 @@ namespace App\Http\Controllers;
|
|||
|
||||
use App\Models\ConfigWallet;
|
||||
use App\Models\Identification;
|
||||
use App\Models\User;
|
||||
use App\Models\UsersDemandesCredit;
|
||||
use App\Models\UsersGroup;
|
||||
use App\Models\UsersGroupsDemandesValidation;
|
||||
|
@ -13,7 +14,6 @@ use App\Models\WalletsUser;
|
|||
use App\Traits\ApiResponser;
|
||||
use App\Traits\Helper;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\User;
|
||||
use Illuminate\Http\Response;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
|
@ -593,8 +593,8 @@ ug.date_creation , ug.createur , ug.sponsor1 , ug.sponsor2 , ug.sponsor3, ug.cou
|
|||
|
||||
$montant_total = $demande_credit->montant + $demande_credit->frais + $demande_credit->taxe;
|
||||
|
||||
$demande_credit->date_demande = new \DateTime();
|
||||
$demande_credit->date_remboursement_prevu = $demande_credit->date_demande->modify('+' . $demande_credit->duree_mois . ' month');
|
||||
$demande_credit->date_validation = new \DateTime();
|
||||
$demande_credit->date_remboursement_prevu = $demande_credit->date_validation->modify('+' . $demande_credit->duree_mois . ' month');
|
||||
$demande_credit->etat = 'VALIDE';
|
||||
|
||||
$user->balance_credit += $montant_total;
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\User;
|
||||
use App\Models\WalletAgent;
|
||||
use App\Models\WalletsUser;
|
||||
use App\Traits\ApiResponser;
|
||||
use App\Traits\Helper;
|
||||
|
@ -106,11 +108,113 @@ class WalletController extends Controller
|
|||
INNER JOIN networks n2 ON n2.country_id = n1.country_id
|
||||
INNER JOIN configWallet cw ON cw.id_network = n2.id
|
||||
INNER JOIN countries_currencies cc ON cc.id = n2.country_id
|
||||
WHERE wu.idUser = :id_user AND cw.type = \'ilink\' LIMIT 1',['id_user' => $id_user]))->first();
|
||||
if($wallet){
|
||||
WHERE wu.idUser = :id_user AND cw.type = \'ilink\' LIMIT 1', ['id_user' => $id_user]))->first();
|
||||
if ($wallet) {
|
||||
return $this->successResponse($wallet);
|
||||
} else
|
||||
return $this->errorResponse(trans('errors.model_not_found',['model'=>'wallet']),Response::HTTP_BAD_REQUEST);
|
||||
return $this->errorResponse(trans('errors.model_not_found', ['model' => 'wallet']), Response::HTTP_BAD_REQUEST);
|
||||
}
|
||||
|
||||
//Les historiques globals des hyperviseur et superviseur
|
||||
public function hyperHistory($id_network, Request $request)
|
||||
{
|
||||
|
||||
$demandes = DB::select("SELECT 'N' as type_historique , i.* FROM infos_users_demandes_credits i WHERE id_network = :id ;", ['id' => $id_network]);
|
||||
$savings = DB::select("SELECT 'E' as type_historique , i.* FROM infos_users_epargnes i WHERE id_network = :id;", ['id' => $id_network]);
|
||||
|
||||
$transactions = DB::select("SELECT 'T' as type_historique, wit.id_transaction, tit.nom as operation , wit.montant ,wit.nom_emetteur, wit.prenom_emetteur, wit.id_wallet_user,wit.frais,wit.taxe,wit.id_destinataire,
|
||||
wit.nom_destinataire, wit.prenom_destinataire, wit.type , wit.id_wallet_user, wit.init_country, wit.final_country , wit.network_destinataire , wit.montant_net_final_country ,
|
||||
wit.date as date_creation , wit.id , wit.numero_carte, wit.montant_net FROM wallet_ilink_transaction wit
|
||||
INNER JOIN type_ilink_transaction tit ON wit.type = tit.id WHERE wit.network_emetteur = :id ;", ['id' => $id_network]);
|
||||
|
||||
$transactions_mapped = array_map(function ($data) {
|
||||
|
||||
$wallet_user = isset($data->id_wallet_user) ? WalletsUser::findOrFail($data->id_wallet_user) : null;
|
||||
$user_destinataire = isset($data->id_destinataire) ? User::where('user_code', $data->id_destinataire)->first() : null;
|
||||
$emetteur = $wallet_user ? $wallet_user->user->lastname . ' ' . $wallet_user->user->firstname : $data->prenom_emetteur . ' ' . $data->nom_emetteur;
|
||||
if (!$wallet_user && !$data->nom_emetteur)
|
||||
$emetteur = $data->numero_carte;
|
||||
$destinataire = in_array($data->type, [12, 16]) ? $emetteur : ($user_destinataire ? $user_destinataire->lastname . ' ' . $user_destinataire->firstname :
|
||||
$data->prenom_destinataire . ' ' . $data->nom_destinataire);
|
||||
$data->emetteur = $emetteur;
|
||||
$data->destinataire = $destinataire;
|
||||
$data->frais = $this->toMoney($data->frais + $data->taxe, $data->init_country);
|
||||
$data->montant_net_init = $this->toMoney($data->montant_net, $data->init_country);
|
||||
$data->montant_net_final = $data->montant_net_final_country ? $this->toMoney($data->montant_net_final_country, $data->final_country) : $data->montant_net_init;
|
||||
$data->montant = $this->toMoney($data->montant, $data->init_country);
|
||||
$data->init_country = $this->getCountryName($data->init_country);
|
||||
$data->final_country = $data->montant_net_final_country ? $this->getCountryName($data->final_country) : '';
|
||||
$data->reseau_payeur = isset($data->network_destinataire) ? $this->getNetworkName($data->network_destinataire) . ' ' . $data->final_country : null;
|
||||
|
||||
unset($data->type, $data->id_wallet_user, $data->network_destinataire, $data->nom_destinataire, $data->prenom_destinataire, $data->taxe, $data->numero_carte,
|
||||
$data->montant_net_final_country, $data->montant_net, $data->nom_emetteur, $data->prenom_emetteur, $data->id_destinataire);
|
||||
return $data;
|
||||
}, $transactions);
|
||||
|
||||
// Supprimer les underscore sur les etats
|
||||
$merge = array_map(function ($demand) {
|
||||
$demand->etat = str_replace('_', ' ', $demand->etat);
|
||||
return $demand;
|
||||
}, array_merge($demandes, $savings));
|
||||
|
||||
$result = array_merge($transactions_mapped, $merge);
|
||||
|
||||
usort($result, array($this, 'sortFunction')); // Trier le tout par date
|
||||
|
||||
// return $this->successResponse($this->arrayPaginator($result,$request));
|
||||
return $this->successResponse($result);
|
||||
|
||||
}
|
||||
|
||||
public function superHistory($id_wallet, Request $request)
|
||||
{
|
||||
|
||||
$walletSup = WalletAgent::where('wallet_id', $id_wallet)->firstOrFail();
|
||||
|
||||
$demandes = DB::select("SELECT 'N' as type_historique , i.* FROM infos_users_demandes_credits i WHERE id_network = :id ;", ['id' => $walletSup->codeMembre]);
|
||||
|
||||
|
||||
$transactions = DB::select("SELECT 'T' as type_historique, wit.id_transaction, tit.nom as operation , wit.montant ,wit.nom_emetteur, wit.prenom_emetteur, wit.id_wallet_user,wit.frais,wit.taxe,wit.id_destinataire,
|
||||
wit.nom_destinataire, wit.prenom_destinataire, wit.type , wit.id_wallet_user, wit.init_country, wit.final_country , wit.network_destinataire , wit.montant_net_final_country ,
|
||||
wit.date as date_creation , wit.id , wit.numero_carte, wit.montant_net FROM wallet_ilink_transaction wit
|
||||
INNER JOIN type_ilink_transaction tit ON wit.type = tit.id WHERE wit.id_wallet_sup = :id ;", ['id' => $id_wallet]);
|
||||
|
||||
$transactions_mapped = array_map(function ($data) {
|
||||
|
||||
$wallet_user = isset($data->id_wallet_user) ? WalletsUser::findOrFail($data->id_wallet_user) : null;
|
||||
$user_destinataire = isset($data->id_destinataire) ? User::where('user_code', $data->id_destinataire)->first() : null;
|
||||
$emetteur = $wallet_user ? $wallet_user->user->lastname . ' ' . $wallet_user->user->firstname : $data->prenom_emetteur . ' ' . $data->nom_emetteur;
|
||||
if (!$wallet_user && !$data->nom_emetteur)
|
||||
$emetteur = $data->numero_carte;
|
||||
$destinataire = in_array($data->type, [12, 16]) ? $emetteur : ($user_destinataire ? $user_destinataire->lastname . ' ' . $user_destinataire->firstname :
|
||||
$data->prenom_destinataire . ' ' . $data->nom_destinataire);
|
||||
$data->emetteur = $emetteur;
|
||||
$data->destinataire = $destinataire;
|
||||
$data->frais = $this->toMoney($data->frais + $data->taxe, $data->init_country);
|
||||
$data->montant_net_init = $this->toMoney($data->montant_net, $data->init_country);
|
||||
$data->montant_net_final = $data->montant_net_final_country ? $this->toMoney($data->montant_net_final_country, $data->final_country) : $data->montant_net_init;
|
||||
$data->montant = $this->toMoney($data->montant, $data->init_country);
|
||||
$data->init_country = $this->getCountryName($data->init_country);
|
||||
$data->final_country = $data->montant_net_final_country ? $this->getCountryName($data->final_country) : '';
|
||||
$data->reseau_payeur = isset($data->network_destinataire) ? $this->getNetworkName($data->network_destinataire) . ' ' . $data->final_country : null;
|
||||
|
||||
unset($data->type, $data->id_wallet_user, $data->network_destinataire, $data->nom_destinataire, $data->prenom_destinataire, $data->taxe, $data->numero_carte,
|
||||
$data->montant_net_final_country, $data->montant_net, $data->nom_emetteur, $data->prenom_emetteur, $data->id_destinataire);
|
||||
return $data;
|
||||
}, $transactions);
|
||||
|
||||
// Supprimer les underscore sur les etats
|
||||
$demandes_mapped = array_map(function ($demand) {
|
||||
$demand->etat = str_replace('_', ' ', $demand->etat);
|
||||
return $demand;
|
||||
}, $demandes);
|
||||
|
||||
$result = array_merge($transactions_mapped, $demandes_mapped);
|
||||
|
||||
usort($result, array($this, 'sortFunction')); // Trier le tout par date
|
||||
|
||||
// return $this->successResponse($this->arrayPaginator($result,$request));
|
||||
return $this->successResponse($result);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -138,7 +138,7 @@ class iLinkTransactionController extends Controller
|
|||
return $this->errorResponse(trans('errors.insufficient_balance'));
|
||||
} else {
|
||||
//Verification des limites reglementaires
|
||||
$rep = $this->checkReguationsLimits($walletUser->id, $init_country, $transaction->montant);
|
||||
$rep = $this->checkReguationsLimits($walletUser->id, $init_country, $request->final_country, $transaction->montant);
|
||||
if ($rep instanceof JsonResponse)
|
||||
return $rep;
|
||||
|
||||
|
@ -291,7 +291,7 @@ class iLinkTransactionController extends Controller
|
|||
return $this->errorResponse(trans('errors.insufficient_balance'));
|
||||
} else {
|
||||
//Verification des limites reglementaires
|
||||
$rep = $this->checkReguationsLimits($walletUser->id, $init_country, $transaction->montant);
|
||||
$rep = $this->checkReguationsLimits($walletUser->id, $init_country, $request->final_country, $transaction->montant);
|
||||
if ($rep instanceof JsonResponse)
|
||||
return $rep;
|
||||
|
||||
|
@ -712,7 +712,7 @@ class iLinkTransactionController extends Controller
|
|||
$transaction->final_country = $final_country = $user->network->country->id;
|
||||
|
||||
//Verification des limites reglementaires
|
||||
$rep = $this->checkReguationsLimits($walletUser->id, $init_country, $transaction->montant);
|
||||
$rep = $this->checkReguationsLimits($walletUser->id, $init_country, $final_country, $transaction->montant);
|
||||
if ($rep instanceof JsonResponse)
|
||||
return $rep;
|
||||
|
||||
|
@ -765,7 +765,7 @@ class iLinkTransactionController extends Controller
|
|||
return $this->errorResponse(trans('errors.insufficient_balance'));
|
||||
|
||||
//Verification des limites reglementaires
|
||||
$rep = $this->checkReguationsLimits($request->id_document_emetteur, $init_country, $transaction->montant, true);
|
||||
$rep = $this->checkReguationsLimits($request->id_document_emetteur, $init_country, $request->final_country, $transaction->montant, true);
|
||||
if ($rep instanceof JsonResponse)
|
||||
return $rep;
|
||||
|
||||
|
@ -901,7 +901,7 @@ class iLinkTransactionController extends Controller
|
|||
return $this->errorResponse(trans('errors.insufficient_balance'));
|
||||
|
||||
//Verification des limites reglementaires
|
||||
$rep = $this->checkReguationsLimits($request->id_document_emetteur, $init_country, $transaction->montant, true);
|
||||
$rep = $this->checkReguationsLimits($request->id_document_emetteur, $init_country, $request->final_country, $transaction->montant, true);
|
||||
if ($rep instanceof JsonResponse)
|
||||
return $rep;
|
||||
|
||||
|
@ -1062,8 +1062,8 @@ class iLinkTransactionController extends Controller
|
|||
$data->montant_net_final = $data->montant_net_final_country ? $this->toMoney($data->montant_net_final_country, $data->final_country) : $data->montant_net_init ;
|
||||
$data->montant = $this->toMoney($data->montant, $data->init_country);
|
||||
$data->init_country = $this->getCountryName($data->init_country);
|
||||
$data->final_country = $this->getCountryName($data->final_country);
|
||||
$data->reseau_payeur = isset($data->network_destinataire) ? $this->getNetworkName($data->network_destinataire).' '.$data->final_country : null;
|
||||
$data->final_country = $data->montant_net_final_country ? $this->getCountryName($data->final_country) : '';
|
||||
$data->reseau_payeur = isset($data->network_destinataire) ? $this->getNetworkName($data->network_destinataire) . ' ' . $data->final_country : null;
|
||||
$data->date = $date;
|
||||
unset($data->type, $data->id_wallet_user, $data->network_destinataire,$data->nom_destinataire, $data->prenom_destinataire ,$data->taxe,$data->numero_carte,
|
||||
$data->montant_net_final_country, $data->montant_net,$data->nom_emetteur, $data->prenom_emetteur ,$data->id_destinataire);
|
||||
|
@ -1411,7 +1411,7 @@ class iLinkTransactionController extends Controller
|
|||
}
|
||||
|
||||
//Verfier les limites reglementaires
|
||||
public function checkReguationsLimits($identifiant, $init_country, $montant_transaction, $is_id_document_emetteur = false)
|
||||
public function checkReguationsLimits($identifiant, $init_country, $final_country, $montant_transaction, $is_id_document_emetteur = false)
|
||||
{
|
||||
|
||||
$regulation = Regulation::where('id_country', $init_country)->first();
|
||||
|
@ -1421,34 +1421,36 @@ class iLinkTransactionController extends Controller
|
|||
|
||||
// Total montants journalier
|
||||
if ($is_id_document_emetteur)
|
||||
$daily_sum = WalletIlinkTransaction::where('id_document_emetteur', $identifiant)->whereDate('date', Carbon::today())->sum('montant');
|
||||
$daily_sum = WalletIlinkTransaction::where('id_document_emetteur', $identifiant)->where('final_country', $final_country)->whereDate('date', Carbon::today())->sum('montant');
|
||||
else
|
||||
$daily_sum = WalletIlinkTransaction::where('id_wallet_user', $identifiant)->whereDate('date', Carbon::today())->sum('montant');
|
||||
$amount_admitted = $regulation->montant_max_jour - $daily_sum;
|
||||
// dd(($daily_sum + $montant_transaction) > $regulation->montant_max_jour);
|
||||
if (($daily_sum + $montant_transaction) > $regulation->montant_max_jour)
|
||||
return $this->errorResponse(trans('errors.daily_regulations_limits_reached') . ' '
|
||||
$daily_sum = WalletIlinkTransaction::where('id_wallet_user', $identifiant)->where('final_country', $final_country)->whereDate('date', Carbon::today())->sum('montant');
|
||||
$max_jour = ($init_country == $final_country) ? $regulation->montant_max_jour_national : $regulation->montant_max_jour_international;
|
||||
$amount_admitted = $max_jour - $daily_sum;
|
||||
if (($daily_sum + $montant_transaction) > $max_jour)
|
||||
return $this->errorResponse(($init_country == $final_country) ? trans('errors.national_daily_regulations_limits_reached') : trans('errors.international_daily_regulations_limits_reached') . ' '
|
||||
. ($amount_admitted > 0 ? trans('errors.regulations_limits_amount_transaction', ['amount' => $this->toMoney($amount_admitted, $init_country)]) : ''));
|
||||
|
||||
// Total montants hebdomadaire
|
||||
if ($is_id_document_emetteur)
|
||||
$weekly_sum = WalletIlinkTransaction::where('id_document_emetteur', $identifiant)->whereBetween('date', [Carbon::today()->subDay(7), Carbon::today()])->sum('montant');
|
||||
$weekly_sum = WalletIlinkTransaction::where('id_document_emetteur', $identifiant)->where('final_country', $final_country)->whereBetween('date', [Carbon::today()->subDay(7), Carbon::today()])->sum('montant');
|
||||
else
|
||||
$weekly_sum = WalletIlinkTransaction::where('id_wallet_user', $identifiant)->whereBetween('date', [Carbon::today()->subDay(7), Carbon::today()])->sum('montant');
|
||||
$amount_admitted = $regulation->montant_max_hedbo - $weekly_sum;
|
||||
if (($weekly_sum + $montant_transaction) > $regulation->montant_max_hebdo)
|
||||
return $this->errorResponse(trans('errors.weekly_regulations_limits_reached') . ' '
|
||||
$weekly_sum = WalletIlinkTransaction::where('id_wallet_user', $identifiant)->where('final_country', $final_country)->whereBetween('date', [Carbon::today()->subDay(7), Carbon::today()])->sum('montant');
|
||||
$max_hebdo = ($init_country == $final_country) ? $regulation->montant_max_hedbo_national : $regulation->montant_max_hedbo_international;
|
||||
$amount_admitted = $max_hebdo - $weekly_sum;
|
||||
if (($weekly_sum + $montant_transaction) > $max_hebdo)
|
||||
return $this->errorResponse(($init_country == $final_country) ? trans('errors.national_weekly_regulations_limits_reached') : trans('errors.international_weekly_regulations_limits_reached') . ' '
|
||||
. ($amount_admitted > 0 ? trans('errors.regulations_limits_amount_transaction', ['amount' => $this->toMoney($amount_admitted, $init_country)]) : ''));
|
||||
|
||||
|
||||
// Total montants mensuel
|
||||
if ($is_id_document_emetteur)
|
||||
$monthly_sum = WalletIlinkTransaction::where('id_document_emetteur', $identifiant)->whereBetween('date', [Carbon::today()->subDay(30), Carbon::today()])->sum('montant');
|
||||
$monthly_sum = WalletIlinkTransaction::where('id_document_emetteur', $identifiant)->where('final_country', $final_country)->whereBetween('date', [Carbon::today()->subDay(30), Carbon::today()])->sum('montant');
|
||||
else
|
||||
$monthly_sum = WalletIlinkTransaction::where('id_wallet_user', $identifiant)->whereBetween('date', [Carbon::today()->subDay(30), Carbon::today()])->sum('montant');
|
||||
$amount_admitted = $regulation->montant_max_mensuel - $monthly_sum;
|
||||
if (($monthly_sum + $montant_transaction) > $regulation->montant_max_mensuel)
|
||||
return $this->errorResponse(trans('errors.monthly_regulations_limits_reached') . ' '
|
||||
$monthly_sum = WalletIlinkTransaction::where('id_wallet_user', $identifiant)->where('final_country', $final_country)->whereBetween('date', [Carbon::today()->subDay(30), Carbon::today()])->sum('montant');
|
||||
$max_mensuel = ($init_country == $final_country) ? $regulation->montant_max_mensuel_national : $regulation->montant_max_mensuel_international;
|
||||
$amount_admitted = $max_mensuel - $monthly_sum;
|
||||
if (($monthly_sum + $montant_transaction) > $max_mensuel)
|
||||
return $this->errorResponse(($init_country == $final_country) ? trans('errors.national_monthly_regulations_limits_reached') : trans('errors.international_monthly_regulations_limits_reached') . ' '
|
||||
. ($amount_admitted > 0 ? trans('errors.regulations_limits_amount_transaction', ['amount' => $this->toMoney($amount_admitted, $init_country)]) : ''));
|
||||
|
||||
}
|
||||
|
|
|
@ -13,9 +13,12 @@ use Illuminate\Database\Eloquent\Model;
|
|||
*
|
||||
* @property int $id
|
||||
* @property int $id_country
|
||||
* @property float $montant_max_jour
|
||||
* @property float $montant_max_hebdo
|
||||
* @property float $montant_max_mensuel
|
||||
* @property float $montant_max_jour_national
|
||||
* @property float $montant_max_hebdo_national
|
||||
* @property float $montant_max_mensuel_national
|
||||
* @property float $montant_max_jour_international
|
||||
* @property float $montant_max_hebdo_international
|
||||
* @property float $montant_max_mensuel_international
|
||||
*
|
||||
* @package App\Models
|
||||
*/
|
||||
|
@ -26,15 +29,21 @@ class Regulation extends Model
|
|||
|
||||
protected $casts = [
|
||||
'id_country' => 'int',
|
||||
'montant_max_jour' => 'float',
|
||||
'montant_max_hebdo' => 'float',
|
||||
'montant_max_mensuel' => 'float'
|
||||
'montant_max_jour_national' => 'float',
|
||||
'montant_max_hebdo_national' => 'float',
|
||||
'montant_max_mensuel_national' => 'float',
|
||||
'montant_max_jour_international' => 'float',
|
||||
'montant_max_hebdo_international' => 'float',
|
||||
'montant_max_mensuel_international' => 'float'
|
||||
];
|
||||
|
||||
protected $fillable = [
|
||||
'id_country',
|
||||
'montant_max_jour',
|
||||
'montant_max_hebdo',
|
||||
'montant_max_mensuel'
|
||||
'montant_max_jour_national',
|
||||
'montant_max_hebdo_national',
|
||||
'montant_max_mensuel_national',
|
||||
'montant_max_jour_international',
|
||||
'montant_max_hebdo_international',
|
||||
'montant_max_mensuel_international'
|
||||
];
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ use Illuminate\Database\Eloquent\Model;
|
|||
* @property string $etat
|
||||
* @property float $interet
|
||||
* @property float $taxe
|
||||
* @property Carbon $date_demande
|
||||
* @property Carbon $date_validation
|
||||
* @property Carbon $date_remboursement_prevu
|
||||
* @property Carbon $date_remboursement
|
||||
* @property int $id_user
|
||||
|
@ -52,7 +52,7 @@ class UsersDemandesCredit extends Model
|
|||
];
|
||||
|
||||
protected $dates = [
|
||||
'date_demande',
|
||||
'date_validation',
|
||||
'date_remboursement_prevu',
|
||||
'date_remboursement',
|
||||
'date_creation'
|
||||
|
@ -68,7 +68,7 @@ class UsersDemandesCredit extends Model
|
|||
'etat',
|
||||
'interet',
|
||||
'taxe',
|
||||
'date_demande',
|
||||
'date_validation',
|
||||
'date_remboursement_prevu',
|
||||
'date_remboursement',
|
||||
'id_user',
|
||||
|
|
|
@ -269,6 +269,12 @@ trait Helper
|
|||
return $randomString;
|
||||
}
|
||||
|
||||
// Fonction de tri par date
|
||||
public function sortFunction($a, $b)
|
||||
{
|
||||
return strtotime($b->date_creation) - strtotime($a->date_creation);
|
||||
}
|
||||
|
||||
public function refundAllNanoCredit()
|
||||
{
|
||||
// \Log::info('cron refund credit --');
|
||||
|
@ -364,9 +370,9 @@ trait Helper
|
|||
|
||||
$message = trans('messages.successful_nano_credit_demand_refunded',
|
||||
['id_demand' => $demande_credit->id_demande, 'amount' => $this->toMoney($montantARembourser, $init_country), 'duration' => $demande_credit->duree_mois,
|
||||
'net' => $this->toMoney($montantARembourser * $quota, $init_country), 'fees' => $this->toMoney($demande_credit->interet * $quota, $init_country),
|
||||
'tax' => $this->toMoney($demande_credit->taxe * $quota, $init_country),
|
||||
'caution' => $demande_credit->type_caution == 'groupe' ? 'Groupe' : 'Individuel']);
|
||||
'net' => $this->toMoney($montantARembourser - $demande_credit->interet * $quota - $demande_credit->taxe * $quota, $init_country),
|
||||
'fees' => $this->toMoney($demande_credit->interet * $quota, $init_country),
|
||||
'tax' => $this->toMoney($demande_credit->taxe * $quota, $init_country)]);
|
||||
|
||||
$title = (!$partialRefund) ? trans('messages.successful_nano_credit_refunded') :
|
||||
trans('messages.successful_nano_credit_partially_refunded');
|
||||
|
|
|
@ -60,7 +60,10 @@ Paying network : :network :country',
|
|||
"borrowing_capacity_exceeded" => "The borrowing capacity is exceeded",
|
||||
"savings_not_found" => "This savings does not exist",
|
||||
"regulations_limits_amount_transaction" => "You can make a transaction of :amount .",
|
||||
"daily_regulations_limits_reached" => "You have reached your daily limit.",
|
||||
"weekly_regulations_limits_reached" => "You have reached your weekly limit.",
|
||||
"monthly_regulations_limits_reached" => "You have reached your monthly limit.",
|
||||
"national_daily_regulations_limits_reached" => "You have reached your national daily limit.",
|
||||
"national_weekly_regulations_limits_reached" => "You have reached your national weekly limit.",
|
||||
"national_monthly_regulations_limits_reached" => "You have reached your national monthly limit.",
|
||||
"international_daily_regulations_limits_reached" => "You have reached your international daily limit.",
|
||||
"international_weekly_regulations_limits_reached" => "You have reached your international weekly limit.",
|
||||
"international_monthly_regulations_limits_reached" => "You have reached your international monthly limit.",
|
||||
];
|
||||
|
|
|
@ -214,11 +214,10 @@ NB: The reimbursement process is automatic on the due date if the reimbursement
|
|||
'successful_nano_credit_demand_refunded' => "Nano credit refunded
|
||||
Request Information:
|
||||
- Request number: :id_demand
|
||||
- Type of deposit: :deposit
|
||||
- Credit amount: :amount
|
||||
- Amount of credit repaid : :amount
|
||||
- Interests : :fees
|
||||
- Taxes : :tax
|
||||
- Net amount received: :net",
|
||||
- Capital : :net",
|
||||
'successful_accepted_group_membership_request' => "Membership request accepted",
|
||||
'successful_canceled_group_membership_request' => "Membership request refused",
|
||||
'successful_nano_credit_sent_to_hypervisor' => "Your request has been sent to your network hypervisor. You will receive the credit only after validation",
|
||||
|
@ -244,5 +243,5 @@ Savings Information :
|
|||
- Taxes : :tax
|
||||
- Net amount saved : :net",
|
||||
"successful_broken_saving" => "Broken savings",
|
||||
"reload_your_account" => "Reload your account",
|
||||
"reload_your_account" => "The repayment of nano credit failed for insufficient balance, please recharge your account",
|
||||
];
|
||||
|
|
|
@ -60,7 +60,10 @@ Réseau payeur : :network :country',
|
|||
"borrowing_capacity_exceeded" => "La capacité d'emprunt est dépassée",
|
||||
"savings_not_found" => "Cette épargne n'existe pas",
|
||||
"regulations_limits_amount_transaction" => "Vous pouvez effectuer une transaction de :amount .",
|
||||
"daily_regulations_limits_reached" => "Vous avez atteint votre limite journalière.",
|
||||
"weekly_regulations_limits_reached" => "Vous avez atteint votre limite hebdomadaire.",
|
||||
"monthly_regulations_limits_reached" => "Vous avez atteint votre limite mensuelle.",
|
||||
"national_daily_regulations_limits_reached" => "Vous avez atteint votre limite journalière nationale.",
|
||||
"national_weekly_regulations_limits_reached" => "Vous avez atteint votre limite hebdomadaire nationale.",
|
||||
"national_monthly_regulations_limits_reached" => "Vous avez atteint votre limite mensuelle nationale.",
|
||||
"international_daily_regulations_limits_reached" => "Vous avez atteint votre limite journalière internationale.",
|
||||
"international_weekly_regulations_limits_reached" => "Vous avez atteint votre limite hebdomadaire internationale.",
|
||||
"international_monthly_regulations_limits_reached" => "Vous avez atteint votre limite mensuelle internationale.",
|
||||
];
|
||||
|
|
|
@ -212,13 +212,12 @@ NB: Le processus de remboursement est automatique à la date d'échéance si le
|
|||
'successful_nano_credit_partially_refunded' => 'Remboursement de nano crédit partiellement effectué',
|
||||
'failed_nano_credit_refunded' => 'Remboursement de nano crédit échoué',
|
||||
'successful_nano_credit_demand_refunded' => "Nano crédit remboursé
|
||||
Informations de la demande :
|
||||
Informations sur la demande :
|
||||
- Numéro de la demande : :id_demand
|
||||
- Type de caution : :caution
|
||||
- Montant du crédit : :amount
|
||||
- Montant du crédit remboursé : :amount
|
||||
- Intérêts : :fees
|
||||
- Taxes : :tax
|
||||
- Montant net percu : :net",
|
||||
- Capital : :net",
|
||||
'successful_accepted_group_membership_request' => "Demande d'adhésion acceptée",
|
||||
'successful_canceled_group_membership_request' => "Demande d'adhésion refusée",
|
||||
'successful_nano_credit_sent_to_hypervisor' => "Votre demande a été envoyé à l'hyperviseur de votre reseau. Vous recevrez le credit seulement après validation",
|
||||
|
@ -246,5 +245,5 @@ Informations sur l'epargne :
|
|||
- Montant net epargné : :net
|
||||
",
|
||||
"successful_broken_saving" => "Epargne cassée",
|
||||
"reload_your_account" => "Rechargez votre compte",
|
||||
"reload_your_account" => "Le remboursement de nano credit a echoué pour solde insuffisant, veuillez recharger votre compte.",
|
||||
];
|
||||
|
|
|
@ -53,8 +53,12 @@ $router->group(['prefix' => '/wallets'] , function () use ($router){
|
|||
$router->get('{id_wallet}', 'WalletController@show');
|
||||
$router->post('', 'WalletController@create');
|
||||
|
||||
//Les historiques globals des hyperviseur et superviseur
|
||||
$router->get('hyper_history/{id_network}', 'WalletController@hyperHistory');
|
||||
$router->get('super_history/{id_wallet}', 'WalletController@superHistory');
|
||||
|
||||
// Wallets users iLink
|
||||
$router->group(['prefix' => '/users'] , function () use ($router){
|
||||
$router->group(['prefix' => '/users'], function () use ($router) {
|
||||
$router->get('{id_user}', 'WalletController@showWalletUser');
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue