Edit Bank Details format and layout

I’m trying to customize the font size and arrangement of details in my display. Ideally, I’d like it to look like this:

  • Account Owner:
  • Bank Account No.:
  • Bank:
  • IFSC Code:
  • SWIFT Code:

However, currently, it appears differently. Could someone guide me on how to achieve the desired format?

Screenshot 2024-07-15 at 19.00.38

i am also facing this issue :thinking:

do you mean in the PDF?

Yes, in the PDF. Do you know how to fix it?

I think you need to fix it in the template that is used to create the document

@jonbendtsen I have tried editing the below portion which i think is used for displaying the bank details:

// If payment mode not forced or forced to VIR, show payment with BAN
			if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'VIR') {
				if ($object->fk_account > 0 || $object->fk_bank > 0 || getDolGlobalInt('FACTURE_RIB_NUMBER')) {
					$bankid = ($object->fk_account <= 0 ? $conf->global->FACTURE_RIB_NUMBER : $object->fk_account);
					if ($object->fk_bank > 0) {
						$bankid = $object->fk_bank; // For backward compatibility when object->fk_account is forced with object->fk_bank
					}
					$account = new Account($this->db);
					$account->fetch($bankid);

					$curx = $this->marge_gauche;
					$cury = $posy;

					$posy = pdf_bank($pdf, $outputlangs, $curx, $cury, $account, 0, $default_font_size + 1);

from which the below line, fetches the account details for TCPDF library to display the bank account details.

$posy = pdf_bank($pdf, $outputlangs, $curx, $cury, $account, 0, $default_font_size + 1);

But I’m not able to set default font size, bold/italic alignment or any other text formating tweaks for the bank details the way i need as a final format output.

is that PHP code? Which file do you have it from?

I think you need to find perhaps a PDF or ODT or some other kind of file that serves as a template to create the real PDF

@jonbendtsen, this code snippet is from the Sponge Template, which is used for PDF document generation.

@inpilankar sorry, this is beyond my knowledge

You find the formatting details in ~/htdocs/core/lib/pdf.lib.php:

function pdf_bank(&$pdf, $outputlangs, $curx, $cury, $account, $onlynumber = 0, $default_font_size = 10)

bold line:

$pdf->SetFont('', 'B', $default_font_size - $diffsizecontent);

normal line but with smaller (-3) fontsize

$pdf->SetFont('', '', $default_font_size - 3);

@jonbendtsen i can understand.

Just for clarity, all the bank details are pulling by using ‘$account’ variable. While there is not control on each attribute coming with it, i.e. account no., owner name, bank name, IFSC code, Swift code, etc.

Even we can display each of these details using Multicell line, i think it will give us control over the font and alignment as well.

@DG-Rilling is this fix only for bank details on Sponge PDF template?

No, it’s not a fix.
When you change the function pdf_bank it will be also used for all templates with details about the bank

@DG-Rilling does this mean it will only fix the font size and bold issue with Account Owner and Bank Account No. ?

Also what about the squential position of the details displayed:

  • Account Owner:
  • Bank Account No.:
  • Bank:
  • IFSC Code:
  • SWIFT Code:

how to rearrange/set them as per your own preference?

With a little php knowledge you can rearrange the fields by changing the code according to your wishes.

If you are not happy with the field names you can change the translations or define your own translation-keys

@DG-Rilling noted, thank you for your support. I will try to tinker around and see. Post which I might be able to post a proper solution over here.

Really appreciate your help. :innocent:

@DG-Rilling Thank you for your guidance.

Here is how I fixed it.

All changes are made in the ~/htdocs/core/lib/pdf.lib.php file.

Under the Bank Section:

*  Show bank informations for PDF generation
.
.
.
$pdf->SetFont('', '', $default_font_size - 2)

To rearrange the bank fields, I modified this portion:

	    // Account owner name
	    $pdf->SetFont('', '', $default_font_size - 2);
		$pdf->SetXY($curx, $cury);
		$pdf->MultiCell(100, 3, $outputlangs->transnoentities("Account Name").': '.$outputlangs->convToOutputCharset($account->proprio), 0, 'L', 0);
		$cury += 4;
	    
	    // Account Number
	    $pdf->SetFont('', '', $default_font_size - 2);
		$pdf->SetXY($curx, $cury);
		$pdf->MultiCell(100, 3, $outputlangs->transnoentities("BankAccountNumber").': '.$outputlangs->convToOutputCharset($account->number), 0, 'L', 0);
		$cury += 4;
		
		// Bank Name
		$pdf->SetFont('', '', $default_font_size - 2);
		$pdf->SetXY($curx, $cury);
		$pdf->MultiCell(100, 3, $outputlangs->transnoentities("Bank").': '.$outputlangs->convToOutputCharset($account->bank), 0, 'L', 0);
		$cury += 4;

I hope this helps for future reference.

(Note to @eldy) Also, it would be great if this modification and control could be kept on the PDF template and not on system files, so that it would be easier to upgrade without keeping track of system modifications.