dolibarr 25.0.0-alpha
paymentvat.class.php
1<?php
2/* Copyright (C) 2002 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3 * Copyright (C) 2004-2007 Laurent Destailleur <eldy@users.sourceforge.net>
4 * Copyright (C) 2021 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
5 * Copyright (C) 2024-2026 Frédéric France <frederic.france@free.fr>
6 * Copyright (C) 2024-2026 MDW <mdeweerd@users.noreply.github.com>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <https://www.gnu.org/licenses/>.
20 */
21
28require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php';
29require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php';
30
31
36{
40 public $element = 'payment_vat';
41
45 public $table_element = 'payment_vat';
46
50 public $picto = 'payment';
51
55 public $fk_tva;
56
60 public $datec = '';
61
65 public $datep = '';
66
72 public $total;
73
77 public $amount; // Total amount of payment
78
82 public $amounts = array(); // Array of amounts
83
87 public $fk_typepaiement;
88
94 public $num_paiement;
95
100 public $num_payment;
101
105 public $fk_bank;
106
110 public $fk_user_creat;
111
115 public $fk_user_modif;
116
120 public $chid;
121
125 public $datepaye;
126
130 public $type_code;
131
135 public $type_label;
136
140 public $bank_account;
141
145 public $bank_line;
146
150 public $paiementtype;
151
157 public function __construct($db)
158 {
159 $this->db = $db;
160 }
161
170 public function create($user, $closepaidvat = 0)
171 {
172 $error = 0;
173
174 $now = dol_now();
175
176 dol_syslog(get_class($this)."::create", LOG_DEBUG);
177
178 // Validate parameters
179 if (!$this->datepaye) {
180 $this->error = 'ErrorBadValueForParameterCreatePaymentVAT';
181 return -1;
182 }
183
184 // Clean parameters
185 if (isset($this->fk_tva)) {
186 $this->fk_tva = (int) $this->fk_tva;
187 }
188 if (isset($this->amount)) {
189 $this->amount = (float) $this->amount;
190 }
191 if (isset($this->fk_typepaiement)) {
192 $this->fk_typepaiement = (int) $this->fk_typepaiement;
193 }
194 if (isset($this->num_paiement)) {
195 $this->num_paiement = trim($this->num_paiement); // deprecated
196 }
197 if (isset($this->num_payment)) {
198 $this->num_payment = trim($this->num_payment);
199 }
200 if (isset($this->note)) {
201 $this->note = trim($this->note);
202 }
203 if (isset($this->fk_bank)) {
204 $this->fk_bank = (int) $this->fk_bank;
205 }
206 if (isset($this->fk_user_creat)) {
207 $this->fk_user_creat = (int) $this->fk_user_creat;
208 }
209 if (isset($this->fk_user_modif)) {
210 $this->fk_user_modif = (int) $this->fk_user_modif;
211 }
212
213 $totalamount = 0;
214 foreach ($this->amounts as $key => $value) { // How payment is dispatch
215 $newvalue = (float) price2num($value, 'MT');
216 $this->amounts[$key] = $newvalue;
217 $totalamount += $newvalue;
218 }
219 // $totalamount = price2num($totalamount);
220
221 // Check parameters
222 if ($totalamount == 0) {
223 return -1; // We accept negative amounts for chargebacks, but not null amounts.
224 }
225
226
227 $this->db->begin();
228
229 if ($totalamount != 0) {
230 $sql = "INSERT INTO ".MAIN_DB_PREFIX."payment_vat (fk_tva, datec, datep, amount,";
231 $sql .= " fk_typepaiement, num_paiement, note, fk_user_creat, fk_bank)";
232 $sql .= " VALUES (".((int) $this->chid).", '".$this->db->idate($now)."',";
233 $sql .= " '".$this->db->idate($this->datepaye)."',";
234 $sql .= " ".((float) $totalamount).",";
235 $sql .= " ".((int) $this->paiementtype).", '".$this->db->escape($this->num_payment)."', '".$this->db->escape($this->note)."', ".((int) $user->id).",";
236 $sql .= " 0)";
237
238 $resql = $this->db->query($sql);
239 if ($resql) {
240 $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."payment_vat");
241
242 // Insert table of amounts / invoices
243 foreach ($this->amounts as $key => $amount) {
244 $contribid = $key;
245 if (is_numeric($amount) && $amount != 0) {
246 $amount = (float) price2num($amount);
247
248 // If we want to closed paid invoices
249 if ($closepaidvat) {
250 $contrib = new Tva($this->db);
251 $contrib->fetch($contribid);
252 $paiement = $contrib->getSommePaiement();
253 //$creditnotes=$contrib->getSumCreditNotesUsed();
254 $creditnotes = 0;
255 //$deposits=$contrib->getSumDepositsUsed();
256 $deposits = 0;
257 $alreadypayed = (float) price2num($paiement + $creditnotes + $deposits, 'MT');
258 $remaintopay = (float) price2num($contrib->amount - $paiement - $creditnotes - $deposits, 'MT');
259 if ($remaintopay == 0) {
260 $result = $contrib->setPaid($user);
261 } else {
262 dol_syslog("Remain to pay for conrib ".$contribid." not null. We do nothing.");
263 }
264 }
265 }
266 }
267 } else {
268 $error++;
269 }
270 }
271
272 $result = $this->call_trigger('PAYMENTVAT_CREATE', $user);
273 if ($result < 0) {
274 $error++;
275 }
276
277 if ($totalamount != 0 && !$error) {
278 $this->amount = $totalamount;
279 $this->total = $totalamount; // deprecated
280 $this->db->commit();
281 return $this->id;
282 } else {
283 $this->error = $this->db->error();
284 $this->db->rollback();
285 return -1;
286 }
287 }
288
295 public function fetch($id)
296 {
297 $sql = "SELECT";
298 $sql .= " t.rowid,";
299 $sql .= " t.fk_tva,";
300 $sql .= " t.datec,";
301 $sql .= " t.tms,";
302 $sql .= " t.datep,";
303 $sql .= " t.amount,";
304 $sql .= " t.fk_typepaiement,";
305 $sql .= " t.num_paiement as num_payment,";
306 $sql .= " t.note as note_private,";
307 $sql .= " t.fk_bank,";
308 $sql .= " t.fk_user_creat,";
309 $sql .= " t.fk_user_modif,";
310 $sql .= " pt.code as type_code, pt.libelle as type_label,";
311 $sql .= ' b.fk_account';
312 $sql .= " FROM ".MAIN_DB_PREFIX."payment_vat as t LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pt ON t.fk_typepaiement = pt.id";
313 $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank as b ON t.fk_bank = b.rowid';
314 $sql .= " WHERE t.rowid = ".((int) $id);
315 // TODO link on entity of tax;
316
317 dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
318 $resql = $this->db->query($sql);
319 if ($resql) {
320 if ($this->db->num_rows($resql)) {
321 $obj = $this->db->fetch_object($resql);
322
323 $this->id = $obj->rowid;
324 $this->ref = $obj->rowid;
325
326 $this->fk_tva = $obj->fk_tva;
327 $this->datec = $this->db->jdate($obj->datec);
328 $this->tms = $this->db->jdate($obj->tms);
329 $this->datep = $this->db->jdate($obj->datep);
330 $this->amount = $obj->amount;
331 $this->fk_typepaiement = $obj->fk_typepaiement;
332 $this->num_paiement = $obj->num_payment;
333 $this->num_payment = $obj->num_payment;
334 $this->note = $obj->note_private;
335 $this->note_private = $obj->note_private;
336 $this->fk_bank = $obj->fk_bank;
337 $this->fk_user_creat = $obj->fk_user_creat;
338 $this->fk_user_modif = $obj->fk_user_modif;
339
340 $this->type_code = $obj->type_code;
341 $this->type_label = $obj->type_label;
342
343 $this->bank_account = $obj->fk_account;
344 $this->bank_line = $obj->fk_bank;
345 }
346 $this->db->free($resql);
347
348 return 1;
349 } else {
350 $this->error = "Error ".$this->db->lasterror();
351 return -1;
352 }
353 }
354
355
363 public function update($user = null, $notrigger = 0)
364 {
365 $error = 0;
366
367 // Clean parameters
368
369 if (isset($this->fk_tva)) {
370 $this->fk_tva = (int) $this->fk_tva;
371 }
372 if (isset($this->amount)) {
373 $this->amount = (float) $this->amount;
374 }
375 if (isset($this->fk_typepaiement)) {
376 $this->fk_typepaiement = (int) $this->fk_typepaiement;
377 }
378 if (isset($this->num_payment)) {
379 $this->num_payment = trim($this->num_payment);
380 }
381 if (isset($this->note)) {
382 $this->note = trim($this->note);
383 }
384 if (isset($this->fk_bank)) {
385 $this->fk_bank = (int) $this->fk_bank;
386 }
387 if (isset($this->fk_user_creat)) {
388 $this->fk_user_creat = (int) $this->fk_user_creat;
389 }
390 if (isset($this->fk_user_modif)) {
391 $this->fk_user_modif = (int) $this->fk_user_modif;
392 }
393
394 // Check parameters
395 // Put here code to add control on parameters values
396
397 // Update request
398 $sql = "UPDATE ".MAIN_DB_PREFIX."payment_vat SET";
399 $sql .= " fk_tva=".(isset($this->fk_tva) ? ((int) $this->fk_tva) : "null").",";
400 $sql .= " datec=".(dol_strlen($this->datec) != 0 ? "'".$this->db->idate($this->datec)."'" : 'null').",";
401 $sql .= " tms=".(dol_strlen((string) $this->tms) != 0 ? "'".$this->db->idate($this->tms)."'" : 'null').",";
402 $sql .= " datep=".(dol_strlen($this->datep) != 0 ? "'".$this->db->idate($this->datep)."'" : 'null').",";
403 $sql .= " amount=".(isset($this->amount) ? (float) price2num($this->amount) : "null").",";
404 $sql .= " fk_typepaiement=".(isset($this->fk_typepaiement) ? ((int) $this->fk_typepaiement) : "null").",";
405 $sql .= " num_paiement=".(isset($this->num_payment) ? "'".$this->db->escape($this->num_payment)."'" : "null").",";
406 $sql .= " note=".(isset($this->note) ? "'".$this->db->escape($this->note)."'" : "null").",";
407 $sql .= " fk_bank=".(isset($this->fk_bank) ? ((int) $this->fk_bank) : "null").",";
408 $sql .= " fk_user_creat=".(isset($this->fk_user_creat) ? ((int) $this->fk_user_creat) : "null").",";
409 $sql .= " fk_user_modif=".(isset($this->fk_user_modif) ? ((int) $this->fk_user_modif) : "null");
410 $sql .= " WHERE rowid=".((int) $this->id);
411
412 $this->db->begin();
413
414 dol_syslog(get_class($this)."::update", LOG_DEBUG);
415 $resql = $this->db->query($sql);
416 if (!$resql) {
417 $error++;
418 $this->errors[] = "Error ".$this->db->lasterror();
419 }
420
421 if (!$error && $user && !$notrigger) {
422 // Call trigger
423 $result = $this->call_trigger('PAYMENTVAT_MODIFY', $user);
424 if ($result < 0) {
425 $error++;
426 }
427 // End call triggers
428 }
429
430 // Commit or rollback
431 if ($error) {
432 foreach ($this->errors as $errmsg) {
433 dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR);
434 $this->error .= ($this->error ? ', '.$errmsg : $errmsg);
435 }
436 $this->db->rollback();
437 return -1 * $error;
438 } else {
439 $this->db->commit();
440 return 1;
441 }
442 }
443
444
452 public function delete($user, $notrigger = 0)
453 {
454 $error = 0;
455
456 dol_syslog(get_class($this)."::delete");
457
458 $this->db->begin();
459
460 if ($this->bank_line > 0) {
461 $accline = new AccountLine($this->db);
462 $result = $accline->fetch($this->bank_line);
463 if ($result > 0) {
464 $result = $accline->delete($user); // $result may be 0 if not found (when bank entry was deleted manually and fk_bank point to nothing)
465 if ($result < 0) {
466 $this->errors[] = $accline->error;
467 $error++;
468 }
469 }
470 }
471
472 if (!$error) {
473 $sql = "DELETE FROM ".MAIN_DB_PREFIX."payment_vat";
474 $sql .= " WHERE rowid=".((int) $this->id);
475
476 dol_syslog(get_class($this)."::delete", LOG_DEBUG);
477 $resql = $this->db->query($sql);
478 if (!$resql) {
479 $error++;
480 $this->errors[] = "Error ".$this->db->lasterror();
481 }
482 }
483
484 if (!$error && !$notrigger) {
485 // Call trigger
486 $result = $this->call_trigger('PAYMENTVAT_DELETE', $user);
487 if ($result < 0) {
488 $error++;
489 }
490 // End call triggers
491 }
492
493 // Commit or rollback
494 if ($error) {
495 foreach ($this->errors as $errmsg) {
496 dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR);
497 $this->error .= ($this->error ? ', '.$errmsg : $errmsg);
498 }
499 $this->db->rollback();
500 return -1 * $error;
501 } else {
502 $this->db->commit();
503 return 1;
504 }
505 }
506
507
508
516 public function createFromClone(User $user, $fromid)
517 {
518 $error = 0;
519
520 $object = new PaymentVAT($this->db);
521
522 $this->db->begin();
523
524 // Load source object
525 $object->fetch($fromid);
526 $object->id = 0;
527 $object->status = 0;
528 $object->statut = 0;
529
530 // Clear fields
531
532 // Create clone
533 $object->context['createfromclone'] = 'createfromclone';
534 $result = $object->create($user);
535
536 // Other options
537 if ($result < 0) {
538 $this->error = $object->error;
539 $error++;
540 }
541
542 unset($object->context['createfromclone']);
543
544 // End
545 if (!$error) {
546 $this->db->commit();
547 return $object->id;
548 } else {
549 $this->db->rollback();
550 return -1;
551 }
552 }
553
554
562 public function initAsSpecimen()
563 {
564 $this->id = 0;
565 $this->fk_tva = 0;
566 $this->datec = dol_now();
567 $this->tms = dol_now();
568 $this->datep = dol_now();
569 $this->amount = 100;
570 $this->fk_typepaiement = 0;
571 $this->num_payment = '123456';
572 $this->note_private = 'Private note';
573 $this->note_public = 'Public note';
574 $this->fk_bank = 0;
575 $this->fk_user_creat = 0;
576 $this->fk_user_modif = 0;
577
578 return 1;
579 }
580
581
594 public function addPaymentToBank($user, $mode, $label, $accountid, $emetteur_nom, $emetteur_banque)
595 {
596 // Clean data
597 $this->num_payment = trim($this->num_payment ? $this->num_payment : $this->num_paiement);
598
599 $error = 0;
600
601 if (isModEnabled("bank")) {
602 include_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
603
604 $acc = new Account($this->db);
605 $acc->fetch($accountid);
606
607 $total = $this->amount;
608 if ($mode == 'payment_vat') {
609 $total = -$total;
610 }
611
612 // Insert payment into llx_bank
613 $bank_line_id = $acc->addline(
614 $this->datepaye,
615 $this->paiementtype, // Payment mode id or code ("CHQ or VIR for example")
616 $label,
617 $total,
618 $this->num_payment,
619 0,
620 $user,
621 $emetteur_nom,
622 $emetteur_banque
623 );
624
625 // Update fk_bank in llx_paiement.
626 // We thus know the payment that generated the bank entry
627 if ($bank_line_id > 0) {
628 $result = $this->update_fk_bank($bank_line_id);
629 if ($result <= 0) {
630 $error++;
631 dol_print_error($this->db);
632 }
633
634 // Add link 'payment', 'payment_supplier', 'payment_sc' in bank_url between payment and bank transaction
635 $url = '';
636 if ($mode == 'payment_vat') {
637 $url = DOL_URL_ROOT.'/compta/payment_vat/card.php?id=';
638 }
639 if ($url) {
640 $result = $acc->add_url_line($bank_line_id, $this->id, $url, '(paiement)', $mode);
641 if ($result <= 0) {
642 $error++;
643 dol_print_error($this->db);
644 }
645 }
646
647 // Add link 'company' in bank_url between invoice and bank transaction (for each invoice concerned by payment)
648 $linkaddedforthirdparty = array();
649 foreach ($this->amounts as $key => $value) {
650 if ($mode == 'payment_vat') {
651 $tva = new Tva($this->db);
652 $tva->fetch($key);
653 $result = $acc->add_url_line($bank_line_id, $tva->id, DOL_URL_ROOT.'/compta/tva/card.php?id=', '('.$tva->label.')', 'vat');
654 if ($result <= 0) {
655 dol_print_error($this->db);
656 }
657 }
658 }
659 } else {
660 $this->error = $acc->error;
661 $error++;
662 }
663 }
664
665 if (!$error) {
666 return 1;
667 } else {
668 return -1;
669 }
670 }
671
672
673 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
680 public function update_fk_bank($id_bank)
681 {
682 // phpcs:enable
683 $sql = "UPDATE ".MAIN_DB_PREFIX."payment_vat SET fk_bank = ".((int) $id_bank)." WHERE rowid = ".((int) $this->id);
684
685 dol_syslog(get_class($this)."::update_fk_bank", LOG_DEBUG);
686 $result = $this->db->query($sql);
687 if ($result) {
688 return 1;
689 } else {
690 $this->error = $this->db->error();
691 return 0;
692 }
693 }
694
695
702 public function getLibStatut($mode = 0)
703 {
704 return $this->LibStatut($this->statut, $mode);
705 }
706
707 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
715 public function LibStatut($status, $mode = 0)
716 {
717 // phpcs:enable
718 global $langs;
719
720 $langs->load('compta');
721 /*if ($mode == 0)
722 {
723 if ($status == 0) return $langs->trans('ToValidate');
724 if ($status == 1) return $langs->trans('Validated');
725 }
726 if ($mode == 1)
727 {
728 if ($status == 0) return $langs->trans('ToValidate');
729 if ($status == 1) return $langs->trans('Validated');
730 }
731 if ($mode == 2)
732 {
733 if ($status == 0) return img_picto($langs->trans('ToValidate'),'statut1').' '.$langs->trans('ToValidate');
734 if ($status == 1) return img_picto($langs->trans('Validated'),'statut4').' '.$langs->trans('Validated');
735 }
736 if ($mode == 3)
737 {
738 if ($status == 0) return img_picto($langs->trans('ToValidate'),'statut1');
739 if ($status == 1) return img_picto($langs->trans('Validated'),'statut4');
740 }
741 if ($mode == 4)
742 {
743 if ($status == 0) return img_picto($langs->trans('ToValidate'),'statut1').' '.$langs->trans('ToValidate');
744 if ($status == 1) return img_picto($langs->trans('Validated'),'statut4').' '.$langs->trans('Validated');
745 }
746 if ($mode == 5)
747 {
748 if ($status == 0) return $langs->trans('ToValidate').' '.img_picto($langs->trans('ToValidate'),'statut1');
749 if ($status == 1) return $langs->trans('Validated').' '.img_picto($langs->trans('Validated'),'statut4');
750 }
751 if ($mode == 6)
752 {
753 if ($status == 0) return $langs->trans('ToValidate').' '.img_picto($langs->trans('ToValidate'),'statut1');
754 if ($status == 1) return $langs->trans('Validated').' '.img_picto($langs->trans('Validated'),'statut4');
755 }*/
756 return '';
757 }
758
766 public function getNomUrl($withpicto = 0, $maxlen = 0)
767 {
768 global $langs;
769
770 $result = '';
771
772 $label = img_picto('', $this->picto).' <u>'.$langs->trans("VATPayment").'</u>';
773 $label .= '<br><b>'.$langs->trans('Ref').':</b> '.$this->ref;
774 if ($this->datep) {
775 $label .= '<br><b>'.$langs->trans('Date').':</b> '.dol_print_date($this->datep, 'day');
776 }
777
778 if (!empty($this->id)) {
779 $link = '<a href="'.DOL_URL_ROOT.'/compta/payment_vat/card.php?id='.$this->id.'" title="'.dolPrintHTMLForAttribute($label).'" class="classfortooltip">';
780 $linkend = '</a>';
781
782 if ($withpicto) {
783 $result .= ($link.img_object($label, 'payment', 'class="classfortooltip"').$linkend.' ');
784 }
785 if ($withpicto && $withpicto != 2) {
786 $result .= ' ';
787 }
788 if ($withpicto != 2) {
789 $result .= $link.($maxlen ? dol_trunc($this->ref, $maxlen) : $this->ref).$linkend;
790 }
791 }
792
793 global $action, $hookmanager;
794 $hookmanager->initHooks(array($this->element . 'dao'));
795 $parameters = array('id' => $this->id, 'getnomurl' => &$result);
796 $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
797 if ($reshook > 0) {
798 $result = $hookmanager->resPrint;
799 } else {
800 $result .= $hookmanager->resPrint;
801 }
802
803 return $result;
804 }
805}
if(! $sortfield) if(! $sortorder) $object
Definition account.php:100
$object ref
Definition info.php:90
Class to manage bank accounts.
Class to manage bank transaction lines.
Class to manage payments of social contributions.
initAsSpecimen()
Initialise an instance with random values.
LibStatut($status, $mode=0)
Return the label of a given status.
create($user, $closepaidvat=0)
Create payment of vat into database.
__construct($db)
Constructor.
update_fk_bank($id_bank)
Update link between vat payment and line in llx_bank generated.
fetch($id)
Load object in memory from database.
createFromClone(User $user, $fromid)
Load an object from its id and create a new one in database.
getLibStatut($mode=0)
Return the label of the status.
getNomUrl($withpicto=0, $maxlen=0)
Return clickable name (with picto eventually)
update($user=null, $notrigger=0)
Update database.
addPaymentToBank($user, $mode, $label, $accountid, $emetteur_nom, $emetteur_banque)
Add record into bank for payment with links between this bank record and invoices of payment.
Class to manage VAT - Value-added tax (also known in French as TVA)
Definition tva.class.php:39
Class to manage Dolibarr users.
dol_now($mode='gmt')
Return date for now.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
dol_trunc($string, $size=40, $trunc='right', $stringencoding='UTF-8', $nodot=0, $display=0)
Truncate a string to a particular length adding '...' if string larger than length.
isModEnabled($module)
Is Dolibarr module enabled.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
print $langs trans('Date')." left Ref Label right Qty right Price right TotalHT right TotalTTC right right right right right right right right right centpercent right TotalHT right n right VAT right n right TotalVAT right n No sujeto a RE IRPF right TotalLT1 right n right TotalLT2 right n right TotalTTC right n takeposcustomercurrency takeposcustomercurrency takeposcustomercurrency takeposcustomercurrency right TotalTTC takeposcustomercurrency right takeposcustomercurrency n right Paid right PaymentTypeShortLIQ right SELECT p pos_change as p datep as p p num_paiement as f pf amount as amount
Definition receipt.php:494