976 public function LibStatut($paye, $status, $mode = 0, $alreadypaid = -1, $type = -1, $moreparams = array())
979 global $langs, $hookmanager;
980 $langs->load(
'bills');
987 if (is_int($moreparams)) {
988 $moreparams = array(
'nbofopendirectdebitorcredittransfer' => (
int) $moreparams);
991 $nbofopendirectdebitorcredittransfer = 0;
992 foreach ($moreparams as $moreparamkey => $moreparamvalue) {
993 if ($moreparamkey ==
'nbofopendirectdebitorcredittransfer') {
994 $nbofopendirectdebitorcredittransfer = $moreparamvalue;
998 $statusType =
'status0';
1002 $labelStatus = $langs->transnoentitiesnoconv(
'BillStatusDraft');
1003 $labelStatusShort = $langs->transnoentitiesnoconv(
'Bill'.$prefix.
'StatusDraft');
1004 } elseif (($status == 3 || $status == 2) && $alreadypaid <= 0) {
1006 $labelStatus = $langs->transnoentitiesnoconv(
'BillStatusCanceled');
1007 $labelStatusShort = $langs->transnoentitiesnoconv(
'Bill'.$prefix.
'StatusCanceled');
1009 $labelStatus = $langs->transnoentitiesnoconv(
'BillStatusClosedUnpaid');
1010 $labelStatusShort = $langs->transnoentitiesnoconv(
'Bill'.$prefix.
'StatusClosedUnpaid');
1012 $statusType =
'status5';
1013 } elseif (($status == 3 || $status == 2) && $alreadypaid > 0) {
1014 $labelStatus = $langs->transnoentitiesnoconv(
'BillStatusClosedPaidPartially');
1015 $labelStatusShort = $langs->transnoentitiesnoconv(
'Bill'.$prefix.
'StatusClosedPaidPartially');
1016 $statusType =
'status9';
1017 } elseif ($alreadypaid == 0 && $nbofopendirectdebitorcredittransfer == 0) {
1018 $labelStatus = $langs->transnoentitiesnoconv(
'BillStatusNotPaid');
1019 $labelStatusShort = $langs->transnoentitiesnoconv(
'Bill'.$prefix.
'StatusNotPaid');
1020 $statusType =
'status1';
1022 $labelStatus = $langs->transnoentitiesnoconv(
'BillStatusStarted');
1023 $labelStatusShort = $langs->transnoentitiesnoconv(
'Bill'.$prefix.
'StatusStarted');
1024 $statusType =
'status3';
1027 $statusType =
'status6';
1028 if ($type == self::TYPE_CREDIT_NOTE) {
1029 $labelStatus = $langs->transnoentitiesnoconv(
'BillStatusPaidBackOrConverted');
1030 $labelStatusShort = $langs->transnoentitiesnoconv(
'Bill'.$prefix.
'StatusPaidBackOrConverted');
1031 } elseif ($type == self::TYPE_DEPOSIT) {
1032 $labelStatus = $langs->transnoentitiesnoconv(
'BillStatusConverted');
1033 $labelStatusShort = $langs->transnoentitiesnoconv(
'Bill'.$prefix.
'StatusConverted');
1035 $labelStatus = $langs->transnoentitiesnoconv(
'BillStatusPaid');
1036 $labelStatusShort = $langs->transnoentitiesnoconv(
'Bill'.$prefix.
'StatusPaid');
1040 $parameters = array(
1041 'status' => $status,
1044 'alreadypaid' => $alreadypaid,
1048 $reshook = $hookmanager->executeHooks(
'LibStatut', $parameters, $this);
1051 return $hookmanager->resPrint;
1054 if (!empty($moreparams[
'close_code'])) {
1055 $titlestringtoshow =
'';
1057 if ($moreparams[
'close_code'] == self::CLOSECODE_DISCOUNTVAT) {
1058 $titlestringtoshow = $langs->trans(
"HelpEscompte");
1059 } elseif ($moreparams[
'close_code'] == self::CLOSECODE_BADDEBT) {
1060 $titlestringtoshow = $langs->trans(
"ConfirmClassifyPaidPartiallyReasonBadCustomer");
1061 } elseif ($moreparams[
'close_code'] == self::CLOSECODE_BANKCHARGE) {
1062 $titlestringtoshow = $langs->trans(
"ConfirmClassifyPaidPartiallyReasonBankCharge");
1063 } elseif ($moreparams[
'close_code'] == self::CLOSECODE_WITHHOLDINGTAX) {
1064 $titlestringtoshow = $langs->trans(
"ConfirmClassifyPaidPartiallyReasonWithholdingTax");
1065 } elseif ($moreparams[
'close_code'] == self::CLOSECODE_OTHER) {
1066 $titlestringtoshow = $langs->trans(
"Other");
1070 $paramsbutton = array(
'badgeParams' => array(
'attr' => array(
'title' => $titlestringtoshow)));
1072 $paramsbutton = array();
1075 return dolGetStatus($labelStatus, $labelStatusShort,
'', $statusType, $mode,
'', $paramsbutton);
1335 public function makeStripeSepaRequest($fuser, $did, $type =
'direct-debit', $sourcetype =
'facture', $service =
'', $forcestripe =
'')
1337 global
$conf, $user, $langs;
1339 if ($type !=
'bank-transfer' && $type !=
'credit-transfer' && !
getDolGlobalString(
'STRIPE_SEPA_DIRECT_DEBIT')) {
1346 if (empty($service)) {
1347 $service =
'StripeTest';
1349 $service =
'StripeLive';
1355 dol_syslog(get_class($this).
"::makeStripeSepaRequest start did=".$did.
" type=".$type.
" service=".$service.
" sourcetype=".$sourcetype.
" forcestripe=".$forcestripe, LOG_DEBUG);
1357 if ($this->
status > self::STATUS_DRAFT && $this->paye == 0) {
1359 require_once DOL_DOCUMENT_ROOT.
'/societe/class/companybankaccount.class.php';
1361 $result = $bac->fetch(0,
'', $this->socid, 1,
'ban');
1362 if ($result <= 0 || empty($bac->id)) {
1363 $this->error = $langs->trans(
"ThirdpartyHasNoDefaultBanAccount");
1364 $this->errors[] = $this->error;
1365 dol_syslog(get_class($this).
"::makeStripeSepaRequest ".$this->error);
1370 $sql =
"SELECT rowid, date_demande, amount, fk_facture, fk_facture_fourn, fk_salary, fk_prelevement_bons";
1371 $sql .=
" FROM ".$this->db->prefix().
"prelevement_demande";
1372 $sql .=
" WHERE rowid = ".((int) $did);
1373 if ($type !=
'bank-transfer' && $type !=
'credit-transfer') {
1374 $sql .=
" AND fk_facture = ".((int) $this->
id);
1376 if ($type !=
'direct-debit') {
1377 if ($sourcetype ==
'salary') {
1378 $sql .=
" AND fk_salary = ".((int) $this->
id);
1380 $sql .=
" AND fk_facture_fourn = ".((int) $this->
id);
1383 $sql .=
" AND traite = 0";
1385 dol_syslog(get_class($this).
"::makeStripeSepaRequest load requests to process", LOG_DEBUG);
1386 $resql = $this->db->query($sql);
1388 $obj = $this->db->fetch_object($resql);
1395 $amount = $obj->amount;
1397 if (is_numeric($amount) && $amount != 0) {
1398 require_once DOL_DOCUMENT_ROOT.
'/societe/class/companypaymentmode.class.php';
1400 $companypaymentmode->fetch($bac->id);
1402 $this->stripechargedone = 0;
1403 $this->stripechargeerror = 0;
1407 $currency =
$conf->currency;
1409 $errorforinvoice = 0;
1413 dol_syslog(
"makeStripeSepaRequest Process payment request amount=".$amount.
" thirdparty_id=" . $this->thirdparty->id .
", thirdparty_name=" . $this->thirdparty->name .
" ban id=" . $bac->id, LOG_DEBUG);
1418 $amounttopay = $amount;
1422 $arrayzerounitcurrency = [
'BIF',
'CLP',
'DJF',
'GNF',
'JPY',
'KMF',
'KRW',
'MGA',
'PYG',
'RWF',
'VND',
'VUV',
'XAF',
'XOF',
'XPF'];
1423 $amountstripe = $amounttopay;
1424 if (!in_array($currency, $arrayzerounitcurrency)) {
1425 $amountstripe *= 100;
1428 $fk_bank_account =
getDolGlobalInt(
'STRIPE_BANK_ACCOUNT_FOR_PAYMENTS');
1429 if (!($fk_bank_account > 0)) {
1432 dol_syslog(
"makeStripeSepaRequest Error no bank account defined for Stripe payments", LOG_ERR);
1433 $this->error =
"Error bank account for Stripe payments not defined into Stripe module";
1434 $this->errors[] = $this->error;
1440 require_once DOL_DOCUMENT_ROOT.
'/compta/prelevement/class/bonprelevement.class.php';
1443 if (empty($obj->fk_prelevement_bons)) {
1445 $nbinvoices = $bon->create(
'0',
'0',
'real',
'ALL', 0, 0, $type, $did, $fk_bank_account);
1446 if ($nbinvoices <= 0) {
1449 dol_syslog(
"makeStripeSepaRequest Error on BonPrelevement creation", LOG_ERR);
1450 $this->error =
"Error on BonPrelevement creation";
1451 $this->errors[] = $this->error;
1471 dol_syslog(
"makeStripeSepaRequest Error Line already part of a bank payment order", LOG_ERR);
1472 $this->error =
"The line is already included into a bank payment order. Delete the bank payment order first.";
1473 $this->errors[] = $this->error;
1477 $paymentintent =
null;
1479 if ($amountstripe > 0) {
1481 global $savstripearrayofkeysbyenv;
1482 global $stripearrayofkeysbyenv;
1484 if ($service ==
'StripeLive') {
1489 dol_syslog(
"makeStripeSepaRequest We will try to pay with companypaymentmodeid=" . $companypaymentmode->id .
" stripe_card_ref=" . $companypaymentmode->stripe_card_ref .
" mode=" . $companypaymentmode->status, LOG_DEBUG);
1491 $thirdparty =
new Societe($this->db);
1492 $resultthirdparty = $thirdparty->fetch($this->socid);
1494 include_once DOL_DOCUMENT_ROOT .
'/stripe/class/stripe.class.php';
1496 $stripe =
new Stripe($this->db);
1498 if (empty($savstripearrayofkeysbyenv)) {
1499 $savstripearrayofkeysbyenv = $stripearrayofkeysbyenv;
1501 dol_syslog(
"makeStripeSepaRequest Current Stripe environment is " . $stripearrayofkeysbyenv[$servicestatus][
'publishable_key']);
1502 dol_syslog(
"makeStripeSepaRequest Current Saved Stripe environment is ".$savstripearrayofkeysbyenv[$servicestatus][
'publishable_key']);
1504 $foundalternativestripeaccount =
'';
1507 if (! empty($forcestripe)) {
1508 dol_syslog(
"makeStripeSepaRequest A dedicated stripe account was forced, so we switch to it.");
1510 $tmparray = explode(
'@', $forcestripe);
1511 if (! empty($tmparray[1])) {
1512 $tmparray2 = explode(
':', $tmparray[1]);
1513 if (! empty($tmparray2[1])) {
1514 $stripearrayofkeysbyenv[$servicestatus][
"publishable_key"] = $tmparray2[0];
1515 $stripearrayofkeysbyenv[$servicestatus][
"secret_key"] = $tmparray2[1];
1517 $stripearrayofkeys = $stripearrayofkeysbyenv[$servicestatus];
1518 \Stripe\Stripe::setApiKey($stripearrayofkeys[
'secret_key']);
1520 $foundalternativestripeaccount = $tmparray[0];
1522 dol_syslog(
"makeStripeSepaRequest We use now customer=".$foundalternativestripeaccount.
" publishable_key=".$stripearrayofkeys[
'publishable_key'], LOG_DEBUG);
1526 if (! $foundalternativestripeaccount) {
1527 $stripearrayofkeysbyenv = $savstripearrayofkeysbyenv;
1529 $stripearrayofkeys = $savstripearrayofkeysbyenv[$servicestatus];
1530 \Stripe\Stripe::setApiKey($stripearrayofkeys[
'secret_key']);
1531 dol_syslog(
"makeStripeSepaRequest We found a bad value for Stripe Account for thirdparty id=".$thirdparty->id.
", so we ignore it and keep using the global one, so ".$stripearrayofkeys[
'publishable_key'], LOG_WARNING);
1534 $stripearrayofkeysbyenv = $savstripearrayofkeysbyenv;
1536 $stripearrayofkeys = $savstripearrayofkeysbyenv[$servicestatus];
1537 \Stripe\Stripe::setApiKey($stripearrayofkeys[
'secret_key']);
1538 dol_syslog(
"makeStripeSepaRequest No dedicated Stripe Account requested, so we use global one, so ".$stripearrayofkeys[
'publishable_key'], LOG_DEBUG);
1541 $stripeacc = $stripe->getStripeAccount($service, $this->socid);
1543 if ($foundalternativestripeaccount) {
1544 if (empty($stripeacc)) {
1545 $customer = \Stripe\Customer::retrieve(array(
'id' =>
"$foundalternativestripeaccount",
'expand[]' =>
'sources'));
1547 $customer = \Stripe\Customer::retrieve(array(
'id' =>
"$foundalternativestripeaccount",
'expand[]' =>
'sources'), array(
"stripe_account" => $stripeacc));
1550 $customer = $stripe->customerStripe($thirdparty, $stripeacc, $servicestatus, 0);
1551 if (empty($customer) && ! empty($stripe->error)) {
1552 $this->error = $stripe->error;
1553 $this->errors[] = $this->error;
1564 $postactionmessages = [];
1566 if ($resultthirdparty > 0 && !empty($customer)) {
1569 if ($companypaymentmode->type ==
'ban') {
1573 $stripecard = $stripe->sepaStripe($customer, $companypaymentmode, $stripeacc, $servicestatus, 0);
1576 $this->error =
'The payment mode type is not "ban"';
1580 $FULLTAG =
'DID='.$did.
'-INV=' . $this->
id .
'-CUS=' . $thirdparty->id;
1581 $description =
'Stripe payment from makeStripeSepaRequest: ' . $FULLTAG .
' did='.$did.
' ref=' . $this->ref;
1583 $stripefailurecode =
'';
1584 $stripefailuremessage =
'';
1585 $stripefailuredeclinecode =
'';
1588 dol_syslog(
"* Create payment on SEPA " . $stripecard->id .
", amounttopay=" . $amounttopay .
", amountstripe=" . $amountstripe .
", FULLTAG=" . $FULLTAG, LOG_DEBUG);
1591 $paymentintent = $stripe->getPaymentIntent($amounttopay, $currency, $FULLTAG, $description, $this, $customer->id, $stripeacc, $servicestatus, 0,
'automatic',
true, $stripecard->id, 1, 1, $did);
1595 if ($paymentintent->status ===
'succeeded' || $paymentintent->status ===
'processing') {
1596 $charge->status =
'ok';
1597 $charge->id = $paymentintent->id;
1598 $charge->customer = $customer->id;
1599 } elseif ($paymentintent->status ===
'requires_action') {
1601 dol_syslog(var_export($paymentintent,
true), LOG_DEBUG);
1603 $charge->status =
'failed';
1604 $charge->customer = $customer->id;
1605 $charge->failure_code = $stripe->code;
1606 $charge->failure_message = $stripe->error;
1607 $charge->failure_declinecode = $stripe->declinecode;
1608 $stripefailurecode = $stripe->code;
1609 $stripefailuremessage =
'Action required. Contact the support at ';
1610 $stripefailuredeclinecode = $stripe->declinecode;
1612 dol_syslog(var_export($paymentintent,
true), LOG_DEBUG);
1614 $charge->status =
'failed';
1615 $charge->customer = $customer->id;
1616 $charge->failure_code = $stripe->code;
1617 $charge->failure_message = $stripe->error;
1618 $charge->failure_declinecode = $stripe->declinecode;
1619 $stripefailurecode = $stripe->code;
1620 $stripefailuremessage = $stripe->error;
1621 $stripefailuredeclinecode = $stripe->declinecode;
1629 if (empty($charge) || $charge->status ==
'failed') {
1630 dol_syslog(
'Failed to charge payment mode ' . $stripecard->id .
' stripefailurecode=' . $stripefailurecode .
' stripefailuremessage=' . $stripefailuremessage .
' stripefailuredeclinecode=' . $stripefailuredeclinecode, LOG_WARNING);
1633 $this->stripechargeerror++;
1637 $errmsg = $langs->trans(
"FailedToChargeSEPA");
1638 if (!empty($charge)) {
1639 if ($stripefailuredeclinecode ==
'authentication_required') {
1640 $errauthenticationmessage = $langs->trans(
"ErrSCAAuthentication");
1641 $errmsg = $errauthenticationmessage;
1642 } elseif (in_array($stripefailuredeclinecode, [
'insufficient_funds',
'generic_decline'])) {
1643 $errmsg .=
': ' . $charge->failure_code;
1644 $errmsg .= ($charge->failure_message ?
' - ' :
'') .
' ' . $charge->failure_message;
1645 if (empty($stripefailurecode)) {
1646 $stripefailurecode = $charge->failure_code;
1648 if (empty($stripefailuremessage)) {
1649 $stripefailuremessage = $charge->failure_message;
1652 $errmsg .=
': failure_code=' . $charge->failure_code;
1653 $errmsg .= ($charge->failure_message ?
' - ' :
'') .
' failure_message=' . $charge->failure_message;
1654 if (empty($stripefailurecode)) {
1655 $stripefailurecode = $charge->failure_code;
1657 if (empty($stripefailuremessage)) {
1658 $stripefailuremessage = $charge->failure_message;
1662 $errmsg .=
': ' . $stripefailurecode .
' - ' . $stripefailuremessage;
1663 $errmsg .= ($stripefailuredeclinecode ?
' - ' . $stripefailuredeclinecode :
'');
1666 $description =
'Stripe payment ERROR from makeStripeSepaRequest: ' . $FULLTAG;
1667 $postactionmessages[] = $errmsg .
' (' . $stripearrayofkeys[
'publishable_key'] .
')';
1669 $this->error = $errmsg;
1670 $this->errors[] = $this->error;
1672 dol_syslog(
'Successfuly request '.$type.
' '.$stripecard->id);
1674 $postactionmessages[] =
'Success to request '.$type.
' (' . $charge->id .
' with ' . $stripearrayofkeys[
'publishable_key'] .
')';
1678 $this->stripechargedone++;
1681 $description =
'Stripe payment request OK (' . $charge->id .
') from makeStripeSepaRequest: ' . $FULLTAG;
1687 if (empty($charge) || $charge->status ==
'failed') {
1688 $actioncode =
'PAYMENT_STRIPE_KO';
1689 $extraparams = $stripefailurecode;
1690 $extraparams .= (($extraparams && $stripefailuremessage) ?
' - ' :
'') . $stripefailuremessage;
1691 $extraparams .= (($extraparams && $stripefailuredeclinecode) ?
' - ' :
'') . $stripefailuredeclinecode;
1693 $actioncode =
'PAYMENT_STRIPE_OK';
1694 $extraparams = array();
1699 dol_syslog(
"No ban payment method found for this stripe customer " . $customer->id, LOG_WARNING);
1701 $this->error =
'Failed to get direct debit payment method for stripe customer = ' . $customer->id;
1702 $this->errors[] = $this->error;
1704 $description =
'Failed to find or use the payment mode - no ban defined for the thirdparty account';
1705 $stripefailurecode =
'BADPAYMENTMODE';
1706 $stripefailuremessage =
'Failed to find or use the payment mode - no ban defined for the thirdparty account';
1707 $postactionmessages[] = $description .
' (' . $stripearrayofkeys[
'publishable_key'] .
')';
1711 $actioncode =
'PAYMENT_STRIPE_KO';
1712 $extraparams = array();
1717 $stripefailurecode =
'';
1718 $stripefailuremessage =
'';
1723 $extraparams = array();
1726 if ($resultthirdparty <= 0) {
1727 dol_syslog(
'SellYourSaasUtils Failed to load customer for thirdparty_id = ' . $thirdparty->id, LOG_WARNING);
1728 $this->error =
'Failed to load Stripe account for thirdparty_id = ' . $thirdparty->id;
1729 $this->errors[] = $this->error;
1731 dol_syslog(
'SellYourSaasUtils Failed to get Stripe customer id for thirdparty_id = ' . $thirdparty->id .
" in mode " . $servicestatus .
" in Stripe env " . $stripearrayofkeysbyenv[$servicestatus][
'publishable_key'], LOG_WARNING);
1732 $this->error =
'Failed to get Stripe account id for thirdparty_id = ' . $thirdparty->id .
" in mode " . $servicestatus .
" in Stripe env " . $stripearrayofkeysbyenv[$servicestatus][
'publishable_key'];
1733 $this->errors[] = $this->error;
1738 $description =
'Failed to find or use your payment mode (no payment mode for this customer id)';
1739 $stripefailurecode =
'BADPAYMENTMODE';
1740 $stripefailuremessage =
'Failed to find or use your payment mode (no payment mode for this customer id)';
1741 $postactionmessages = [];
1745 $actioncode =
'PAYMENT_STRIPE_KO';
1746 $extraparams = array();
1750 dol_syslog(
"* Record event for credit transfer or direct debit request result - " . $description);
1751 require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/actioncomm.class.php';
1756 $actioncomm->type_code =
'AC_OTH_AUTO';
1757 $actioncomm->code =
'AC_' . $actioncode;
1758 $actioncomm->label = $description;
1759 $actioncomm->note_private = implode(
",\n", $postactionmessages);
1760 $actioncomm->fk_project = $this->fk_project;
1761 $actioncomm->datep = $now;
1762 $actioncomm->datef = $now;
1763 $actioncomm->percentage = -1;
1764 $actioncomm->socid = $thirdparty->id;
1765 $actioncomm->contactid = 0;
1766 $actioncomm->authorid = $user->id;
1767 $actioncomm->userownerid = $user->id;
1777 $actioncomm->fk_element = $this->id;
1778 $actioncomm->elementid = $this->id;
1779 $actioncomm->elementtype = $this->element;
1780 $actioncomm->extraparams = $extraparams;
1782 $actioncomm->create($user);
1786 $this->postactionmessages = $postactionmessages;
1790 dol_syslog(
'Error ' . $e->getMessage(), LOG_ERR);
1791 $this->error =
'Error ' . $e->getMessage();
1792 $this->errors[] = $this->error;
1797 dol_syslog(
"Remain to pay is null for the invoice " . $this->
id .
" " . $this->
ref .
". Why is the invoice not classified 'Paid' ?", LOG_WARNING);
1798 $this->error =
"Remain to pay is null for the invoice " . $this->
id .
" " . $this->ref .
". Why is the invoice not classified 'Paid' ?";
1799 $this->errors[] = $this->error;
1804 if (!$error && !$errorforinvoice) {
1805 $result = $bon->set_infotrans($user, $now, 3);
1809 dol_syslog(
"Error on BonPrelevement creation", LOG_ERR);
1810 $this->error =
"Error on BonPrelevement creation";
1811 $this->errors[] = $this->error;
1815 if (!$error && !$errorforinvoice && $paymentintent !==
null) {
1817 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"prelevement_demande SET";
1818 $sql .=
" ext_payment_id = '".$this->db->escape($paymentintent->id).
"',";
1819 $sql .=
" ext_payment_site = '".$this->db->escape($service).
"'";
1820 $sql .=
" WHERE rowid = ".((int) $did);
1822 dol_syslog(get_class($this).
"::makeStripeSepaRequest update to save stripe paymentintent ids", LOG_DEBUG);
1823 $resql = $this->db->query($sql);
1825 $this->error = $this->db->lasterror();
1826 dol_syslog(get_class($this).
'::makeStripeSepaRequest Erreur');
1831 if (!$error && !$errorforinvoice) {
1832 $this->db->commit();
1834 $this->db->rollback();
1837 $this->error =
'WithdrawRequestErrorNilAmount';
1838 dol_syslog(get_class($this).
'::makeStripeSepaRequest WithdrawRequestErrorNilAmount');
1856 $this->error = $this->db->error();
1857 dol_syslog(get_class($this).
'::makeStripeSepaRequest Erreur -2');
1861 $this->error =
"Status of invoice does not allow this";
1862 dol_syslog(get_class($this).
"::makeStripeSepaRequest ".$this->error.
" ".$this->status.
" ,".$this->paye.
", ".$this->mode_reglement_id, LOG_WARNING);
2023 global
$conf, $mysoc;
2026 $tmplang->setDefaultLang(
'en_US');
2027 $tmplang->load(
"main");
2029 $pricewithtaxstring =
price2num($this->total_ttc, 2, 1);
2030 $pricetaxstring =
price2num($this->total_tva, 2, 1);
2032 $complementaryinfo =
'';
2046 $complementaryinfo =
'//S1/10/'.str_replace(
'/',
'', $this->
ref).
'/11/'.$datestring;
2047 if ($this->ref_client) {
2048 $complementaryinfo .=
'/20/'.$this->ref_client;
2050 if ($this->thirdparty->tva_intra) {
2051 $complementaryinfo .=
'/30/'.$this->thirdparty->tva_intra;
2054 include_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
2055 $bankaccount =
new Account($this->db);
2063 if ($this->fk_account > 0) {
2065 $bankaccount->fetch($this->fk_account);
2066 $s .= $bankaccount->iban.
"\n";
2070 if ($bankaccount->id > 0 &&
getDolGlobalString(
'PDF_SWISS_QRCODE_USE_OWNER_OF_ACCOUNT_AS_CREDITOR')) {
2074 $s .=
dol_trunc($bankaccount->owner_name, 70,
'right',
'UTF-8', 1).
"\n";
2075 $addresslinearray = explode(
"\n", $bankaccount->owner_address);
2076 $s .=
dol_trunc(empty($addresslinearray[1]) ?
'' : $addresslinearray[1], 70,
'right',
'UTF-8', 1).
"\n";
2077 $s .=
dol_trunc(empty($addresslinearray[2]) ?
'' : $addresslinearray[2], 70,
'right',
'UTF-8', 1).
"\n";
2083 $s .=
dol_trunc((
string) $mysoc->name, 70,
'right',
'UTF-8', 1).
"\n";
2084 $addresslinearray = explode(
"\n", $mysoc->address);
2085 $s .=
dol_trunc(empty($addresslinearray[1]) ?
'' : $addresslinearray[1], 70,
'right',
'UTF-8', 1).
"\n";
2086 $s .=
dol_trunc(empty($addresslinearray[2]) ?
'' : $addresslinearray[2], 70,
'right',
'UTF-8', 1).
"\n";
2087 $s .=
dol_trunc($mysoc->zip, 16,
'right',
'UTF-8', 1).
"\n";
2088 $s .=
dol_trunc($mysoc->town, 35,
'right',
'UTF-8', 1).
"\n";
2089 $s .=
dol_trunc($mysoc->country_code, 2,
'right',
'UTF-8', 1).
"\n";
2100 $s .=
price($pricewithtaxstring, 0,
'none', 0, 0, 2).
"\n";
2101 $s .= ($this->multicurrency_code ? $this->multicurrency_code :
$conf->currency).
"\n";
2104 $s .=
dol_trunc((
string) $this->thirdparty->name, 70,
'right',
'UTF-8', 1).
"\n";
2105 $addresslinearray = explode(
"\n", $this->thirdparty->address);
2106 $s .=
dol_trunc(empty($addresslinearray[1]) ?
'' : $addresslinearray[1], 70,
'right',
'UTF-8', 1).
"\n";
2107 $s .=
dol_trunc(empty($addresslinearray[2]) ?
'' : $addresslinearray[2], 70,
'right',
'UTF-8', 1).
"\n";
2108 $s .=
dol_trunc($this->thirdparty->zip, 16,
'right',
'UTF-8', 1).
"\n";
2109 $s .=
dol_trunc($this->thirdparty->town, 35,
'right',
'UTF-8', 1).
"\n";
2110 $s .=
dol_trunc($this->thirdparty->country_code, 2,
'right',
'UTF-8', 1).
"\n";
2115 if ($complementaryinfo) {
2116 $s .= $complementaryinfo.
"\n";
2122 if ($complementaryinfo) {
2123 $s .= $complementaryinfo.
"\n";