summaryrefslogtreecommitdiff
path: root/doc/GPL
diff options
context:
space:
mode:
authorJoey Hess <joey@kitenet.net>2010-10-08 18:02:47 -0400
committerJoey Hess <joey@kitenet.net>2010-10-08 18:02:47 -0400
commit5c6f7a8d1b805001a3d1ee912683755cec773682 (patch)
tree424edc6efbd279597d2a43991c4a3566174e73e1 /doc/GPL
parent84111d96c461a5d31a615ebf64cae751e6fd9aef (diff)
fix rcs_prepedit implementation to match spec
Diffstat (limited to 'doc/GPL')
0 files changed, 0 insertions, 0 deletions
  • # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  • # GNU General Public License for more details.
  • # You should have received a copy of the GNU General Public License
  • # along with this program; if not, write to the Free Software
  • # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  • #=====================================================================
  • #
  • # POS
  • #
  • #=====================================================================
  • use LedgerSMB::Tax;
  • 1;
  • # end
  • sub check_alert {
  • my $rc = $form->{'rowcount'};
  • if (!$form->{"partnumber_$rc"}){
  • --$rc; # Ensures that alert shows up when item is selected from a list;
  • }
  • for (1 .. $rc){
  • $form->{'check_id'} = ($form->{'check_id'} || $form->{"check_id_$_"});
  • }
  • }
  • sub send_to_pd{
  • socket(SOCK, 2, 1, getprotobynumber($pos_config{'pd_proto'}));
  • connect(SOCK, $pos_config{'pd_dest'});
  • my $rn = $numrows - 1;
  • my $ds_string = sprintf (
  • '%s%s @ $%-7.2f%s%s%s',
  • $pd_control{'new_line'},
  • $form->{"qty_$rn"},
  • $form->{"sellprice_$rn"},
  • $pd_control{'new_line'},
  • "Subtotal: \$".sprintf('%-7.2f', $form->{'invtotal'})
  • );
  • print SOCK $ds_string;
  • close SOCK;
  • }
  • sub on_update{
  • &send_to_pd;
  • &check_alert;
  • }
  • sub open_drawer{
  • open (PRINTER, "|-", ${LedgerSMB::Sysconfig::printer}{Printer});
  • print PRINTER $pos_config{'rp_cash_open'};
  • close PRINTER;
  • sleep 1;
  • }
  • sub open {
  • &open_drawer;
  • &update;
  • }
  • sub add {
  • $form->{nextsub} = 'add';
  • $form->{title} = $locale->text('Add POS Invoice');
  • $form->{callback} = "$form->{script}?action=$form->{nextsub}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}";
  • &invoice_links;
  • $form->{type} = "pos_invoice";
  • $form->{format} = "txt";
  • $form->{media} = ($myconfig{printer}) ? $myconfig{printer} : "screen";
  • $form->{rowcount} = 0;
  • $form->{readonly} = ($myconfig{acs} =~ /POS--Sale/) ? 1 : 0;
  • $ENV{REMOTE_ADDR} =~ /(\d+)\.(\d+)\.(\d+)\.(\d+)/;
  • $form->{till} = $4;
  • $form->{partsgroup} = "";
  • for (@{ $form->{all_partsgroup} }) { $form->{partsgroup} .= "$_->{partsgroup}--$_->{translation}\n"; }
  • $form->{dontdisplayend} = 1;
  • &display_form;
  • $form->{dontdisplayrows} = 1;
  • $form->{dontdisplayend} = 0;
  • &openinvoices;
  • }
  • sub openinvoices {
  • undef %column_data;
  • undef %column_heading;
  • $ENV{REMOTE_ADDR} =~ /(\d+)\.(\d+)\.(\d+)\.(\d+)/;
  • $form->{till} = $4;
  • $form->{sort} = 'transdate';
  • for (qw(open l_invnumber l_transdate l_name l_amount l_curr l_till l_subtotal)) { $form->{$_} = 'Y'; }
  • if ($myconfig{role} ne 'user') {
  • $form->{l_employee} = 'Y';
  • }
  • $form->{title} = $locale->text('Open');
  • transactions;
  • }
  • sub edit {
  • $form->{title} = $locale->text('Edit POS Invoice');
  • $form->{callback} = "$form->{script}?action=$form->{nextsub}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}";
  • &invoice_links;
  • &prepare_invoice;
  • $form->{type} = "pos_invoice";
  • $form->{format} = "txt";
  • $form->{media} = ($myconfig{printer}) ? $myconfig{printer} : "screen";
  • $form->{readonly} = ($myconfig{acs} =~ /POS--Sale/) ? 1 : 0;
  • $form->{partsgroup} = "";
  • for (@{ $form->{all_partsgroup} }) { $form->{partsgroup} .= "$_->{partsgroup}--$_->{translation}\n"; }
  • &display_form;
  • }
  • sub form_header {
  • if (!$form->{'check_id'}){
  • &check_alert;
  • }
  • # set option selected
  • for (qw(AR currency)) {
  • $form->{"select$_"} =~ s/ selected//;
  • $form->{"select$_"} =~ s/option>\Q$form->{$_}\E/option selected>$form->{$_}/;
  • }
  • for (qw(customer department employee)) {
  • $form->{"select$_"} = $form->unescape($form->{"select$_"});
  • $form->{"select$_"} =~ s/ selected//;
  • $form->{"select$_"} =~ s/(<option value="\Q$form->{$_}\E")/$1 selected/;
  • }
  • $form->{exchangerate} = $form->format_amount(\%myconfig, $form->{exchangerate});
  • $exchangerate = qq|<tr>|;
  • $exchangerate .= qq|
  • <th align=right nowrap>|.$locale->text('Currency').qq|</th>
  • <td><select name=currency>$form->{selectcurrency}</select></td> | if $form->{defaultcurrency};
  • $exchangerate .= qq|
  • <input type=hidden name=selectcurrency value="$form->{selectcurrency}">
  • <input type=hidden name=defaultcurrency value=$form->{defaultcurrency}>
  • |;
  • if ($form->{defaultcurrency} && $form->{currency} ne $form->{defaultcurrency}) {
  • if ($form->{forex}) {
  • $exchangerate .= qq|<th align=right>|.$locale->text('Exchange Rate').qq|</th><td>$form->{exchangerate}<input type=hidden name=exchangerate value=$form->{exchangerate}></td>|;
  • } else {
  • $exchangerate .= qq|<th align=right>|.$locale->text('Exchange Rate').qq|</th><td><input name=exchangerate size=10 value=$form->{exchangerate}></td>|;
  • }
  • }
  • $exchangerate .= qq|
  • <input type=hidden name=forex value=$form->{forex}>
  • </tr>
  • |;
  • if ($form->{selectcustomer}) {
  • $customer = qq|<select name=customer>$form->{selectcustomer}</select>
  • <input type=hidden name="selectcustomer" value="|.
  • $form->escape($form->{selectcustomer},1).qq|">|;
  • } else {
  • $customer = qq|<input name=customer value="$form->{customer}" size=35>|;
  • }
  • $department = qq|
  • <tr>
  • <th align="right" nowrap>|.$locale->text('Department').qq|</th>
  • <td colspan=3><select name=department>$form->{selectdepartment}</select>
  • <input type=hidden name=selectdepartment value="|.
  • $form->escape($form->{selectdepartment},1).qq|">
  • </td>
  • </tr>
  • | if $form->{selectdepartment};
  • $employee = qq|
  • <tr>
  • <th align=right nowrap>|.$locale->text('Salesperson').qq|</th>
  • <td colspan=3><select name=employee>$form->{selectemployee}</select></td>
  • <input type=hidden name=selectemployee value="|.
  • $form->escape($form->{selectemployee},1).qq|">
  • </tr>
  • | if $form->{selectemployee};
  • if ($form->{change} != $form->{oldchange}) {
  • $form->{creditremaining} -= $form->{oldchange};
  • }
  • $n = ($form->{creditremaining} < 0) ? "0" : "1";
  • if ($form->{business}) {
  • $business = qq|
  • <tr>
  • <th align=right nowrap>|.$locale->text('Business').qq|</th>
  • <td>$form->{business}</td>
  • <td width=10></td>
  • <th align=right nowrap>|.$locale->text('Trade Discount').qq|</th>
  • <td>|.$form->format_amount(\%myconfig, $form->{tradediscount} * 100).qq| %</td>
  • </tr>
  • |;
  • }
  • if ($form->{selectlanguage}) {
  • if ($form->{language_code} ne $form->{oldlanguage_code}) {
  • # rebuild partsgroup
  • $form->get_partsgroup(\%myconfig, { language_code => $form->{language_code}, searchitems => 'nolabor'});
  • $form->{partsgroup} = "";
  • for (@{ $form->{all_partsgroup} }) { $form->{partsgroup} .= "$_->{partsgroup}--$_->{translation}\n"; }
  • $form->{oldlanguage_code} = $form->{language_code};
  • }
  • $form->{"selectlanguage"} = $form->unescape($form->{"selectlanguage"});
  • $form->{"selectlanguage"} =~ s/ selected//;
  • $form->{"selectlanguage"} =~ s/(<option value="\Q$form->{language_code}\E")/$1 selected/;
  • $lang = qq|
  • <tr>
  • <th align=right>|.$locale->text('Language').qq|</th>
  • <td colspan=3><select name=language_code>$form->{selectlanguage}</select></td>
  • </tr>
  • <input type=hidden name=oldlanguage_code value=$form->{oldlanguage_code}>
  • <input type=hidden name=selectlanguage value="|.
  • $form->escape($form->{selectlanguage},1).qq|">|;
  • }
  • $i = $form->{rowcount} + 1;
  • $focus = "partnumber_$i";
  • $form->header();
  • print qq|
  • <body onLoad="document.forms[0].${focus}.focus()" />
  • <form method=post action="$form->{script}">
  • |;
  • $form->hide_form(qw(id till type format printed title discount creditlimit creditremaining tradediscount business closedto locked oldtransdate customer_id oldcustomer check_id));
  • print qq|
  • <input type=hidden name=vc value="customer">
  • <table width=100%>
  • <tr class=listtop>
  • <th class=listtop>$form->{title}</font></th>
  • </tr>|;
  • if ($form->{'check_id'}){
  • print qq|
  • <tr class=listtop>
  • <th class=listtop style="background-color: red">|.$locale->text('Check ID').qq|
  • </th>
  • </tr>|;
  • }
  • print qq|
  • <tr height="5"></tr>
  • <tr>
  • <td>
  • <table width=100%>
  • <tr valign=top>
  • <td>
  • <table>
  • <tr>
  • <th align=right nowrap>|.$locale->text('Customer').qq|</th>
  • <td colspan=3>$customer</td>
  • </tr>
  • <tr>
  • <td></td>
  • <td colspan=3>
  • <table>
  • <tr>
  • <th align=right nowrap>|.$locale->text('Credit Limit').qq|</th>
  • <td>$form->{creditlimit}</td>
  • <td width=10></td>
  • <th align=right nowrap>|.$locale->text('Remaining').qq|</th>
  • <td class="plus$n">|.$form->format_amount(\%myconfig, $form->{creditremaining}, 0, "0").qq|</font></td>
  • </tr>
  • $business
  • </table>
  • </td>
  • </tr>
  • <tr>
  • <th align=right nowrap>|.$locale->text('Record in').qq|</th>
  • <td colspan=3><select name=AR>$form->{selectAR}</select></td>
  • <input type=hidden name=selectAR value="$form->{selectAR}">
  • </tr>
  • $department
  • </table>
  • </td>
  • <td>
  • <table>
  • $employee
  • $exchangerate
  • $lang
  • </table>
  • </td>
  • </tr>
  • </table>
  • </td>
  • </tr>
  • <tr>
  • <td>
  • </td>
  • </tr>
  • |;
  • $form->hide_form(qw(taxaccounts duedate invnumber transdate selectcurrency defaultcurrency));
  • for (split / /, $form->{taxaccounts}) {
  • $form->hide_form("${_}_rate", "${_}_description", "${_}_taxnumber");
  • }
  • }
  • sub form_footer {
  • $form->{invtotal} = $form->{invsubtotal};
  • $form->{taxincluded} = ($form->{taxincluded}) ? "checked" : "";
  • $taxincluded = "";
  • if ($form->{taxaccounts}) {
  • $taxincluded = qq|
  • <tr height="5"></tr>
  • <tr>
  • <td align=right>
  • <input name=taxincluded class=checkbox type=checkbox value=1 $form->{taxincluded}></td><th align=left>|.$locale->text('Tax Included').qq|</th>
  • </tr>
  • |;
  • }
  • if (!$form->{taxincluded}) {
  • my @taxes = Tax::init_taxes($form, $form->{taxaccounts});
  • $form->{invtotal} += Tax::calculate_taxes(\@taxes, $form,
  • $form->{invsubtotal}, 0);
  • foreach my $item (@taxes) {
  • my $taccno = $item->account;
  • $form->{"${taccno}_total"} = $form->format_amount(\%myconfig,
  • $item->value, 2, 0);
  • $tax .= qq|
  • <tr>
  • <th align=right>$form->{"${taccno}_description"}</th>
  • <td align=right>$form->{"${taccno}_total"}</td>
  • </tr>
  • | if $item->value;
  • }
  • $form->{invsubtotal} = $form->format_amount(\%myconfig, $form->{invsubtotal}, 2, 0);
  • $subtotal = qq|
  • <tr>
  • <th align=right>|.$locale->text('Subtotal').qq|</th>
  • <td align=right>$form->{invsubtotal}</td>
  • </tr>
  • |;
  • }
  • @column_index = qw(paid memo source cctrack AR_paid);
  • $column_data{paid} = "<th>".$locale->text('Amount')."</th>";
  • $column_data{source} = "<th>".$locale->text('Source')."</th>";
  • $column_data{memo} = "<th>".$locale->text('Memo')."</th>";
  • $column_data{cctrack} = "<th>".$locale->text('Credit Card Track')."</th>";
  • $column_data{AR_paid} = "<th>&nbsp;</th>";
  • print qq|
  • <tr>
  • <td>
  • <table width=100%>
  • <tr valign=top>
  • <td>
  • <table>
  • <tr>
  • |;
  • for (@column_index) { print "$column_data{$_}\n"; }
  • print qq|
  • </tr>
  • |;
  • $totalpaid = 0;
  • $form->{paidaccounts}++ if ($form->{"paid_$form->{paidaccounts}"});
  • my $memoselect = qq|<SELECT name="MEMONAME">|;
  • for (sort keys %pos_sources){