From 322160a63127aea2b7571ba529b053745543fac2 Mon Sep 17 00:00:00 2001 From: Djery-Tom Date: Mon, 19 Dec 2022 17:03:39 +0100 Subject: [PATCH] Add payment_period_days to customers openings accounts configuration --- .../controllers/OpeningAccountAgent.php | 2 +- application/language/english/message_lang.php | 2 + application/language/french/message_lang.php | 2 + .../infos_opening_account_request.php | 31 ++- .../opening_account_requests.php | 2 +- .../customers_accounts.php | 178 ++++++++++-------- 6 files changed, 133 insertions(+), 84 deletions(-) diff --git a/application/controllers/OpeningAccountAgent.php b/application/controllers/OpeningAccountAgent.php index a7d387ab..dd79e273 100755 --- a/application/controllers/OpeningAccountAgent.php +++ b/application/controllers/OpeningAccountAgent.php @@ -90,7 +90,7 @@ class OpeningAccountAgent extends CI_Controller public function treatRequest($request_id) { - echo makeRequest('user-service', 'PUT','/customers_accounts_requests/'.$request_id.'/treat', $_POST); + echo makeRequest('user-service', 'PUT','/customers_accounts_requests/'.$request_id, $_POST); } private function isLogged() diff --git a/application/language/english/message_lang.php b/application/language/english/message_lang.php index 0c65ffbe..84e23df9 100755 --- a/application/language/english/message_lang.php +++ b/application/language/english/message_lang.php @@ -1049,4 +1049,6 @@ $lang['debit_card_type'] = "Debit card type"; $lang['opening_account_request_accepted'] = "Customer account opening request accepted"; $lang['opening_account_request_rejected'] = "The request to open an account has been rejected"; $lang['opening_account_request_more_information'] = "The request to open an account has been rejected"; +$lang['payment_period_days'] = "Payment period (in days)"; +$lang['required_payment_period_days'] = "Payment period is required" ?> diff --git a/application/language/french/message_lang.php b/application/language/french/message_lang.php index 50662498..5d529483 100755 --- a/application/language/french/message_lang.php +++ b/application/language/french/message_lang.php @@ -1057,4 +1057,6 @@ $lang['debit_card_type'] = "Type de carte de débit"; $lang['opening_account_request_accepted'] = "La demande d'ouverture de compte client été acceptée"; $lang['opening_account_request_rejected'] = "La demande d'ouverture de compte client été rejetée"; $lang['opening_account_request_more_information'] = "La demande d'ouverture de compte client en attente de complement d'informations"; +$lang['payment_period_days'] = "Délai de paiement (en jours)"; +$lang['required_payment_period_days'] = "Délai de paiement est obligatoire" ?> diff --git a/application/views/account_opening_agent/infos_opening_account_request.php b/application/views/account_opening_agent/infos_opening_account_request.php index 41231b2f..8d80620b 100755 --- a/application/views/account_opening_agent/infos_opening_account_request.php +++ b/application/views/account_opening_agent/infos_opening_account_request.php @@ -70,6 +70,8 @@ $this->converter = new CurrencyConverter($provider); $this->context = new AutoContext(); $fmt = new NumberFormatter('fr_FR', NumberFormatter::DECIMAL); + + $context = new AutoContext(); ?> @@ -100,23 +102,38 @@ - status, ['REJECTED','MORE_INFORMATION'])) { ?> + opening_amount)) { ?>
-

reject_reason ?>

-

lang->line('reject_reason') ?>

+

opening_amount, 2), $request->currency_code ?? 'XAF', $context)->formatTo('fr_FR') ?>

+

lang->line('opening_amount') ?>

- +
- + + + status, ['REJECTED','MORE_INFORMATION'])) { ?> +
+
+
+
+

reject_reason ?>

+

lang->line('reject_reason') ?>

+
+
+ +
+
+
+
+ +
diff --git a/application/views/account_opening_agent/opening_account_requests.php b/application/views/account_opening_agent/opening_account_requests.php index 63f64151..ae0e8abb 100755 --- a/application/views/account_opening_agent/opening_account_requests.php +++ b/application/views/account_opening_agent/opening_account_requests.php @@ -54,7 +54,7 @@ lang->line('request_id')?> Type lang->line('Nom') ?> - lang->line('Nom') ?> + lang->line('Prénom') ?> lang->line('Contact') ?> lang->line('state') ?> Date diff --git a/application/views/config_wallet_ilink_hyp/customers_accounts.php b/application/views/config_wallet_ilink_hyp/customers_accounts.php index 04a1c184..0caad69c 100755 --- a/application/views/config_wallet_ilink_hyp/customers_accounts.php +++ b/application/views/config_wallet_ilink_hyp/customers_accounts.php @@ -33,6 +33,7 @@ Description Parent lang->line('opening_amount'); ?> + lang->line('payment_period_days'); ?> Action @@ -44,9 +45,10 @@ description?> parent?> opening_amount) ? '' : Money::of(round($row->opening_amount, 2), $currency_code ?? 'XAF', $context)->formatTo('fr_FR')?> + opening_amount_payment_period_days?>
+
+ + +
@@ -121,6 +127,10 @@
+
+ + +
@@ -150,8 +160,9 @@
- +
@@ -274,6 +285,7 @@ $("#update-form input[name='name']").val($(this).data('name')); $("#update-form textarea[name='description']").val($(this).data('description')); $("#update-form input[name='opening_amount']").val($(this).data('opening_amount')); + $("#update-form input[name='opening_amount_payment_period_days']").val($(this).data('opening_amount_payment_period_days')); $("#update-form select[name='parent_id']").empty().append(""); $.each(types, function (j, it) { @@ -306,87 +318,103 @@ }); $("#update-form").submit(function () { - // Paliers - var documents = []; - $('#documents_list tr').has('td').each(function() { - var arrayItem = {}; - $('td', $(this)).each(function(index, item) { - if(index < 2){ - arrayItem[index] = $(item).html(); + let openingAmount = $("input[name=opening_amount]",this).val(); + let paymentPeriod = $("input[name=opening_amount_payment_period_days]",this).val(); + + if (openingAmount && !paymentPeriod){ + toastr.warning("lang->line('required_payment_period_days')?>" , "lang->line('request_error')?>"); + }else { + // Paliers + var documents = []; + + $('#documents_list tr').has('td').each(function() { + var arrayItem = {}; + $('td', $(this)).each(function(index, item) { + if(index < 2){ + arrayItem[index] = $(item).html(); + } + }); + documents.push(arrayItem); + }); + + $.ajax({ + url: '', + type: 'post', + data: { + id: selectedId, + network_id : networkId, + name: $("input[name=name]",this).val(), + description: $("textarea[name=description]",this).val(), + opening_amount: $("input[name=opening_amount]",this).val(), + opening_amount_payment_period_days: $("input[name=opening_amount_payment_period_days]", this).val(), + parent_id : $("select[name=parent_id]",this).val(), + documents: documents + }, + dataType: 'json', + success: function (data) { + if(data.code === 200){ + Swal.fire({ + icon: 'success', + title: "lang->line('customer_account_type_updated')?>", + text:"lang->line('informations_updated')?>", + timer: 3000 + }).then(()=>{ + location.reload(); + }); + }else{ + toastr.error(data.message , "lang->line('request_error')?>"); + } + }, + error: function (resultat, statut, error) { + console.log(resultat + " " + error); + toastr.error("lang->line('error_message')?>" , "lang->line('request_error')?>"); } }); - documents.push(arrayItem); - }); - - $.ajax({ - url: '', - type: 'post', - data: { - id: selectedId, - network_id : networkId, - name: $("input[name=name]",this).val(), - description: $("textarea[name=description]",this).val(), - opening_amount: $("input[name=opening_amount]",this).val(), - parent_id : $("select[name=parent_id]",this).val(), - documents: documents - }, - dataType: 'json', - success: function (data) { - if(data.code === 200){ - Swal.fire({ - icon: 'success', - title: "lang->line('customer_account_type_updated')?>", - text:"lang->line('informations_updated')?>", - timer: 3000 - }).then(()=>{ - location.reload(); - }); - }else{ - toastr.error(data.message , "lang->line('request_error')?>"); - } - }, - error: function (resultat, statut, error) { - console.log(resultat + " " + error); - toastr.error("lang->line('error_message')?>" , "lang->line('request_error')?>"); - } - }); + } event.preventDefault(); }); $("#create-form").submit(function (event) { - $.ajax({ - url: '', - type: 'post', - data: { - network_id : networkId, - name: $("input[name=name]",this).val(), - description: $("textarea[name=description]",this).val(), - opening_amount: $("input[name=opening_amount]",this).val(), - parent_id : $("select[name=parent_id]",this).val() - }, - dataType: 'json', - success: function (data) { - if(data.code === 200){ - Swal.fire({ - icon: 'success', - title: "lang->line('customer_account_type_created')?>", - text:"lang->line('informations_updated')?>", - timer: 3000 - }).then(()=>{ - location.reload(); - }); - }else{ - toastr.error(data.message , "lang->line('request_error')?>"); + let openingAmount = $("input[name=opening_amount]",this).val(); + let paymentPeriod = $("input[name=opening_amount_payment_period_days]",this).val(); + if (openingAmount && !paymentPeriod){ + toastr.warning("lang->line('required_payment_period_days')?>" , "lang->line('request_error')?>"); + }else { + $.ajax({ + url: '', + type: 'post', + data: { + network_id: networkId, + name: $("input[name=name]", this).val(), + description: $("textarea[name=description]", this).val(), + opening_amount: $("input[name=opening_amount]", this).val(), + opening_amount_payment_period_days: $("input[name=opening_amount_payment_period_days]", this).val(), + parent_id: $("select[name=parent_id]", this).val() + }, + dataType: 'json', + success: function (data) { + if (data.code === 200) { + Swal.fire({ + icon: 'success', + title: "lang->line('customer_account_type_created')?>", + text: "lang->line('informations_updated')?>", + timer: 3000 + }).then(() => { + location.reload(); + }); + } else { + toastr.error(data.message, "lang->line('request_error')?>"); + } + }, + error: function (resultat, statut, error) { + console.log(resultat + " " + error); + toastr.error("lang->line('error_message')?>", "lang->line('request_error')?>"); } - }, - error: function (resultat, statut, error) { - console.log(resultat + " " + error); - toastr.error("lang->line('error_message')?>" , "lang->line('request_error')?>"); - } - }); + }); + } event.preventDefault(); });