本文整理匯總了PHP中Facture::getListOfPayments方法的典型用法代碼示例。如果您正苦於以下問題:PHP Facture::getListOfPayments方法的具體用法?PHP Facture::getListOfPayments怎麽用?PHP Facture::getListOfPayments使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Facture
的用法示例。
在下文中一共展示了Facture::getListOfPayments方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: create
/**
* Create payment of invoices into database.
* Use this->amounts to have list of invoices for the payment.
* For payment of a customer invoice, amounts are postive, for payment of credit note, amounts are negative
*
* @param User $user Object user
* @param int $closepaidinvoices 1=Also close payed invoices to paid, 0=Do nothing more
* @return int id of created payment, < 0 if error
*/
function create($user, $closepaidinvoices = 0)
{
global $conf, $langs;
$error = 0;
$now = dol_now();
// Clean parameters
$totalamount = 0;
$atleastonepaymentnotnull = 0;
foreach ($this->amounts as $key => $value) {
$newvalue = price2num($value, 'MT');
$this->amounts[$key] = $newvalue;
$totalamount += $newvalue;
if (!empty($newvalue)) {
$atleastonepaymentnotnull++;
}
}
$totalamount = price2num($totalamount);
// Check parameters
if (empty($totalamount) && empty($atleastonepaymentnotnull)) {
$this->error = 'TotalAmountEmpty';
return -1;
}
$this->db->begin();
$ref = $this->getNextNumRef('');
$sql = "INSERT INTO " . MAIN_DB_PREFIX . "paiement (entity, ref, datec, datep, amount, fk_paiement, num_paiement, note, fk_user_creat)";
$sql .= " VALUES (" . $conf->entity . ", '" . $ref . "', '" . $this->db->idate($now) . "', '" . $this->db->idate($this->datepaye) . "', '" . $totalamount . "', " . $this->paiementid . ", '" . $this->num_paiement . "', '" . $this->db->escape($this->note) . "', " . $user->id . ")";
dol_syslog(get_class($this) . "::Create insert paiement", LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql) {
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX . 'paiement');
// Insert links amount / invoices
foreach ($this->amounts as $key => $amount) {
$facid = $key;
if (is_numeric($amount) && $amount != 0) {
$amount = price2num($amount);
$sql = 'INSERT INTO ' . MAIN_DB_PREFIX . 'paiement_facture (fk_facture, fk_paiement, amount)';
$sql .= ' VALUES (' . $facid . ', ' . $this->id . ', \'' . $amount . '\')';
dol_syslog(get_class($this) . '::Create Amount line ' . $key . ' insert paiement_facture', LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql) {
// If we want to closed payed invoices
if ($closepaidinvoices) {
$invoice = new Facture($this->db);
$invoice->fetch($facid);
$paiement = $invoice->getSommePaiement();
$creditnotes = $invoice->getSumCreditNotesUsed();
$deposits = $invoice->getSumDepositsUsed();
$alreadypayed = price2num($paiement + $creditnotes + $deposits, 'MT');
$remaintopay = price2num($invoice->total_ttc - $paiement - $creditnotes - $deposits, 'MT');
//var_dump($invoice->total_ttc.' - '.$paiement.' -'.$creditnotes.' - '.$deposits.' - '.$remaintopay);exit;
// If there is withdrawals request to do and not done yet, we wait before closing.
$mustwait = 0;
$listofpayments = $invoice->getListOfPayments();
foreach ($listofpayments as $paym) {
// This payment might be this one or a previous one
if ($paym['type'] == 'PRE') {
if (!empty($conf->prelevement->enabled)) {
// TODO Check if this payment has a withdraw request
// if not, $mustwait++; // This will disable automatic close on invoice to allow to process
}
}
}
//Invoice types that are eligible for changing status to paid
$affected_types = array(Facture::TYPE_STANDARD, Facture::TYPE_REPLACEMENT, Facture::TYPE_CREDIT_NOTE, Facture::TYPE_DEPOSIT, Facture::TYPE_SITUATION);
if (!in_array($invoice->type, $affected_types)) {
dol_syslog("Invoice " . $facid . " is not a standard, nor replacement invoice, nor credit note, nor deposit invoice, nor situation invoice. We do nothing more.");
} else {
if ($remaintopay) {
dol_syslog("Remain to pay for invoice " . $facid . " not null. We do nothing more.");
} else {
if ($mustwait) {
dol_syslog("There is " . $mustwait . " differed payment to process, we do nothing more.");
} else {
$result = $invoice->set_paid($user, '', '');
if ($result < 0) {
$this->error = $invoice->error;
$error++;
}
}
}
}
}
} else {
$this->error = $this->db->lasterror();
$error++;
}
} else {
dol_syslog(get_class($this) . '::Create Amount line ' . $key . ' not a number. We discard it.');
}
}
if (!$error) {
//.........這裏部分代碼省略.........
示例2: fillMailFactureBody
//.........這裏部分代碼省略.........
$subtotal[$line->tva_tx] += $line->total_ht;
$subtotaltva[$line->tva_tx] += $line->total_tva;
if (!empty($line->total_localtax1)) {
$localtax1 = $line->localtax1_tx;
}
if (!empty($line->total_localtax2)) {
$localtax2 = $line->localtax2_tx;
}
}
} else {
$message .= $langs->transnoentities("ErrNoArticles") . "\n";
}
$message .= $langs->transnoentities("TotalTTC") . ":\t" . price($facture->total_ttc) . " " . $langs->trans(currency_name($conf->currency)) . "\n";
$message .= "\n" . $langs->trans("TotalHT") . "\t" . $langs->trans("VAT") . "\t" . $langs->trans("TotalVAT") . "\n";
if (!empty($subtotal)) {
foreach ($subtotal as $totkey => $totval) {
if ($tvakey > 0) {
$message .= price($subtotal[$totkey], "", "", "", "", 2) . "\t\t\t" . price($totkey, "", "", "", "", 2) . "%\t" . price($subtotaltva[$totkey], "", "", "", "", 2) . "\n";
}
}
}
$message .= "-------------------------------\n";
$message .= price($facture->total_ht, "", "", "", "", 2) . "\t\t\t----\t" . price($facture->total_tva, "", "", "", "", 2) . "\n";
if ($facture->total_localtax1 != 0) {
$message .= $langs->transcountrynoentities("TotalLT1", $mysoc->country_code) . " " . price($localtax1, "", "", "", "", 2) . "%\t" . price($facture->total_localtax1, "", "", "", "", 2) . " " . $langs->trans(currency_name($conf->currency)) . "\n";
}
if ($facture->total_localtax2 != 0) {
$message .= $langs->transcountrynoentities("TotalLT2", $mysoc->country_code) . " " . price($localtax2, "", "", "", "", 2) . "%\t" . price($facture->total_localtax2, "", "", "", "", 2) . " " . $langs->trans(currency_name($conf->currency)) . "\n";
}
$message .= "\n\n";
$terminal = new Cash($db);
$sql = 'SELECT fk_cash, customer_pay FROM ' . MAIN_DB_PREFIX . 'pos_facture WHERE fk_facture = ' . $facture->id;
$resql = $db->query($sql);
$obj = $db->fetch_object($resql);
$customer_pay = $obj->customer_pay;
$terminal->fetch($obj > fk_cash);
if (!empty($conf->rewards->enabled)) {
$rewards = new Rewards($db);
$points = $rewards->getInvoicePoints($facture->id);
}
if ($facture->type == 0) {
$pay = $facture->getSommePaiement();
if (!empty($conf->rewards->enabled)) {
$usepoints = abs($rewards->getInvoicePoints($facture->id, 1));
$moneypoints = abs($usepoints * $conf->global->REWARDS_DISCOUNT);
//falta fer algo per aci
if ($customer_pay > $pay - $moneypoints) {
$pay = $customer_pay;
} else {
$pay = $pay - $moneypoints;
}
} else {
if ($customer_pay > $pay) {
$pay = $customer_pay;
}
}
}
if ($facture->type == 2) {
$customer_pay = $customer_pay * -1;
$pay = $facture->getSommePaiement();
if (!empty($conf->rewards->enabled)) {
$usepoints = abs($rewards->getInvoicePoints($facture->id, 1));
$moneypoints = abs($usepoints * $conf->global->REWARDS_DISCOUNT);
//falta fer algo per aci
if ($customer_pay > $pay - $moneypoints) {
$pay = $customer_pay;
} else {
$pay = $pay - $moneypoints;
}
} else {
if ($customer_pay > $pay) {
$pay = $customer_pay;
}
}
}
$diff_payment = $facture->total_ttc - $moneypoints - $pay;
$listofpayments = $facture->getListOfPayments();
foreach ($listofpayments as $paym) {
if ($paym['type'] != 'PNT') {
if ($paym['type'] != 'LIQ') {
$message .= $terminal->select_Paymentname(dol_getIdFromCode($db, $paym['type'], 'c_paiement')) . "\t" . price($paym['amount'], "", "", "", "", 2) . " " . $langs->trans(currency_name($conf->currency)) . "\n";
} else {
$message .= $terminal->select_Paymentname(dol_getIdFromCode($db, $paym['type'], 'c_paiement')) . "\t" . price($paym['amount'] - ($diff_payment < 0 ? $diff_payment : 0), "", "", "", "", 2) . " " . $langs->trans(currency_name($conf->currency)) . "\n";
}
}
}
if (!empty($conf->rewards->enabled)) {
if ($moneypoints > 0) {
$message .= $usepoints . " " . $langs->trans("Points") . "\t" . price($moneypoints, "", "", "", "", 2) . " " . $langs->trans(currency_name($conf->currency)) . "\n";
}
}
$message .= ($diff_payment < 0 ? $langs->trans("CustomerRet") : $langs->trans("CustomerDeb")) . "\t" . price(abs($diff_payment), "", "", "", "", 2) . " " . $langs->trans(currency_name($conf->currency)) . "\n";
if ($points != 0 && !empty($conf->rewards->enabled)) {
$message .= $langs->trans("TotalPointsInvoice") . "\t" . price($points, "", "", "", "", 2) . " " . $langs->trans('Points') . "\n";
$total_points = $rewards->getCustomerPoints($facture->socid);
$message .= $langs->trans("DispoPoints") . "\t" . price($total_points, "", "", "", "", 2) . " " . $langs->trans('Points') . "\n";
}
$message .= $conf->global->POS_PREDEF_MSG;
return $message;
}
示例3: abs
$usepoints = abs($rewards->getInvoicePoints($object->id, 0));
$moneypoints = -1 * ($usepoints * $conf->global->REWARDS_DISCOUNT);
//falta fer algo per aci
if ($customer_pay > $pay - $moneypoints) {
$pay = $customer_pay;
} else {
$pay = $pay - $moneypoints;
}
} else {
if ($customer_pay > $pay) {
$pay = $customer_pay;
}
}
}
$diff_payment = $object->total_ttc - $moneypoints - $pay;
$listofpayments = $object->getListOfPayments();
foreach ($listofpayments as $paym) {
if ($paym['type'] != 'PNT') {
if ($paym['type'] != 'LIQ') {
echo '<tr><th nowrap="nowrap">' . $terminal->select_Paymentname(dol_getIdFromCode($db, $paym['type'], 'c_paiement')) . '</th><td nowrap="nowrap">' . price($paym['amount'], "", "", "", "", 2) . " " . $langs->trans(currency_name($conf->currency)) . "</td></tr>";
} else {
echo '<tr><th nowrap="nowrap">' . $terminal->select_Paymentname(dol_getIdFromCode($db, $paym['type'], 'c_paiement')) . '</th><td nowrap="nowrap">' . price($paym['amount'] - (($object->type > 1 ? $diff_payment * -1 : $diff_payment) < 0 ? $diff_payment : 0), "", "", "", "", 2) . " " . $langs->trans(currency_name($conf->currency)) . "</td></tr>";
}
}
}
if (!empty($conf->rewards->enabled)) {
if ($moneypoints != 0) {
echo '<tr><th nowrap="nowrap">' . $usepoints . " " . $langs->trans("Points") . '</th><td nowrap="nowrap">' . price($moneypoints, "", "", "", "", 2) . " " . $langs->trans(currency_name($conf->currency)) . "</td></tr>";
}
}
$discount = new DiscountAbsolute($db);
示例4: abs
$usepoints = abs($rewards->getInvoicePoints($facture->id, 1));
$moneypoints = abs($usepoints * $conf->global->REWARDS_DISCOUNT);
//falta fer algo per aci
if ($customer_pay > $pay - $moneypoints) {
$pay = $customer_pay;
} else {
$pay = $pay - $moneypoints;
}
} else {
if ($customer_pay > $pay) {
$pay = $customer_pay;
}
}
}
$diff_payment = $facture->total_ttc - $moneypoints - $pay;
$listofpayments = $facture->getListOfPayments();
$pays = array();
if (!empty($listofpayments)) {
foreach ($listofpayments as $paym) {
if ($paym['type'] != 'PNT') {
if ($paym['type'] != 'LIQ') {
$paytext = $terminal->select_Paymentname(dol_getIdFromCode($db, $paym['type'], 'c_paiement')) . " " . price($paym['amount'], "", "", "", "", 2) . " " . $langs->trans(currency_name($conf->currency));
} else {
$paytext = $terminal->select_Paymentname(dol_getIdFromCode($db, $paym['type'], 'c_paiement')) . " " . price($paym['amount'] - ($diff_payment < 0 ? $diff_payment : 0), "", "", "", "", 2) . " " . $langs->trans(currency_name($conf->currency));
}
}
$pays[] = $paytext;
}
} else {
$paytext = "";
$pays[] = $paytext;
示例5: create
/**
* Create payment of invoices into database.
* Use this->amounts to have list of invoices for the payment
* @param user object user
* @param closepaidinvoices 1=Also close payed invoices to paid, 0=Do nothing more
* @return int id of created payment, < 0 if error
*/
function create($user,$closepaidinvoices=0)
{
global $langs,$conf;
$error = 0;
$now=dol_now();
// Clean parameters
$totalamount = 0;
foreach ($this->amounts as $key => $value) // How payment is dispatch
{
$newvalue = price2num($value,'MT');
$this->amounts[$key] = $newvalue;
$totalamount += $newvalue;
}
$totalamount = price2num($totalamount);
// Check parameters
if ($totalamount == 0) return -1; // On accepte les montants negatifs pour les rejets de prelevement mais pas null
$this->db->begin();
$sql = "INSERT INTO ".MAIN_DB_PREFIX."paiement (datec, datep, amount, fk_paiement, num_paiement, note, fk_user_creat)";
$sql.= " VALUES ('".$this->db->idate($now)."', '".$this->db->idate($this->datepaye)."', '".$totalamount."', ".$this->paiementid.", '".$this->num_paiement."', '".$this->db->escape($this->note)."', ".$user->id.")";
dol_syslog(get_class($this)."::Create insert paiement sql=".$sql);
$resql = $this->db->query($sql);
if ($resql)
{
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.'paiement');
// Insert links amount / invoices
foreach ($this->amounts as $key => $amount)
{
$facid = $key;
if (is_numeric($amount) && $amount <> 0)
{
$amount = price2num($amount);
$sql = 'INSERT INTO '.MAIN_DB_PREFIX.'paiement_facture (fk_facture, fk_paiement, amount)';
$sql .= ' VALUES ('.$facid.', '. $this->id.', \''.$amount.'\')';
dol_syslog(get_class($this).'::Create Amount line '.$key.' insert paiement_facture sql='.$sql);
$resql=$this->db->query($sql);
if ($resql)
{
// If we want to closed payed invoices
if ($closepaidinvoices)
{
$invoice=new Facture($this->db);
$invoice->fetch($facid);
$paiement = $invoice->getSommePaiement();
$creditnotes=$invoice->getSumCreditNotesUsed();
$deposits=$invoice->getSumDepositsUsed();
$alreadypayed=price2num($paiement + $creditnotes + $deposits,'MT');
$remaintopay=price2num($invoice->total_ttc - $paiement - $creditnotes - $deposits,'MT');
// If there is withdrawals request to do and not done yet, we wait before closing.
$mustwait=0;
$listofpayments=$invoice->getListOfPayments();
foreach($listofpayments as $paym)
{
// This payment might be this one or a previous one
if ($paym['type']=='PRE')
{
if ($conf->prelevement->enabled)
{
// TODO Check if this payment has a withdraw request
// if not, $mustwait++; // This will disable automatic close on invoice to allow to process
}
}
}
if ($invoice->type != 0 && $invoice->type != 1) dol_syslog("Invoice ".$facid." is not a standard nor replacement invoice. We do nothing more.");
else if ($remaintopay) dol_syslog("Remain to pay for invoice ".$facid." not null. We do nothing more.");
else if ($mustwait) dol_syslog("There is ".$mustwait." differed payment to process, we do nothing more.");
else $result=$invoice->set_paid($user,'','');
}
}
else
{
$this->error=$this->db->lasterror();
dol_syslog(get_class($this).'::Create insert paiement_facture error='.$this->error, LOG_ERR);
$error++;
}
}
else
{
dol_syslog(get_class($this).'::Create Amount line '.$key.' not a number. We discard it.');
}
}
if (! $error)
//.........這裏部分代碼省略.........