diff --git a/src/components/Partner_Commande.js b/src/components/Partner_Commande.js index 061f173..db821db 100644 --- a/src/components/Partner_Commande.js +++ b/src/components/Partner_Commande.js @@ -624,8 +624,8 @@ const Partner_Commande = (props) => { axios.post(myurl, form).then(res => { if (String(res.data.status) === "true") { - //console.log(" In Get_Order_Data res.data.status = " + res.data.status); - //console.log(" In Get_Order_Data res.data.message r_class = " + res.data.message); + console.log(" In Get_Order_Data res.data.status = " + res.data.status); + console.log(" In Get_Order_Data res.data.message r_class = " + res.data.message); setGetAttendee_api("true"); setGetAttendee_result(res.data.message); @@ -760,8 +760,8 @@ const Partner_Commande = (props) => { } //document.getElementsByName("detail_header_total_tax")[0].value = ""; - if (mylocal_order.order_header_total_tax) { - setp_detail_header_total_tax(mylocal_order.order_header_total_tax); + if (mylocal_order.order_header_tax_amount) { + setp_detail_header_total_tax(mylocal_order.order_header_tax_amount); } @@ -782,9 +782,41 @@ const Partner_Commande = (props) => { if (mylocal_order.order_header_montant_reduction) { - setp_detail_header_montant_reduction(mylocal_order.order_header_montant_reduction); + setp_detail_header_total_reduction_amount(mylocal_order.order_header_montant_reduction); } + + if (mylocal_order.total_lines_montant_reduction) { + setp_detail_header_montant_reduction(mylocal_order.total_lines_montant_reduction); + } + + if (mylocal_order.total_header_hors_taxe_before_header_reduction) { + setp_detail_total_header_hors_taxe_before_header_reduction(mylocal_order.total_header_hors_taxe_before_header_reduction); + } + + if (mylocal_order.total_header_hors_taxe_after_header_reduction) { + setp_detail_total_header_hors_taxe_after_header_reduction(mylocal_order.total_header_hors_taxe_after_header_reduction); + } + + if (mylocal_order.order_header_tax_amount) { + setp_detail_order_header_tax_amount(mylocal_order.order_header_tax_amount); + } + + + if (mylocal_order.total_header_toutes_taxes) { + setp_detail_total_header_toutes_taxes(mylocal_order.total_header_toutes_taxes); + } + + if (mylocal_order.total_lines_hors_taxe_before_lines_reduction) { + setp_detail_total_lines_hors_taxe_before_lines_reduction(mylocal_order.total_lines_hors_taxe_before_lines_reduction); + } + + if (mylocal_order.total_lines_hors_taxe_after_lines_reduction) { + setp_detail_total_lines_hors_taxe_after_lines_reduction(mylocal_order.total_lines_hors_taxe_after_lines_reduction); + } + + + disable_Order_Header_DetailFields(); order_header_submenu_main(); @@ -830,8 +862,8 @@ const Partner_Commande = (props) => { axios.post(myurl, form).then(res => { if (String(res.data.status) === String("true")) { - //console.log(" In Get_Partner_Orders_Lines_from_header_id res.data.status = " + res.data.status); - //console.log(" In Get_Partner_Orders_Lines_from_header_id res.data.message r_class = " + res.data.message); + console.log(" In Get_Partner_Orders_Lines_from_header_id res.data.status = " + res.data.status); + console.log(" In Get_Partner_Orders_Lines_from_header_id res.data.message r_class = " + res.data.message); setGet_Partner_Orders_Lines_from_header_id_api("true"); setGet_Partner_Orders_Lines_from_header_id_result(res.data.message); setrows_order_lines(res.data.message); @@ -999,7 +1031,7 @@ const Partner_Commande = (props) => { if (mylocal_order.order_line_montant_hors_taxes) { setp_add_line_item_total_amount_ht(mylocal_order.order_line_montant_hors_taxes); - console.log(" ### mylocal_order.order_line_montant_hors_taxes = ", mylocal_order.order_line_montant_hors_taxes); + } @@ -1069,8 +1101,8 @@ const Partner_Commande = (props) => { const [p_detail_header_description, setp_detail_header_description] = useState(); const [p_detail_header_comment, setp_detail_header_comment] = useState(); - const [p_detail_header_date_cmd, setp_detail_header_date_cmd] = useState(); - const [p_detail_header_date_expiration, setp_detail_header_date_expiration] = useState(); + const [p_detail_header_date_cmd, setp_detail_header_date_cmd] = useState(new Date().toLocaleDateString('fr-FR')); + const [p_detail_header_date_expiration, setp_detail_header_date_expiration] = useState(date_today_90j.toLocaleDateString('fr-FR')); const [p_detail_header_condition_paiement, setp_detail_header_condition_paiement] = useState(); const [p_detail_header_ref_client, setp_detail_header_ref_client] = useState(); const [p_detail_header_ref_interne, setp_detail_header_ref_interne] = useState(); @@ -1100,8 +1132,18 @@ const Partner_Commande = (props) => { const [p_detail_header_total_tax, setp_detail_header_total_tax] = useState(); const [p_detail_header_total_ttc, setp_detail_header_total_ttc] = useState(); const [p_detail_header_type_reduction, setp_detail_header_type_reduction] = useState(); + const [p_detail_header_total_reduction_amount, setp_detail_header_total_reduction_amount] = useState(); const [p_detail_header_type_reduction_valeur, setp_detail_header_type_reduction_valeur] = useState(); const [p_detail_header_montant_reduction, setp_detail_header_montant_reduction] = useState(); + const [p_detail_total_header_hors_taxe_before_header_reduction, setp_detail_total_header_hors_taxe_before_header_reduction] = useState(); + const [p_detail_total_header_hors_taxe_after_header_reduction, setp_detail_total_header_hors_taxe_after_header_reduction] = useState(); + const [p_detail_order_header_tax_amount, setp_detail_order_header_tax_amount] = useState(); + const [p_detail_total_header_toutes_taxes, setp_detail_total_header_toutes_taxes] = useState(); + + + + const [p_detail_total_lines_hors_taxe_before_lines_reduction, setp_detail_total_lines_hors_taxe_before_lines_reduction] = useState(); + const [p_detail_total_lines_hors_taxe_after_lines_reduction, setp_detail_total_lines_hors_taxe_after_lines_reduction] = useState(); @@ -1410,13 +1452,13 @@ const Partner_Commande = (props) => { else form.append("order_header_condition_paiement", ""); - if (p_detail_header_date_expiration) - form.append("order_header_date_expiration", p_detail_header_date_expiration); + if (p_detail_header_date_expiration_val) + form.append("order_header_date_expiration", p_detail_header_date_expiration_val); else form.append("order_header_date_expiration", ""); - if (p_detail_header_date_cmd) - form.append("order_header_date_cmd", p_detail_header_date_cmd); + if (p_detail_header_date_cmd_val) + form.append("order_header_date_cmd", p_detail_header_date_cmd_val); else form.append("order_header_date_cmd", ""); @@ -1519,7 +1561,7 @@ const Partner_Commande = (props) => { form.append("order_header_montant_reduction", ""); - //console.log(" form == ", form); + console.log(" form == ", form); var myurl = ""; if (String(p_detail_header_type) === "commande") @@ -1773,7 +1815,7 @@ const Partner_Commande = (props) => { form.append("order_header_type", p_add_cmd_header_order_type); - console.log("### form = ", form); + //console.log("### form = ", form); var myurl = "" if (String(p_add_cmd_header_order_type) === "devis") { @@ -1953,10 +1995,9 @@ const Partner_Commande = (props) => { function Recalcul_Item_Amounts() { var qty = parseFloat(document.getElementById("ref_article_qty").value); var unit_price = parseFloat(document.getElementById("ref_article_unit_price").value); - var total_base1 = (unit_price * qty).toFixed(2); + var total_base1 = (unit_price * qty).toFixed(3); var total_reduction = 0; - var total_base2 = 0; var reduct_type = document.getElementById("ref_article_type_reduction").value; @@ -1969,28 +2010,26 @@ const Partner_Commande = (props) => { if (String(p_add_line_item_type_reduction) === "fixe") { console.log("fixe : p_add_line_item_reduction_value = ", reduct_value); - total_reduction = parseFloat(String(reduct_value)) * qty; - total_base2 = (total_base1 - total_reduction).toFixed(2); + total_reduction = (parseFloat(String(reduct_value)) * qty).toFixed(3); + } if (String(p_add_line_item_type_reduction) === "percent") { console.log("percent p_add_line_item_reduction_value = ", reduct_value); - total_reduction = (unit_price * parseFloat(String(reduct_value)) * qty) / 100; - total_base2 = (total_base1 - total_reduction).toFixed(2); - } - else { - total_base2 = total_base1 + total_reduction = ((unit_price * parseFloat(String(reduct_value)) * qty) / 100).toFixed(3); + } + console.log(" ### qty = ", qty, " ### unit_price = ", unit_price, " ### total_base1 = ", total_base1, " ### total_reduction = ", - total_reduction, ' ### total_base2 = ', total_base2, " ### reduct_value = ", reduct_value); + total_reduction, " ### reduct_value = ", reduct_value); - var montant_taxe_tva = (total_base2 * 0.2).toFixed(2); - var montant_ttc = total_base2 * 1.2; //(total_base2 + montant_taxe_tva).toFixed(2); + var montant_taxe_tva = ((total_base1 - total_reduction) * 0.2).toFixed(3); + var montant_ttc = ((total_base1 - total_reduction) * 1.2).toFixed(3); //(total_base2 + montant_taxe_tva).toFixed(2); setp_add_line_item_reduction_total_amount(String(total_reduction)); - setp_add_line_item_total_amount_ht(String(total_base2)); + setp_add_line_item_total_amount_ht(String(total_base1)); setp_add_line_item_taxe("tva"); setp_add_line_item_taxe_amount(String(montant_taxe_tva)); setp_add_line_item_total_amount_ttc(String(montant_ttc)); @@ -2002,13 +2041,85 @@ const Partner_Commande = (props) => { function Compute_Order_Header_Price() { - if( String(Order_data_changed) === "1"){ + if (String(Order_data_changed) === "1") { alert(" Merci d'enregistrer les modification avant de lancer le calcul"); } - console.log(" Calcul Prix Cmd") + + Compute_Partner_Order(); + Get_Order_Data(selected_id); + Get_Partner_Orders_Lines_from_header_id(selected_id); } + const [Compute_Partner_Order_api, setCompute_Partner_Order_api] = useState(); + const [Compute_Partner_Order_message, setCompute_Partner_Order_message] = useState(); + const [Compute_Partner_Order_result, setCompute_Partner_Order_result] = useState(); + function Compute_Partner_Order(event) { + + var form = new FormData(); + const stored_cookie = getCookie('tokenmysypart'); + + form.append("token", stored_cookie); + form.append("_id", selected_id); + + + var myurl = process.env.REACT_APP_API_URL + "myclass/api/Compute_Order_Header/"; + + axios.post(myurl, form).then(res => { + //console.log(" In Compute_Partner_Order res.data.status = " + res.data.status); + //console.log(" In Compute_Partner_Order res.data.message r_class = " + res.data.message); + + if (String(res.data.status) === String("true")) { + setCompute_Partner_Order_api("true"); + setCompute_Partner_Order_result(res.data.message); + } + else if (String(res.data.status) === String("Err_Connexion")) { + alert('Erreur: ' + res.data.message); + history.push("/Connexion"); + } + else { + setCompute_Partner_Order_api("false"); + setCompute_Partner_Order_message(res.data.message); + alert('Erreur: ' + res.data.message); + } + + }).catch((error) => { + console.warn('Not good man :( Compute_Partner_Order = ', error); + setCompute_Partner_Order_api("false"); + alert('Erreur: Impossible de faire la mise à jour'); + //setmyApimyApiMessage("") + }) + } + + + + function print_order_pdf() { + + + const stored_cookie = getCookie('tokenmysypart'); + + + var nom_fichier_cmd = "Order_" + order_internal_ref + ".pdf"; + console.log(" nom_fichier_cmd = ", nom_fichier_cmd, " --- selected_id = ", selected_id); + + var url = process.env.REACT_APP_API_URL + "myclass/api/GerneratePDF_Partner_Order/" + stored_cookie + "/" + selected_id; + + console.log(" nom_fichier_cmd = ", nom_fichier_cmd, " --- selected_id = ", selected_id, " --- url =",url); + + axios.get(url, { responseType: 'blob', },) + .then((res) => { + fileDownload(res.data, nom_fichier_cmd) + }).catch((error) => { + console.error('Error:', error); + + }); + } + + function send_order_by_email() { + + } + + return (
@@ -2211,6 +2322,25 @@ const Partner_Commande = (props) => { /> +
Total HT
+ +
+ + + @@ -3073,11 +3203,7 @@ const Partner_Commande = (props) => { disabled={false} className="disabled_style" value={p_detail_header_date_cmd} - onChange={(e) => { - setp_detail_header_date_cmd(e.target.value); - setOrder_data_changed("1"); - } - } + />
} @@ -3114,11 +3240,7 @@ const Partner_Commande = (props) => { disabled={false} className="disabled_style" value={p_detail_header_date_expiration} - onChange={(e) => { - setp_detail_header_date_expiration(e.target.value); - setOrder_data_changed("1"); - } - } + /> } @@ -3198,7 +3320,7 @@ const Partner_Commande = (props) => { } -
Ref. Externz
+
Ref. Externe
{
} {String(header_submenu) === "detail" &&
-

Affichage détai header

- - - - -
Total Hors Taxes
- { - setp_detail_header_total_ht(e.target.value); - setOrder_data_changed("1"); - } - } - - /> +

Affichage détail header

+
+ + +
-
Total Taxes
- + {String(order_data_edit_mode) === "1" &&
Type de Reduction (entete)
+ { + setp_detail_header_type_reduction(e.target.value); + setOrder_data_changed("1"); + } + } - InputLabelProps={{ - shrink: true, - }} - disabled={false} - className="disabled_style" - value={p_detail_header_total_tax} - onChange={(e) => { - setp_detail_header_total_tax(e.target.value); - setOrder_data_changed("1"); - } - } + > + Montant   + Pourcentage   + +
} + + {String(order_data_edit_mode) !== "1" &&
Type de Reduction (entete)
+ + +
} + + +
Valeur reduction (entete)
+ { + setp_detail_header_type_reduction_valeur(e.target.value); + setOrder_data_changed("1"); + } + } + + /> +
+ +
Montant Reduction (entete)
+ { + setp_detail_header_montant_reduction(e.target.value); + setOrder_data_changed("1"); + } + } + + /> +
- />
- - -
Total Toutes Taxes
- { - setp_detail_header_total_ttc(e.target.value); - setOrder_data_changed("1"); - } - } - - /> -
- - {String(order_data_edit_mode) === "1" &&
Type de Reduction
- { - setp_detail_header_type_reduction(e.target.value); - setOrder_data_changed("1"); - } - } - - > - Montant   - Pourcentage   - -
} - - {String(order_data_edit_mode) !== "1" &&
Type de Reduction
- - -
} - - -
Valeur reduction
+
 
+
Les Totaux
+
Total Ligne HT avant reduction
{ InputLabelProps={{ shrink: true, }} - disabled={false} + disabled={true} className="disabled_style" - value={p_detail_header_type_reduction_valeur} - onChange={(e) => { - setp_detail_header_type_reduction_valeur(e.target.value); - setOrder_data_changed("1"); - } - } - + value={p_detail_total_lines_hors_taxe_before_lines_reduction} />
-
Montant Reduction
+
Total Ligne Reduction
{ - setp_detail_header_montant_reduction(e.target.value); - setOrder_data_changed("1"); - } - } - />
+
Total Ligne HT apres reduction
+ +
+ + +
Total Ligne Taxes
+ +
+ +
 
+ +
Entete : Total reduction
+ +
+ + + +
Entete : Total HT avant reduction d'entete
+ +
+ +
Entete : Total HT apres reduction d'entete
+ +
} diff --git a/src/styles/components/_partner_commande.scss b/src/styles/components/_partner_commande.scss index 112182a..0eeeba6 100644 --- a/src/styles/components/_partner_commande.scss +++ b/src/styles/components/_partner_commande.scss @@ -1712,6 +1712,14 @@ border: solid gainsboro 1px; } + .session_caract_Dialog { + width: 100%; + padding: 5px; + float: left; + text-align: left; + font-size: small; + } + .training_caract { width: 30%; @@ -2155,6 +2163,28 @@ max-width: 30% !important; } + .separator { + display: flex; + align-items: center; + text-align: center; + margin-bottom: 0.5rem !important; + } + + .separator::before, + .separator::after { + content: ''; + flex: 1; + border-bottom: 1px solid #e0e0e0; + } + + .separator:not(:empty)::before { + margin-right: .35em; + } + + .separator:not(:empty)::after { + margin-left: .35em; + } + }