Merge pull request #24813 from FliyFly/editfactclientattribute

New attributes on invoice customer card
This commit is contained in:
Laurent Destailleur
2023-05-21 01:48:36 +02:00
committed by GitHub

View File

@@ -4788,6 +4788,7 @@ if ($action == 'create') {
print '<!-- amounts -->'."\n";
print '<div class="underbanner clearboth"></div>'."\n";
print '<table class="border tableforfield centpercent">';
$sign = 1;
@@ -4795,44 +4796,61 @@ if ($action == 'create') {
$sign = -1; // We invert sign for output
}
if (isModEnabled('multicurrency') && ($object->multicurrency_code != $conf->currency)) {
print '<tr>';
// Amount HT
print '<td class="titlefieldmiddle">' . $langs->trans('AmountHT') . '</td>';
print '<td class="nowrap amountcard right">' . price($sign * $object->total_ht, '', $langs, 0, -1, -1, $conf->currency) . '</td>';
if (isModEnabled("multicurrency") && ($object->multicurrency_code && $object->multicurrency_code != $conf->currency)) {
// Multicurrency Amount HT
print '<tr><td class="titlefieldmiddle">'.$form->editfieldkey('MulticurrencyAmountHT', 'multicurrency_total_ht', '', $object, 0).'</td>';
print '<td class="nowrap right amountcard">'.price($sign * $object->multicurrency_total_ht, '', $langs, 0, -1, -1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).'</td>';
print '</tr>';
// Multicurrency Amount VAT
print '<tr><td>'.$form->editfieldkey('MulticurrencyAmountVAT', 'multicurrency_total_tva', '', $object, 0).'</td>';
print '<td class="nowrap right amountcard">'.price($sign * $object->multicurrency_total_tva, '', $langs, 0, -1, -1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).'</td>';
print '</tr>';
// Multicurrency Amount TTC
print '<tr><td>'.$form->editfieldkey('MulticurrencyAmountTTC', 'multicurrency_total_ttc', '', $object, 0).'</td>';
print '<td class="nowrap right amountcard">'.price($sign * $object->multicurrency_total_ttc, '', $langs, 0, -1, -1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).'</td>';
print '</tr>';
print '<td class="nowrap amountcard right">' . price($sign * $object->multicurrency_total_ht, '', $langs, 0, -1, -1, $object->multicurrency_code) . '</td>';
}
print '</tr>';
// Amount
print '<tr><td class="titlefieldmiddle">'.$langs->trans('AmountHT').'</td>';
print '<td class="nowrap right amountcard">'.price($sign * $object->total_ht, 1, '', 1, - 1, - 1, $conf->currency).'</td></tr>';
// Vat
print '<tr><td>'.$langs->trans('AmountVAT').'</td><td colspan="3" class="nowrap right amountcard">'.price($sign * $object->total_tva, 1, '', 1, - 1, - 1, $conf->currency).'</td></tr>';
print '<tr>';
// Amount VAT
print '<td class="titlefieldmiddle">' . $langs->trans('AmountVAT') . '</td>';
print '<td class="nowrap amountcard right">' . price($sign * $object->total_tva, '', $langs, 0, -1, -1, $conf->currency) . '</td>';
if (isModEnabled("multicurrency") && ($object->multicurrency_code && $object->multicurrency_code != $conf->currency)) {
// Multicurrency Amount VAT
print '<td class="nowrap amountcard right">' . price($sign * $object->multicurrency_total_tva, '', $langs, 0, -1, -1, $object->multicurrency_code) . '</td>';
}
print '</tr>';
// Amount Local Taxes
if (($mysoc->localtax1_assuj == "1" && $mysoc->useLocalTax(1)) || $object->total_localtax1 != 0) { // Localtax1
print '<tr><td>'.$langs->transcountry("AmountLT1", $mysoc->country_code).'</td>';
print '<td class="nowrap right amountcard">'.price($sign * $object->total_localtax1, 1, '', 1, - 1, - 1, $conf->currency).'</td></tr>';
}
if (($mysoc->localtax2_assuj == "1" && $mysoc->useLocalTax(2)) || $object->total_localtax2 != 0) { // Localtax2
print '<tr><td>'.$langs->transcountry("AmountLT2", $mysoc->country_code).'</td>';
print '<td class="nowrap right amountcard">'.price($sign * $object->total_localtax2, 1, '', 1, - 1, - 1, $conf->currency).'</td></tr>';
if (($mysoc->localtax1_assuj == "1" && $mysoc->useLocalTax(1)) || $object->total_localtax1 != 0) {
print '<tr>';
print '<td class="titlefieldmiddle">' . $langs->transcountry("AmountLT1", $mysoc->country_code) . '</td>';
print '<td class="nowrap amountcard right">' . price($sign * $object->total_localtax1, '', $langs, 0, -1, -1, $conf->currency) . '</td>';
if (isModEnabled("multicurrency") && ($object->multicurrency_code && $object->multicurrency_code != $conf->currency)) {
print '<td class="nowrap amountcard right">' . price($sign * $object->total_localtax1, '', $langs, 0, -1, -1, $object->multicurrency_code) . '</td>';
}
print '</tr>';
if (($mysoc->localtax2_assuj == "1" && $mysoc->useLocalTax(2)) || $object->total_localtax2 != 0) {
print '<tr>';
print '<td>' . $langs->transcountry("AmountLT2", $mysoc->country_code) . '</td>';
print '<td class="nowrap amountcard right">' . price($sign * $object->total_localtax2, '', $langs, 0, -1, -1, $conf->currency) . '</td>';
if (isModEnabled("multicurrency") && ($object->multicurrency_code && $object->multicurrency_code != $conf->currency)) {
print '<td class="nowrap amountcard right">' . price($sign * $object->total_localtax2, '', $langs, 0, -1, -1, $object->multicurrency_code) . '</td>';
}
print '</tr>';
}
}
// Revenue stamp
if ($selleruserevenustamp) { // Test company use revenue stamp
print '<tr><td>';
print '<tr>';
// Amount TTC
print '<td>' . $langs->trans('AmountTTC') . '</td>';
print '<td class="nowrap amountcard right">' . price($sign * $object->total_ttc, '', $langs, 0, -1, -1, $conf->currency) . '</td>';
if (isModEnabled("multicurrency") && ($object->multicurrency_code && $object->multicurrency_code != $conf->currency)) {
// Multicurrency Amount TTC
print '<td class="nowrap amountcard right">' . price($sign * $object->total_ttc, '', $langs, 0, -1, -1, $object->multicurrency_code) . '</td>';
}
print '</tr>';
print '</table>';
// Ajouter la première condition
if ($selleruserevenustamp) {
print '<table class="nobordernopadding" width="100%"><tr><td>';
print $langs->trans('RevenueStamp');
print '</td>';
@@ -4852,43 +4870,37 @@ if ($action == 'create') {
print ' <input type="submit" class="button buttongen button-save" value="'.$langs->trans('Modify').'">';
print '</form>';
print " <script>
$(document).ready(function(){
js_recalculate_revenuestamp();
$('select[name=revenuestamp_type]').on('change',function(){
js_recalculate_revenuestamp();
});
});
function js_recalculate_revenuestamp(){
var valselected = $('select[name=revenuestamp_type]').val();
console.log('Calculate revenue stamp from '+valselected);
var revenue = 0;
if (valselected.indexOf('%') == -1)
{
revenue = valselected;
}
else
{
$(document).ready(function(){
js_recalculate_revenuestamp();
$('select[name=revenuestamp_type]').on('change',function(){
js_recalculate_revenuestamp();
});
});
function js_recalculate_revenuestamp(){
var valselected = $('select[name=revenuestamp_type]').val();
console.log('Calculate revenue stamp from '+valselected);
var revenue = 0;
if (valselected.indexOf('%') == -1)
{
revenue = valselected;
}
else
{
var revenue_type = parseFloat(valselected);
var amount_net = ".round($object->total_ht, 2).";
revenue = revenue_type * amount_net / 100;
revenue = revenue.toFixed(2);
}
$('#revenuestamp_val').val(revenue);
$('#revenuestamp_span').html(revenue);
}
</script>";
}
$('#revenuestamp_val').val(revenue);
$('#revenuestamp_span').html(revenue);
}
</script>";
} else {
print price($object->revenuestamp, 1, '', 1, - 1, - 1, $conf->currency);
print price($object->revenuestamp, 1, '', 1, -1, -1, $conf->currency);
}
print '</td></tr>';
}
// Total with tax
print '<tr><td>'.$langs->trans('AmountTTC').'</td><td class="nowrap right amountcard">'.price($sign * $object->total_ttc, 1, '', 1, - 1, - 1, $conf->currency).'</td></tr>';
print '</table>';
$nbrows = 8;
$nbcols = 3;
if (isModEnabled('project')) {