12/09/2023 - 18h

recette2
cherif 2023-09-12 17:48:13 +02:00
parent 684c1a551d
commit 533db68e2c
2 changed files with 382 additions and 173 deletions

View File

@ -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));
@ -2005,10 +2044,82 @@ const Partner_Commande = (props) => {
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 (
<div className="partner_commande">
@ -2211,6 +2322,25 @@ const Partner_Commande = (props) => {
/>
<div className="session_caract"> Total HT<br />
<TextField
sx={{ '& legend': { display: 'none' }, '& fieldset': { top: 0 }, }}
required
name="ref_article_total_amount_ht"
id="ref_article_total_amount_ht"
InputLabelProps={{
shrink: true,
}}
disabled={true}
fullWidth
className="disabled_style_Dialog"
value={p_add_line_item_total_amount_ht}
/>
</div>
</DialogContent>
@ -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");
}
}
/>
</div>}
@ -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");
}
}
/>
</div>}
@ -3198,7 +3320,7 @@ const Partner_Commande = (props) => {
</TextField>
</div>}
<div className="session_caract"> Ref. Externz<br />
<div className="session_caract"> Ref. Externe<br />
<TextField
sx={{ '& legend': { display: 'none' }, '& fieldset': { top: 0 }, }}
required
@ -3323,79 +3445,15 @@ const Partner_Commande = (props) => {
</div>}
{String(header_submenu) === "detail" && <div>
<h3> Affichage détai header </h3>
<Button variant="outlined" onClick={Compute_Order_Header_Price} className="detail_class_submenu" id='order_header_main' name='order_header_main'>Mettre a jour prix CMD</Button>
<div className="session_caract"> Total Hors Taxes <br />
<TextField
sx={{ '& legend': { display: 'none' }, '& fieldset': { top: 0 }, }}
required
name="detail_header_total_ht"
id="detail_header_total_ht"
InputLabelProps={{
shrink: true,
}}
disabled={false}
className="disabled_style"
value={p_detail_header_total_ht}
onChange={(e) => {
setp_detail_header_total_ht(e.target.value);
setOrder_data_changed("1");
}
}
/>
<h3> Affichage détail header </h3>
<div className="div_row">
<Button variant="outlined" onClick={Compute_Order_Header_Price} className="detail_class_submenu" id='order_header_main' name='order_header_main'>Mettre a jour prix</Button>
<Button variant="outlined" onClick={print_order_pdf} className="detail_class_submenu" id='order_header_main' name='order_header_main'>Imprimer pdf</Button>
<Button variant="outlined" onClick={send_order_by_email} className="detail_class_submenu" id='order_header_main' name='order_header_main'>envoyer par mail</Button>
</div>
<div className="session_caract"> Total Taxes <br />
<TextField
sx={{ '& legend': { display: 'none' }, '& fieldset': { top: 0 }, }}
required
name="detail_header_total_tax"
id="detail_header_total_tax"
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");
}
}
/>
</div>
<div className="session_caract"> Total Toutes Taxes <br />
<TextField
sx={{ '& legend': { display: 'none' }, '& fieldset': { top: 0 }, }}
required
name="detail_header_total_ttc"
id="detail_header_total_ttc"
InputLabelProps={{
shrink: true,
}}
disabled={false}
className="disabled_style"
value={p_detail_header_total_ttc}
onChange={(e) => {
setp_detail_header_total_ttc(e.target.value);
setOrder_data_changed("1");
}
}
/>
</div>
{String(order_data_edit_mode) === "1" && <div className="session_caract"> Type de Reduction <br />
<div className="div_row">
{String(order_data_edit_mode) === "1" && <div className="session_caract"> Type de Reduction (entete) <br />
<TextField
sx={{ '& legend': { display: 'none' }, '& fieldset': { top: 0 }, }}
required
@ -3420,7 +3478,7 @@ const Partner_Commande = (props) => {
</TextField>
</div>}
{String(order_data_edit_mode) !== "1" && <div className="session_caract"> Type de Reduction <br />
{String(order_data_edit_mode) !== "1" && <div className="session_caract"> Type de Reduction (entete) <br />
<TextField
sx={{ '& legend': { display: 'none' }, '& fieldset': { top: 0 }, }}
required
@ -3440,7 +3498,7 @@ const Partner_Commande = (props) => {
</div>}
<div className="session_caract"> Valeur reduction <br />
<div className="session_caract"> Valeur reduction (entete) <br />
<TextField
sx={{ '& legend': { display: 'none' }, '& fieldset': { top: 0 }, }}
required
@ -3462,7 +3520,7 @@ const Partner_Commande = (props) => {
/>
</div>
<div className="session_caract"> Montant Reduction <br />
<div className="session_caract"> Montant Reduction (entete) <br />
<TextField
sx={{ '& legend': { display: 'none' }, '& fieldset': { top: 0 }, }}
required
@ -3474,7 +3532,9 @@ const Partner_Commande = (props) => {
}}
disabled={false}
className="disabled_style"
value={p_detail_header_montant_reduction}
value={p_detail_header_total_reduction_amount}
//value={p_detail_header_montant_reduction}
onChange={(e) => {
setp_detail_header_montant_reduction(e.target.value);
setOrder_data_changed("1");
@ -3484,6 +3544,125 @@ const Partner_Commande = (props) => {
/>
</div>
</div>
<div className="div_row"> &nbsp; </div>
<div class="separator"> Les Totaux </div>
<div className="session_caract"> Total Ligne HT avant reduction <br />
<TextField
sx={{ '& legend': { display: 'none' }, '& fieldset': { top: 0 }, }}
required
name="detail_header_type_reduction_valeur"
id="detail_header_type_reduction_valeur"
InputLabelProps={{
shrink: true,
}}
disabled={true}
className="disabled_style"
value={p_detail_total_lines_hors_taxe_before_lines_reduction}
/>
</div>
<div className="session_caract"> Total Ligne Reduction <br />
<TextField
sx={{ '& legend': { display: 'none' }, '& fieldset': { top: 0 }, }}
required
name="detail_header_type_reduction_valeur"
id="detail_header_type_reduction_valeur"
InputLabelProps={{
shrink: true,
}}
disabled={true}
className="disabled_style"
value={p_detail_header_montant_reduction}
/>
</div>
<div className="session_caract"> Total Ligne HT apres reduction <br />
<TextField
sx={{ '& legend': { display: 'none' }, '& fieldset': { top: 0 }, }}
required
name="detail_header_type_reduction_valeur"
id="detail_header_type_reduction_valeur"
InputLabelProps={{
shrink: true,
}}
disabled={true}
className="disabled_style"
value={p_detail_total_lines_hors_taxe_after_lines_reduction}
/>
</div>
<div className="session_caract"> Total Ligne Taxes <br />
<TextField
sx={{ '& legend': { display: 'none' }, '& fieldset': { top: 0 }, }}
required
name="detail_header_type_reduction_valeur"
id="detail_header_type_reduction_valeur"
InputLabelProps={{
shrink: true,
}}
disabled={true}
className="disabled_style"
value={p_detail_order_header_tax_amount}
/>
</div>
<div className="div_row"> &nbsp; </div>
<div className="session_caract"> Entete : Total reduction <br />
<TextField
sx={{ '& legend': { display: 'none' }, '& fieldset': { top: 0 }, }}
required
name="detail_header_type_reduction_valeur"
id="detail_header_type_reduction_valeur"
InputLabelProps={{
shrink: true,
}}
disabled={true}
className="disabled_style"
value={p_detail_header_total_reduction_amount}
/>
</div>
<div className="session_caract"> Entete : Total HT avant reduction d'entete <br />
<TextField
sx={{ '& legend': { display: 'none' }, '& fieldset': { top: 0 }, }}
required
name="detail_header_type_reduction_valeur"
id="detail_header_type_reduction_valeur"
InputLabelProps={{
shrink: true,
}}
disabled={true}
className="disabled_style"
value={p_detail_total_header_hors_taxe_before_header_reduction}
/>
</div>
<div className="session_caract"> Entete : Total HT apres reduction d'entete <br />
<TextField
sx={{ '& legend': { display: 'none' }, '& fieldset': { top: 0 }, }}
required
name="detail_header_type_reduction_valeur"
id="detail_header_type_reduction_valeur"
InputLabelProps={{
shrink: true,
}}
disabled={true}
className="disabled_style"
value={p_detail_total_header_hors_taxe_after_header_reduction}
/>
</div>
</div>}

View File

@ -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;
}
}