Merge pull request #14531 from andreubisquerra/master
NEW: Print payment method and change in TakePOS
This commit is contained in:
commit
af36f9c784
@ -9,6 +9,7 @@
|
||||
* Copyright (C) 2018 Ferran Marcet <fmarcet@2byte.es>
|
||||
* Copyright (C) 2018 Thibault FOUCART <support@ptibogxiv.net>
|
||||
* Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
|
||||
* Copyright (C) 2020 Andreu Bisquerra Gaya <jove@bisquerra.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -73,6 +74,8 @@ class Paiement extends CommonObject
|
||||
public $amounts = array(); // array: invoice ID => amount for that invoice (in the main currency)>
|
||||
public $multicurrency_amounts = array(); // array: invoice ID => amount for that invoice (in the invoice's currency)>
|
||||
|
||||
public $pos_change = 0; // Excess received in TakePOS cash payment
|
||||
|
||||
public $author;
|
||||
public $paiementid; // Type of payment. Id saved into fields fk_paiement on llx_paiement
|
||||
public $paiementcode; // Code of payment.
|
||||
@ -288,8 +291,8 @@ class Paiement extends CommonObject
|
||||
$num_payment = ($this->num_payment ? $this->num_payment : $this->num_paiement);
|
||||
$note = ($this->note_public ? $this->note_public : $this->note);
|
||||
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."paiement (entity, ref, datec, datep, amount, multicurrency_amount, fk_paiement, num_paiement, note, ext_payment_id, ext_payment_site, fk_user_creat)";
|
||||
$sql .= " VALUES (".$conf->entity.", '".$this->db->escape($this->ref)."', '".$this->db->idate($now)."', '".$this->db->idate($this->datepaye)."', ".$total.", ".$mtotal.", ".$this->paiementid.", '".$this->db->escape($num_payment)."', '".$this->db->escape($note)."', ".($this->ext_payment_id ? "'".$this->db->escape($this->ext_payment_id)."'" : "null").", ".($this->ext_payment_site ? "'".$this->db->escape($this->ext_payment_site)."'" : "null").", ".$user->id.")";
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."paiement (entity, ref, datec, datep, amount, multicurrency_amount, fk_paiement, num_paiement, note, ext_payment_id, ext_payment_site, fk_user_creat, pos_change)";
|
||||
$sql .= " VALUES (".$conf->entity.", '".$this->db->escape($this->ref)."', '".$this->db->idate($now)."', '".$this->db->idate($this->datepaye)."', ".$total.", ".$mtotal.", ".$this->paiementid.", '".$this->db->escape($num_payment)."', '".$this->db->escape($note)."', ".($this->ext_payment_id ? "'".$this->db->escape($this->ext_payment_id)."'" : "null").", ".($this->ext_payment_site ? "'".$this->db->escape($this->ext_payment_site)."'" : "null").", ".$user->id.", ".((int) $this->pos_change).")";
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql)
|
||||
|
||||
@ -186,7 +186,7 @@ class dolReceiptPrinter extends Printer
|
||||
'dol_value_month' => 'DOL_VALUE_MONTH',
|
||||
'dol_value_day' => 'DOL_VALUE_DAY',
|
||||
'dol_value_day_letters' => 'DOL_VALUE_DAY',
|
||||
//'dol_print_payment',
|
||||
'dol_print_payment' => 'DOL_PRINT_PAYMENT',
|
||||
'dol_print_logo' => 'DOL_PRINT_LOGO',
|
||||
'dol_print_logo_old' => 'DOL_PRINT_LOGO_OLD',
|
||||
'dol_value_object_id' => 'InvoiceID',
|
||||
@ -775,6 +775,35 @@ class dolReceiptPrinter extends Printer
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'DOL_PRINT_PAYMENT':
|
||||
$sql = "SELECT p.pos_change as pos_change, p.datep as date, p.fk_paiement, p.num_paiement as num, pf.amount as amount, pf.multicurrency_amount,";
|
||||
$sql .= " cp.code";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."paiement_facture as pf, ".MAIN_DB_PREFIX."paiement as p";
|
||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as cp ON p.fk_paiement = cp.id";
|
||||
$sql .= " WHERE pf.fk_paiement = p.rowid AND pf.fk_facture = ".$object->id;
|
||||
$sql .= " ORDER BY p.datep";
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$num = $this->db->num_rows($resql);
|
||||
$i = 0;
|
||||
while ($i < $num) {
|
||||
$row = $this->db->fetch_object($resql);
|
||||
$spacestoadd = $nbcharactbyline - strlen($langs->transnoentitiesnoconv("PaymentTypeShort".$row->code)) - 12;
|
||||
$spaces = str_repeat(' ', $spacestoadd);
|
||||
$amount_payment=($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? $row->multicurrency_amount : $row->amount;
|
||||
if ($row->code == "LIQ") $amount_payment = $amount_payment + $row->pos_change; // Show amount with excess received if is cash payment
|
||||
$this->printer->text($spaces.$langs->transnoentitiesnoconv("PaymentTypeShort".$row->code).' '.str_pad(price($amount_payment), 10, ' ', STR_PAD_LEFT)."\n");
|
||||
if ($row->code == "LIQ" && $row->pos_change>0) // Print change only in cash payments
|
||||
{
|
||||
$spacestoadd = $nbcharactbyline - strlen($langs->trans("Change")) - 12;
|
||||
$spaces = str_repeat(' ', $spacestoadd);
|
||||
$this->printer->text($spaces.$langs->trans("Change").' '.str_pad(price($row->pos_change), 10, ' ', STR_PAD_LEFT)."\n");
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
$this->printer->text($vals[$tplline]['tag']);
|
||||
$this->printer->text($vals[$tplline]['value']);
|
||||
|
||||
@ -261,6 +261,8 @@ ALTER TABLE llx_projet ADD COLUMN email_msgid varchar(255);
|
||||
ALTER TABLE llx_ticket ADD COLUMN email_msgid varchar(255);
|
||||
ALTER TABLE llx_actioncomm ADD COLUMN reply_to varchar(255);
|
||||
|
||||
ALTER TABLE llx_paiement ADD pos_change DOUBLE(24,8) DEFAULT 0 AFTER fk_export_compta;
|
||||
|
||||
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('CONTACT_CREATE','Contact address created','Executed when a contact is created','contact',50);
|
||||
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('CONTACT_SENTBYMAIL','Mails sent from third party card','Executed when you send email from contact adress card','contact',51);
|
||||
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('CONTACT_DELETE','Contact address deleted','Executed when a contact is deleted','contact',52);
|
||||
|
||||
@ -37,5 +37,6 @@ create table llx_paiement
|
||||
fk_user_creat integer, -- utilisateur qui a cree l'info
|
||||
fk_user_modif integer, -- utilisateur qui a modifie l'info
|
||||
statut smallint DEFAULT 0 NOT NULL, -- Satut, 0 ou 1, 1 n'est plus supprimable
|
||||
fk_export_compta integer DEFAULT 0 NOT NULL -- fk_export_compta 0 pas exporte
|
||||
fk_export_compta integer DEFAULT 0 NOT NULL, -- fk_export_compta 0 pas exporte
|
||||
pos_change double(24,8) DEFAULT 0 -- Excess received in TakePOS cash payment
|
||||
)ENGINE=innodb;
|
||||
|
||||
@ -121,3 +121,4 @@ GiftReceiptButton=Add a "Gift receipt" button
|
||||
GiftReceipt=Gift receipt
|
||||
ModuleReceiptPrinterMustBeEnabled=Module Receipt printer must have been enabled first
|
||||
AllowDelayedPayment=Allow delayed payment
|
||||
PrintPaymentMethodOnReceipts=Print payment method on tickets|receipts
|
||||
@ -48,6 +48,7 @@ if (GETPOST('action', 'alpha') == 'set')
|
||||
$res = dolibarr_set_const($db, "TAKEPOS_SHOW_CUSTOMER", GETPOST('TAKEPOS_SHOW_CUSTOMER', 'alpha'), 'chaine', 0, '', $conf->entity);
|
||||
$res = dolibarr_set_const($db, "TAKEPOS_AUTO_PRINT_TICKETS", GETPOST('TAKEPOS_AUTO_PRINT_TICKETS', 'int'), 'int', 0, '', $conf->entity);
|
||||
$res = dolibarr_set_const($db, "TAKEPOS_PRINT_SERVER", GETPOST('TAKEPOS_PRINT_SERVER', 'alpha'), 'chaine', 0, '', $conf->entity);
|
||||
$res = dolibarr_set_const($db, "TAKEPOS_PRINT_PAYMENT_METHOD", GETPOST('TAKEPOS_PRINT_PAYMENT_METHOD', 'alpha'), 'chaine', 0, '', $conf->entity);
|
||||
|
||||
dol_syslog("admin/cashdesk: level ".GETPOST('level', 'alpha'));
|
||||
|
||||
@ -216,6 +217,13 @@ if ($conf->global->TAKEPOS_PRINT_METHOD == "browser" || $conf->global->TAKEPOS_P
|
||||
print '<td colspan="2">';
|
||||
print $form->selectyesno("TAKEPOS_SHOW_CUSTOMER", $conf->global->TAKEPOS_SHOW_CUSTOMER, 1);
|
||||
print "</td></tr>\n";
|
||||
|
||||
// Print payment method
|
||||
print '<tr class="oddeven"><td>';
|
||||
print $langs->trans('PrintPaymentMethodOnReceipts');
|
||||
print '<td colspan="2">';
|
||||
print $form->selectyesno("TAKEPOS_PRINT_PAYMENT_METHOD", $conf->global->TAKEPOS_PRINT_PAYMENT_METHOD, 1);
|
||||
print "</td></tr>\n";
|
||||
}
|
||||
|
||||
// Auto print tickets
|
||||
|
||||
@ -241,6 +241,7 @@ if ($action == 'valid' && $user->rights->facture->creer)
|
||||
$payment->datepaye = $now;
|
||||
$payment->fk_account = $bankaccount;
|
||||
$payment->amounts[$invoice->id] = $amountofpayment;
|
||||
if ($pay == 'cash') $payment->pos_change = price2num(GETPOST('excess', 'alpha'));
|
||||
|
||||
// If user has not used change control, add total invoice payment
|
||||
// Or if user has used change control and the amount of payment is higher than remain to pay, add the remain to pay
|
||||
|
||||
@ -186,11 +186,12 @@ else print "var received=0;";
|
||||
var invoiceid = <?php echo ($invoiceid > 0 ? $invoiceid : 0); ?>;
|
||||
var accountid = $("#selectaccountid").val();
|
||||
var amountpayed = $("#change1").val();
|
||||
var excess = $("#change2").val();
|
||||
if (amountpayed > <?php echo $invoice->total_ttc; ?>) {
|
||||
amountpayed = <?php echo $invoice->total_ttc; ?>;
|
||||
}
|
||||
console.log("We click on the payment mode to pay amount = "+amountpayed);
|
||||
parent.$("#poslines").load("invoice.php?place=<?php echo $place; ?>&action=valid&pay="+payment+"&amount="+amountpayed+"&invoiceid="+invoiceid+"&accountid="+accountid, function() {
|
||||
parent.$("#poslines").load("invoice.php?place=<?php echo $place; ?>&action=valid&pay="+payment+"&amount="+amountpayed+"&excess="+excess+"&invoiceid="+invoiceid+"&accountid="+accountid, function() {
|
||||
if (amountpayed > <?php echo $remaintopay; ?> || amountpayed == <?php echo $remaintopay; ?> || amountpayed==0 ) parent.$.colorbox.close();
|
||||
else location.reload();
|
||||
});
|
||||
|
||||
@ -181,6 +181,47 @@ if ($conf->global->TAKEPOS_SHOW_CUSTOMER)
|
||||
<tr>
|
||||
<th class="right"><?php if ($gift!=1) echo ''.$langs->trans("TotalTTC").'</th><td class="right">'.price($object->total_ttc, 1, '', 1, - 1, - 1, $conf->currency)."\n"; ?></td>
|
||||
</tr>
|
||||
<?php
|
||||
if ($conf->global->TAKEPOS_PRINT_PAYMENT_METHOD) {
|
||||
$sql = "SELECT p.pos_change as pos_change, p.datep as date, p.fk_paiement, p.num_paiement as num, pf.amount as amount, pf.multicurrency_amount,";
|
||||
$sql .= " cp.code";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."paiement_facture as pf, ".MAIN_DB_PREFIX."paiement as p";
|
||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as cp ON p.fk_paiement = cp.id";
|
||||
$sql .= " WHERE pf.fk_paiement = p.rowid AND pf.fk_facture = ".$facid;
|
||||
$sql .= " ORDER BY p.datep";
|
||||
$resql = $db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$num = $db->num_rows($resql);
|
||||
$i = 0;
|
||||
while ($i < $num) {
|
||||
$row = $db->fetch_object($resql);
|
||||
echo '<tr>';
|
||||
echo '<td class="right">';
|
||||
echo $langs->transnoentitiesnoconv("PaymentTypeShort".$row->code);
|
||||
echo '</td>';
|
||||
echo '<td class="right">';
|
||||
$amount_payment=($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? $row->multicurrency_amount : $row->amount;
|
||||
if ($row->code == "LIQ") $amount_payment = $amount_payment + $row->pos_change; // Show amount with excess received if is cash payment
|
||||
echo price($amount_payment, 1, '', 1, - 1, - 1, $conf->currency);
|
||||
echo '</td>';
|
||||
echo '</tr>';
|
||||
if ($row->code == "LIQ" && $row->pos_change>0) // Print change only in cash payments
|
||||
{
|
||||
echo '<tr>';
|
||||
echo '<td class="right">';
|
||||
echo $langs->trans("Change");
|
||||
echo '</td>';
|
||||
echo '<td class="right">';
|
||||
echo price($row->pos_change, 1, '', 1, - 1, - 1, $conf->currency);
|
||||
echo '</td>';
|
||||
echo '</tr>';
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
</table>
|
||||
<div style="border-top-style: double;">
|
||||
<br>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user