1112 public function LibStatut($paye, $status, $mode = 0, $alreadypaid = -1, $type = -1, $moreparams = array())
1115 global $langs, $hookmanager;
1116 $langs->load(
'bills');
1119 $type = $this->type;
1123 if (is_int($moreparams)) {
1124 $moreparams = array(
'nbofopendirectdebitorcredittransfer' => (
int) $moreparams);
1127 $nbofopendirectdebitorcredittransfer = 0;
1128 foreach ($moreparams as $moreparamkey => $moreparamvalue) {
1129 if ($moreparamkey ==
'nbofopendirectdebitorcredittransfer') {
1130 $nbofopendirectdebitorcredittransfer = $moreparamvalue;
1134 $statusType =
'status0';
1138 $labelStatus = $langs->transnoentitiesnoconv(
'BillStatusDraft');
1139 $labelStatusShort = $langs->transnoentitiesnoconv(
'Bill'.$prefix.
'StatusDraft');
1140 } elseif (($status == 3 || $status == 2) && $alreadypaid <= 0) {
1142 $labelStatus = $langs->transnoentitiesnoconv(
'BillStatusCanceled');
1143 $labelStatusShort = $langs->transnoentitiesnoconv(
'Bill'.$prefix.
'StatusCanceled');
1145 $labelStatus = $langs->transnoentitiesnoconv(
'BillStatusClosedUnpaid');
1146 $labelStatusShort = $langs->transnoentitiesnoconv(
'Bill'.$prefix.
'StatusClosedUnpaid');
1148 $statusType =
'status5';
1149 } elseif (($status == 3 || $status == 2) && $alreadypaid > 0) {
1150 $labelStatus = $langs->transnoentitiesnoconv(
'BillStatusClosedPaidPartially');
1151 $labelStatusShort = $langs->transnoentitiesnoconv(
'Bill'.$prefix.
'StatusClosedPaidPartially');
1152 $statusType =
'status9';
1153 } elseif ($alreadypaid == 0 && $nbofopendirectdebitorcredittransfer == 0) {
1154 $labelStatus = $langs->transnoentitiesnoconv(
'BillStatusNotPaid');
1155 $labelStatusShort = $langs->transnoentitiesnoconv(
'Bill'.$prefix.
'StatusNotPaid');
1156 $statusType =
'status1';
1158 $labelStatus = $langs->transnoentitiesnoconv(
'BillStatusStarted');
1159 $labelStatusShort = $langs->transnoentitiesnoconv(
'Bill'.$prefix.
'StatusStarted');
1160 $statusType =
'status3';
1163 $statusType =
'status6';
1164 if ($type == self::TYPE_CREDIT_NOTE) {
1165 $labelStatus = $langs->transnoentitiesnoconv(
'BillStatusPaidBackOrConverted');
1166 $labelStatusShort = $langs->transnoentitiesnoconv(
'Bill'.$prefix.
'StatusPaidBackOrConverted');
1167 } elseif ($type == self::TYPE_DEPOSIT) {
1168 $labelStatus = $langs->transnoentitiesnoconv(
'BillStatusConverted');
1169 $labelStatusShort = $langs->transnoentitiesnoconv(
'Bill'.$prefix.
'StatusConverted');
1171 $labelStatus = $langs->transnoentitiesnoconv(
'BillStatusPaid');
1172 $labelStatusShort = $langs->transnoentitiesnoconv(
'Bill'.$prefix.
'StatusPaid');
1176 $paramsBadge = array(
'badgeParams' => array(
'attr' => array(
1177 'data-status-element' => $this->element,
1178 'data-already-paid' => $alreadypaid > 0 ? 1 : 0,
1179 'data-status' => (int) $status
1182 $parameters = array(
1183 'status' => $status,
1186 'alreadypaid' => $alreadypaid,
1188 'paramsBadge'=>& $paramsBadge
1191 $reshook = $hookmanager->executeHooks(
'LibStatut', $parameters, $this);
1194 return $hookmanager->resPrint;
1197 if (!empty($moreparams[
'close_code'])) {
1198 $titlestringtoshow =
'';
1200 if ($moreparams[
'close_code'] == self::CLOSECODE_DISCOUNTVAT) {
1201 $titlestringtoshow = $langs->trans(
"HelpEscompte");
1202 } elseif ($moreparams[
'close_code'] == self::CLOSECODE_BADDEBT) {
1203 $titlestringtoshow = $langs->trans(
"ConfirmClassifyPaidPartiallyReasonBadCustomer");
1204 } elseif ($moreparams[
'close_code'] == self::CLOSECODE_BANKCHARGE) {
1205 $titlestringtoshow = $langs->trans(
"ConfirmClassifyPaidPartiallyReasonBankCharge");
1206 } elseif ($moreparams[
'close_code'] == self::CLOSECODE_WITHHOLDINGTAX) {
1207 $titlestringtoshow = $langs->trans(
"ConfirmClassifyPaidPartiallyReasonWithholdingTax");
1208 } elseif ($moreparams[
'close_code'] == self::CLOSECODE_OTHER) {
1209 $titlestringtoshow = $langs->trans(
"Other");
1213 $paramsBadge[
'badgeParams' ][
'attr'][
'title'] = $titlestringtoshow;
1216 if (isset($moreparams[
'dispute_status']) && $moreparams[
'dispute_status']) {
1217 $labelStatus .=
' - ';
1218 if ($moreparams[
'dispute_status'] == 8) {
1219 $labelStatus .= $langs->trans(
"DisputeLost");
1220 } elseif ($moreparams[
'dispute_status'] == 9) {
1221 $labelStatus .= $langs->trans(
"DisputeWon");
1223 $labelStatus .= $langs->trans(
"DisputeOpen");
1224 $statusType =
'status8';
1228 $statusbadge =
dolGetStatus($labelStatus, $labelStatusShort,
'', $statusType, $mode,
'', $paramsBadge);
1230 return $statusbadge;
1490 public function makeStripeSepaRequest($fuser, $did, $type =
'direct-debit', $sourcetype =
'facture', $service =
'', $forcestripe =
'')
1492 global $conf, $user, $langs;
1494 if ($type !=
'bank-transfer' && $type !=
'credit-transfer' && !
getDolGlobalString(
'STRIPE_SEPA_DIRECT_DEBIT')) {
1501 if (empty($service)) {
1502 $service =
'StripeTest';
1504 $service =
'StripeLive';
1510 dol_syslog(get_class($this).
"::makeStripeSepaRequest start did=".$did.
" type=".$type.
" service=".$service.
" sourcetype=".$sourcetype.
" forcestripe=".$forcestripe, LOG_DEBUG);
1512 if ($this->
status > self::STATUS_DRAFT && $this->paye == 0) {
1514 require_once DOL_DOCUMENT_ROOT.
'/societe/class/companybankaccount.class.php';
1516 $result = $bac->fetch(0,
'', $this->socid, 1,
'ban');
1517 if ($result <= 0 || empty($bac->id)) {
1518 $this->error = $langs->trans(
"ThirdpartyHasNoDefaultBankAccount");
1519 $this->errors[] = $this->error;
1520 dol_syslog(get_class($this).
"::makeStripeSepaRequest ".$this->error);
1525 $sql =
"SELECT rowid, date_demande, amount, fk_facture, fk_facture_fourn, fk_salary, fk_prelevement_bons";
1526 $sql .=
" FROM ".$this->db->prefix().
"prelevement_demande";
1527 $sql .=
" WHERE rowid = ".((int) $did);
1528 if ($type !=
'bank-transfer' && $type !=
'credit-transfer') {
1529 $sql .=
" AND fk_facture = ".((int) $this->
id);
1531 if ($type !=
'direct-debit') {
1532 if ($sourcetype ==
'salary') {
1533 $sql .=
" AND fk_salary = ".((int) $this->
id);
1535 $sql .=
" AND fk_facture_fourn = ".((int) $this->
id);
1538 $sql .=
" AND traite = 0";
1540 dol_syslog(get_class($this).
"::makeStripeSepaRequest load requests to process", LOG_DEBUG);
1541 $resql = $this->db->query($sql);
1543 $obj = $this->db->fetch_object($resql);
1550 $amount = $obj->amount;
1552 if (is_numeric($amount) && $amount != 0) {
1553 require_once DOL_DOCUMENT_ROOT.
'/societe/class/companypaymentmode.class.php';
1555 $companypaymentmode->fetch($bac->id);
1557 $this->stripechargedone = 0;
1558 $this->stripechargeerror = 0;
1562 $currency = $conf->currency;
1564 $errorforinvoice = 0;
1568 dol_syslog(
"makeStripeSepaRequest Process payment request amount=".$amount.
" thirdparty_id=" . $this->thirdparty->id .
", thirdparty_name=" . $this->thirdparty->name .
" ban id=" . $bac->id, LOG_DEBUG);
1573 $amounttopay = $amount;
1577 $arrayzerounitcurrency = [
'BIF',
'CLP',
'DJF',
'GNF',
'JPY',
'KMF',
'KRW',
'MGA',
'PYG',
'RWF',
'VND',
'VUV',
'XAF',
'XOF',
'XPF'];
1578 $amountstripe = $amounttopay;
1579 if (!in_array($currency, $arrayzerounitcurrency)) {
1580 $amountstripe *= 100;
1583 $fk_bank_account =
getDolGlobalInt(
'STRIPE_BANK_ACCOUNT_FOR_PAYMENTS');
1584 if (!($fk_bank_account > 0)) {
1587 dol_syslog(
"makeStripeSepaRequest Error no bank account defined for Stripe payments", LOG_ERR);
1588 $this->error =
"Error bank account for Stripe payments not defined into Stripe module";
1589 $this->errors[] = $this->error;
1595 require_once DOL_DOCUMENT_ROOT.
'/compta/prelevement/class/bonprelevement.class.php';
1598 if (empty($obj->fk_prelevement_bons)) {
1600 $nbinvoices = $bon->create(
'0',
'0',
'real',
'ALL', 0, 0, $type, $did, $fk_bank_account);
1601 if ($nbinvoices <= 0) {
1604 dol_syslog(
"makeStripeSepaRequest Error on BonPrelevement creation", LOG_ERR);
1605 $this->error =
"Error on BonPrelevement creation";
1606 $this->errors[] = $this->error;
1626 dol_syslog(
"makeStripeSepaRequest Error Line already part of a bank payment order", LOG_ERR);
1627 $this->error =
"The line is already included into a bank payment order. Delete the bank payment order first.";
1628 $this->errors[] = $this->error;
1632 $paymentintent =
null;
1634 if ($amountstripe > 0) {
1636 global $savstripearrayofkeysbyenv;
1637 global $stripearrayofkeysbyenv;
1639 if ($service ==
'StripeLive') {
1644 dol_syslog(
"makeStripeSepaRequest We will try to pay with companypaymentmodeid=" . $companypaymentmode->id .
" stripe_card_ref=" . $companypaymentmode->stripe_card_ref .
" mode=" . $companypaymentmode->status, LOG_DEBUG);
1646 $thirdparty =
new Societe($this->db);
1647 $resultthirdparty = $thirdparty->fetch($this->socid);
1649 include_once DOL_DOCUMENT_ROOT .
'/stripe/class/stripe.class.php';
1651 $stripe =
new Stripe($this->db);
1653 if (empty($savstripearrayofkeysbyenv)) {
1654 $savstripearrayofkeysbyenv = $stripearrayofkeysbyenv;
1656 dol_syslog(
"makeStripeSepaRequest Current Stripe environment is " . $stripearrayofkeysbyenv[$servicestatus][
'publishable_key']);
1657 dol_syslog(
"makeStripeSepaRequest Current Saved Stripe environment is ".$savstripearrayofkeysbyenv[$servicestatus][
'publishable_key']);
1659 $foundalternativestripeaccount =
'';
1662 if (! empty($forcestripe)) {
1663 dol_syslog(
"makeStripeSepaRequest A dedicated stripe account was forced, so we switch to it.");
1665 $tmparray = explode(
'@', $forcestripe);
1666 if (! empty($tmparray[1])) {
1667 $tmparray2 = explode(
':', $tmparray[1]);
1668 if (! empty($tmparray2[1])) {
1669 $stripearrayofkeysbyenv[$servicestatus][
"publishable_key"] = $tmparray2[0];
1670 $stripearrayofkeysbyenv[$servicestatus][
"secret_key"] = $tmparray2[1];
1672 $stripearrayofkeys = $stripearrayofkeysbyenv[$servicestatus];
1673 \Stripe\Stripe::setApiKey($stripearrayofkeys[
'secret_key']);
1675 $foundalternativestripeaccount = $tmparray[0];
1677 dol_syslog(
"makeStripeSepaRequest We use now customer=".$foundalternativestripeaccount.
" publishable_key=".$stripearrayofkeys[
'publishable_key'], LOG_DEBUG);
1681 if (! $foundalternativestripeaccount) {
1682 $stripearrayofkeysbyenv = $savstripearrayofkeysbyenv;
1684 $stripearrayofkeys = $savstripearrayofkeysbyenv[$servicestatus];
1685 \Stripe\Stripe::setApiKey($stripearrayofkeys[
'secret_key']);
1686 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);
1689 $stripearrayofkeysbyenv = $savstripearrayofkeysbyenv;
1691 $stripearrayofkeys = $savstripearrayofkeysbyenv[$servicestatus];
1692 \Stripe\Stripe::setApiKey($stripearrayofkeys[
'secret_key']);
1693 dol_syslog(
"makeStripeSepaRequest No dedicated Stripe Account requested, so we use global one, so ".$stripearrayofkeys[
'publishable_key'], LOG_DEBUG);
1696 $stripeacc = $stripe->getStripeAccount($service, $this->socid);
1698 if ($foundalternativestripeaccount) {
1699 if (empty($stripeacc)) {
1700 $customer = \Stripe\Customer::retrieve(array(
'id' =>
"$foundalternativestripeaccount",
'expand[]' =>
'sources'));
1702 $customer = \Stripe\Customer::retrieve(array(
'id' =>
"$foundalternativestripeaccount",
'expand[]' =>
'sources'), array(
"stripe_account" => $stripeacc));
1705 $customer = $stripe->customerStripe($thirdparty, $stripeacc, $servicestatus, 0);
1706 if (empty($customer) && ! empty($stripe->error)) {
1707 $this->error = $stripe->error;
1708 $this->errors[] = $this->error;
1719 $postactionmessages = [];
1721 if ($resultthirdparty > 0 && !empty($customer)) {
1724 if ($companypaymentmode->type ==
'ban') {
1728 $stripecard = $stripe->sepaStripe($customer, $companypaymentmode, $stripeacc, $servicestatus, 0);
1731 $this->error =
'The payment mode type is not "ban"';
1735 $FULLTAG =
'DID='.$did.
'-INV=' . $this->
id .
'-CUS=' . $thirdparty->id;
1736 $description =
'Stripe payment from makeStripeSepaRequest: ' . $FULLTAG .
' did='.$did.
' ref=' . $this->ref;
1738 $stripefailurecode =
'';
1739 $stripefailuremessage =
'';
1740 $stripefailuredeclinecode =
'';
1743 dol_syslog(
"* Create payment on SEPA " . $stripecard->id .
", amounttopay=" . $amounttopay .
", amountstripe=" . $amountstripe .
", FULLTAG=" . $FULLTAG, LOG_DEBUG);
1746 $paymentintent = $stripe->getPaymentIntent($amounttopay, $currency, $FULLTAG, $description, $this, $customer->id, $stripeacc, $servicestatus, 0,
'automatic',
true, $stripecard->id, 1, 1, $did);
1750 if ($paymentintent->status ===
'succeeded' || $paymentintent->status ===
'processing') {
1751 $charge->status =
'ok';
1752 $charge->id = $paymentintent->id;
1753 $charge->customer = $customer->id;
1754 } elseif ($paymentintent->status ===
'requires_action') {
1756 dol_syslog(var_export($paymentintent,
true), LOG_DEBUG);
1758 $charge->status =
'failed';
1759 $charge->customer = $customer->id;
1760 $charge->failure_code = $stripe->code;
1761 $charge->failure_message = $stripe->error;
1762 $charge->failure_declinecode = $stripe->declinecode;
1763 $stripefailurecode = $stripe->code;
1764 $stripefailuremessage =
'Action required. Contact the support at ';
1765 $stripefailuredeclinecode = $stripe->declinecode;
1767 dol_syslog(var_export($paymentintent,
true), LOG_DEBUG);
1769 $charge->status =
'failed';
1770 $charge->customer = $customer->id;
1771 $charge->failure_code = $stripe->code;
1772 $charge->failure_message = $stripe->error;
1773 $charge->failure_declinecode = $stripe->declinecode;
1774 $stripefailurecode = $stripe->code;
1775 $stripefailuremessage = $stripe->error;
1776 $stripefailuredeclinecode = $stripe->declinecode;
1784 if (empty($charge) || $charge->status ==
'failed') {
1785 dol_syslog(
'Failed to charge payment mode ' . $stripecard->id .
' stripefailurecode=' . $stripefailurecode .
' stripefailuremessage=' . $stripefailuremessage .
' stripefailuredeclinecode=' . $stripefailuredeclinecode, LOG_WARNING);
1788 $this->stripechargeerror++;
1792 $errmsg = $langs->trans(
"FailedToChargeSEPA");
1793 if (!empty($charge)) {
1794 if ($stripefailuredeclinecode ==
'authentication_required') {
1795 $errauthenticationmessage = $langs->trans(
"ErrSCAAuthentication");
1796 $errmsg = $errauthenticationmessage;
1797 } elseif (in_array($stripefailuredeclinecode, [
'insufficient_funds',
'generic_decline'])) {
1798 $errmsg .=
': ' . $charge->failure_code;
1799 $errmsg .= ($charge->failure_message ?
' - ' :
'') .
' ' . $charge->failure_message;
1800 if (empty($stripefailurecode)) {
1801 $stripefailurecode = $charge->failure_code;
1803 if (empty($stripefailuremessage)) {
1804 $stripefailuremessage = $charge->failure_message;
1807 $errmsg .=
': failure_code=' . $charge->failure_code;
1808 $errmsg .= ($charge->failure_message ?
' - ' :
'') .
' failure_message=' . $charge->failure_message;
1809 if (empty($stripefailurecode)) {
1810 $stripefailurecode = $charge->failure_code;
1812 if (empty($stripefailuremessage)) {
1813 $stripefailuremessage = $charge->failure_message;
1817 $errmsg .=
': ' . $stripefailurecode .
' - ' . $stripefailuremessage;
1818 $errmsg .= ($stripefailuredeclinecode ?
' - ' . $stripefailuredeclinecode :
'');
1821 $description =
'Stripe payment ERROR from makeStripeSepaRequest: ' . $FULLTAG;
1822 $postactionmessages[] = $errmsg .
' (' . $stripearrayofkeys[
'publishable_key'] .
')';
1824 $this->error = $errmsg;
1825 $this->errors[] = $this->error;
1827 dol_syslog(
'Successfuly request '.$type.
' '.$stripecard->id);
1829 $postactionmessages[] =
'Success to request '.$type.
' (' . $charge->id .
' with ' . $stripearrayofkeys[
'publishable_key'] .
')';
1833 $this->stripechargedone++;
1836 $description =
'Stripe payment request OK (' . $charge->id .
') from makeStripeSepaRequest: ' . $FULLTAG;
1842 if (empty($charge) || $charge->status ==
'failed') {
1843 $actioncode =
'PAYMENT_STRIPE_KO';
1844 $extraparams = $stripefailurecode;
1845 $extraparams .= (($extraparams && $stripefailuremessage) ?
' - ' :
'') . $stripefailuremessage;
1846 $extraparams .= (($extraparams && $stripefailuredeclinecode) ?
' - ' :
'') . $stripefailuredeclinecode;
1848 $actioncode =
'PAYMENT_STRIPE_OK';
1849 $extraparams = array();
1854 dol_syslog(
"No ban payment method found for this stripe customer " . $customer->id, LOG_WARNING);
1856 $this->error =
'Failed to get direct debit payment method for stripe customer = ' . $customer->id;
1857 $this->errors[] = $this->error;
1859 $description =
'Failed to find or use the payment mode - no ban defined for the thirdparty account';
1860 $stripefailurecode =
'BADPAYMENTMODE';
1861 $stripefailuremessage =
'Failed to find or use the payment mode - no ban defined for the thirdparty account';
1862 $postactionmessages[] = $description .
' (' . $stripearrayofkeys[
'publishable_key'] .
')';
1866 $actioncode =
'PAYMENT_STRIPE_KO';
1867 $extraparams = array();
1872 $stripefailurecode =
'';
1873 $stripefailuremessage =
'';
1878 $extraparams = array();
1881 if ($resultthirdparty <= 0) {
1882 dol_syslog(
'SellYourSaasUtils Failed to load customer for thirdparty_id = ' . $thirdparty->id, LOG_WARNING);
1883 $this->error =
'Failed to load Stripe account for thirdparty_id = ' . $thirdparty->id;
1884 $this->errors[] = $this->error;
1886 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);
1887 $this->error =
'Failed to get Stripe account id for thirdparty_id = ' . $thirdparty->id .
" in mode " . $servicestatus .
" in Stripe env " . $stripearrayofkeysbyenv[$servicestatus][
'publishable_key'];
1888 $this->errors[] = $this->error;
1893 $description =
'Failed to find or use your payment mode (no payment mode for this customer id)';
1894 $stripefailurecode =
'BADPAYMENTMODE';
1895 $stripefailuremessage =
'Failed to find or use your payment mode (no payment mode for this customer id)';
1896 $postactionmessages = [];
1900 $actioncode =
'PAYMENT_STRIPE_KO';
1901 $extraparams = array();
1905 dol_syslog(
"* Record event for credit transfer or direct debit request result - " . $description);
1906 require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/actioncomm.class.php';
1911 $actioncomm->type_code =
'AC_OTH_AUTO';
1912 $actioncomm->code =
'AC_' . $actioncode;
1913 $actioncomm->label = $description;
1914 $actioncomm->note_private = implode(
",\n", $postactionmessages);
1915 $actioncomm->fk_project = $this->fk_project;
1916 $actioncomm->datep = $now;
1917 $actioncomm->datef = $now;
1918 $actioncomm->percentage = -1;
1919 $actioncomm->socid = $thirdparty->id;
1920 $actioncomm->contactid = 0;
1921 $actioncomm->authorid = $user->id;
1922 $actioncomm->userownerid = $user->id;
1932 $actioncomm->fk_element = $this->id;
1933 $actioncomm->elementid = $this->id;
1934 $actioncomm->elementtype = $this->element;
1935 $actioncomm->extraparams = $extraparams;
1937 $actioncomm->create($user);
1941 $this->postactionmessages = $postactionmessages;
1945 dol_syslog(
'Error ' . $e->getMessage(), LOG_ERR);
1946 $this->error =
'Error ' . $e->getMessage();
1947 $this->errors[] = $this->error;
1952 dol_syslog(
"Remain to pay is null for the invoice " . $this->
id .
" " . $this->
ref .
". Why is the invoice not classified 'Paid' ?", LOG_WARNING);
1953 $this->error =
"Remain to pay is null for the invoice " . $this->
id .
" " . $this->ref .
". Why is the invoice not classified 'Paid' ?";
1954 $this->errors[] = $this->error;
1959 if (!$error && !$errorforinvoice) {
1960 $result = $bon->set_infotrans($user, $now, 3);
1964 dol_syslog(
"Error on BonPrelevement creation", LOG_ERR);
1965 $this->error =
"Error on BonPrelevement creation";
1966 $this->errors[] = $this->error;
1970 if (!$error && !$errorforinvoice && $paymentintent !==
null) {
1972 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"prelevement_demande SET";
1973 $sql .=
" ext_payment_id = '".$this->db->escape($paymentintent->id).
"',";
1974 $sql .=
" ext_payment_site = '".$this->db->escape($service).
"'";
1975 $sql .=
" WHERE rowid = ".((int) $did);
1977 dol_syslog(get_class($this).
"::makeStripeSepaRequest update to save stripe paymentintent ids", LOG_DEBUG);
1978 $resql = $this->db->query($sql);
1980 $this->error = $this->db->lasterror();
1981 dol_syslog(get_class($this).
'::makeStripeSepaRequest Erreur');
1986 if (!$error && !$errorforinvoice) {
1987 $this->db->commit();
1989 $this->db->rollback();
1992 $this->error =
'WithdrawRequestErrorNilAmount';
1993 dol_syslog(get_class($this).
'::makeStripeSepaRequest WithdrawRequestErrorNilAmount');
2011 $this->error = $this->db->error();
2012 dol_syslog(get_class($this).
'::makeStripeSepaRequest Erreur -2');
2016 $this->error =
"Status of invoice does not allow this";
2017 dol_syslog(get_class($this).
"::makeStripeSepaRequest ".$this->error.
" ".$this->status.
" ,".$this->paye.
", ".$this->mode_reglement_id, LOG_WARNING);
2181 $tmplang->setDefaultLang(
'en_US');
2182 $tmplang->load(
"main");
2184 $pricewithtaxstring =
price2num($this->total_ttc, 2, 1);
2185 $pricetaxstring =
price2num($this->total_tva, 2, 1);
2187 $complementaryinfo =
'';
2201 $complementaryinfo =
'//S1/10/'.str_replace(
'/',
'', $this->
ref).
'/11/'.$datestring;
2202 if ($this->ref_client) {
2203 $complementaryinfo .=
'/20/'.$this->ref_client;
2205 if ($this->thirdparty->tva_intra) {
2206 $complementaryinfo .=
'/30/'.$this->thirdparty->tva_intra;
2209 include_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
2210 $bankaccount =
new Account($this->db);
2218 if ($this->fk_account > 0) {
2220 $bankaccount->fetch($this->fk_account);
2221 $s .= $bankaccount->iban.
"\n";
2225 if ($bankaccount->id > 0 &&
getDolGlobalString(
'PDF_SWISS_QRCODE_USE_OWNER_OF_ACCOUNT_AS_CREDITOR')) {
2229 $s .=
dol_trunc($bankaccount->owner_name, 70,
'right',
'UTF-8', 1).
"\n";
2230 $addresslinearray = explode(
"\n", $bankaccount->owner_address);
2231 $s .=
dol_trunc(empty($addresslinearray[1]) ?
'' : $addresslinearray[1], 70,
'right',
'UTF-8', 1).
"\n";
2232 $s .=
dol_trunc(empty($addresslinearray[2]) ?
'' : $addresslinearray[2], 70,
'right',
'UTF-8', 1).
"\n";
2239 $addresslinearray = explode(
"\n",
$mysoc->address);
2240 $s .=
dol_trunc(empty($addresslinearray[1]) ?
'' : $addresslinearray[1], 70,
'right',
'UTF-8', 1).
"\n";
2241 $s .=
dol_trunc(empty($addresslinearray[2]) ?
'' : $addresslinearray[2], 70,
'right',
'UTF-8', 1).
"\n";
2255 $s .=
price($pricewithtaxstring, 0,
'none', 0, 0, 2).
"\n";
2256 $s .= ($this->multicurrency_code ? $this->multicurrency_code : $conf->currency).
"\n";
2259 $s .=
dol_trunc((
string) $this->thirdparty->name, 70,
'right',
'UTF-8', 1).
"\n";
2260 $addresslinearray = explode(
"\n", $this->thirdparty->address);
2261 $s .=
dol_trunc(empty($addresslinearray[1]) ?
'' : $addresslinearray[1], 70,
'right',
'UTF-8', 1).
"\n";
2262 $s .=
dol_trunc(empty($addresslinearray[2]) ?
'' : $addresslinearray[2], 70,
'right',
'UTF-8', 1).
"\n";
2263 $s .=
dol_trunc($this->thirdparty->zip, 16,
'right',
'UTF-8', 1).
"\n";
2264 $s .=
dol_trunc($this->thirdparty->town, 35,
'right',
'UTF-8', 1).
"\n";
2265 $s .=
dol_trunc($this->thirdparty->country_code, 2,
'right',
'UTF-8', 1).
"\n";
2270 if ($complementaryinfo) {
2271 $s .= $complementaryinfo.
"\n";
2277 if ($complementaryinfo) {
2278 $s .= $complementaryinfo.
"\n";