From fcd5ee36c7b5f42d557ca7b0ec8be997c0faaadb Mon Sep 17 00:00:00 2001 From: einhverfr Date: Tue, 3 Oct 2006 03:26:37 +0000 Subject: Merged SL-POS. git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk@185 4979c152-3d1c-0410-bac9-87ea11338e46 --- bin/mozilla/gl.pl | 21 +++- bin/mozilla/ir.pl | 65 ++++++++++ bin/mozilla/pos.pl | 122 ++++++++++++++++-- bin/mozilla/ps.pl | 1 + bin/mozilla/rc.pl | 353 +++++++++++++++++++++++++++++++++++++++++++++++++++-- 5 files changed, 541 insertions(+), 21 deletions(-) (limited to 'bin') diff --git a/bin/mozilla/gl.pl b/bin/mozilla/gl.pl index 3e238609..9a83675a 100755 --- a/bin/mozilla/gl.pl +++ b/bin/mozilla/gl.pl @@ -83,7 +83,23 @@ require "$form->{path}/arap.pl"; # $locale->text('Nov') # $locale->text('Dec') +sub pos_adjust { + $form->{rowcount} = 3; + require "pos.conf.pl"; + $form->{accno_1} = $pos_config{'close_cash_accno'}; + $form->{accno_2} = $pos_config{'coa_prefix'}; + $form->{accno_3} = $pos_config{'coa_prefix'}; +} +sub add_pos_adjust { + $form->{pos_adjust} = 1; + $form->{reference} = $locale->text("Adjusting Till: (till) Source: (source)"); + $form->{description} = + $locale->text("Adjusting till due to data entry error."); + $form->{callback} = "$form->{script}?action=add_pos_adjust&transfer=$form->{transfer}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}" unless $form->{callback}; + &add; +} + sub add { $form->{title} = "Add"; @@ -93,6 +109,9 @@ sub add { &create_links; $form->{rowcount} = ($form->{transfer}) ? 3 : 9; + if ($form->{pos_adjust}){ + &pos_adjust; + } $form->{oldtransdate} = $form->{transdate}; $form->{focus} = "reference"; @@ -856,7 +875,7 @@ sub display_rows { |; } - $form->hide_form(qw(rowcount selectaccno)); + $form->hide_form(qw(rowcount selectaccno pos_adjust)); print qq| |; diff --git a/bin/mozilla/ir.pl b/bin/mozilla/ir.pl index 1e77dce5..35f9975b 100755 --- a/bin/mozilla/ir.pl +++ b/bin/mozilla/ir.pl @@ -461,10 +461,12 @@ sub form_footer { |.$locale->text('Notes').qq| |.$locale->text('Internal Notes').qq| + |.$locale->text('Import Text').qq| $notes $intnotes + @@ -624,8 +626,71 @@ print qq| } +sub import_text { + my @o_list; + my @i_lines = split(/(\n|\r|\r\n)/, $form->{import_text}); + foreach $i (@i_lines){ + chomp($i); + if ($i != ""){ # Strip out blank lines + push @o_list, $i; + } + } + my $c = 1; + my $linenumber = 0; + foreach $l (@o_list){ + if ($c % 2){ + $linenumber += 1; + $form->{"partnumber_$linenumber"} = $l; + } + else { + $form->{"qty_$linenumber"} = $l; + } + $c += 1; + $form->{rowcount}=$linenumber; + IR->retrieve_item(\%myconfig, \%$form); + $rows = scalar @{ $form->{item_list} }; + $rows = 0 unless $rows; + $i = $form->{rowcount}; + if ($rows = 0){ + $form->{"id_$i"} = 0; + $form->{"unit_$i"} = $locale->text('ea'); + + &new_item; + } elsif ($rows > 1){ + &select_item; + exit; + } else { + map { $form->{item_list}[$i]{$_} = $form->quote($form->{item_list}[$i]{$_}) } qw(partnumber description unit); + + map { $form->{"${_}_$i"} = $form->{item_list}[0]{$_} } keys %{ $form->{item_list}[0] }; + + $s = ($sellprice) ? $sellprice : $form->{"sellprice_$i"}; + + ($dec) = ($s =~ /\.(\d+)/); + $dec = length $dec; + $decimalplaces = ($dec > 2) ? $dec : 2; + + $amount = $form->{"sellprice_$i"} * $form->{"qty_$i"} * (1 - $form->{"discount_$i"} / 100); + map { $form->{"${_}_base"} = 0 } (split / /, $form->{taxaccounts}); + map { $form->{"${_}_base"} += $amount } (split / /, $form->{"taxaccounts_$i"}); + map { $amount += ($form->{"${_}_base"} * $form->{"${_}_rate"}) } split / /, $form->{"taxaccounts_$i"} if !$form->{taxincluded}; + + $form->{creditremaining} -= $amount; + + $form->{"sellprice_$i"} = $form->format_amount(\%myconfig, $form->{"sellprice_$i"}, $decimalplaces); + $form->{"qty_$i"} = $form->format_amount(\%myconfig, $form->{"qty_$i"}); + + } + $form->{item_list} = []; + } + ++$form->{rowcount} +} sub update { + if($form->{import_text}){ + &import_text; + } + $form->{exchangerate} = $form->parse_amount(\%myconfig, $form->{exchangerate}); diff --git a/bin/mozilla/pos.pl b/bin/mozilla/pos.pl index 53627496..f7f817ea 100755 --- a/bin/mozilla/pos.pl +++ b/bin/mozilla/pos.pl @@ -44,12 +44,55 @@ 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, "|-", $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}" unless $form->{callback}; + $form->{callback} = "$form->{script}?action=$form->{nextsub}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}"; &invoice_links; @@ -68,10 +111,14 @@ sub add { &display_form; + $form->{dontdisplayrows} = 1; + &openinvoices; } sub openinvoices { + undef %column_data; + undef %column_heading; $ENV{REMOTE_ADDR} =~ /(\d+)\.(\d+)\.(\d+)\.(\d+)/; $form->{till} = $4; @@ -94,7 +141,7 @@ 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}" unless $form->{callback}; + $form->{callback} = "$form->{script}?action=$form->{nextsub}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}"; &invoice_links; &prepare_invoice; @@ -115,6 +162,10 @@ sub edit { sub form_header { + if (!$form->{'check_id'}){ + &check_alert; + } + # set option selected for (qw(AR currency)) { $form->{"select$_"} =~ s/ selected//; @@ -228,7 +279,7 @@ sub form_header {
|; - $form->hide_form(qw(id till type format printed title discount creditlimit creditremaining tradediscount business closedto locked oldtransdate customer_id oldcustomer)); + $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| @@ -236,7 +287,15 @@ sub form_header { - + |; + if ($form->{'check_id'}){ + print qq| + + + |; + } + print qq| |; + if ($form->{"paid__$i"}){ + $column_data{paid} = qq||; + } else { + $column_data{paid} = qq||; + } + $column_data{source} = qq||; $column_data{memo} = qq||; - $column_data{AR_paid} = qq||; + if ($pos_config{"coa_prefix"}){ + if (!$form->{"AR_paid_$i"}){ + $form->{"AR_paid_$i"} = + $pos_config{"coa_prefix"}.'.'.$pos_config{"till"}; + } + $column_data{AR_paid} = qq||; + } else { + $column_data{AR_paid} = qq||; + } print qq| |; @@ -520,6 +592,7 @@ sub form_footer { sub post { + $form->{media} = 'Printer'; $form->isblank("customer", $locale->text('Customer missing!')); # if oldcustomer ne customer redo form @@ -532,6 +605,7 @@ sub post { } &validate_items; + &print; $form->isblank("exchangerate", $locale->text('Exchange rate missing!')) if ($form->{currency} ne $form->{defaultcurrency}); @@ -542,7 +616,16 @@ sub post { $total = $form->parse_amount(\%myconfig, $form->{invtotal}); # deduct change from first payment - $form->{"paid_1"} = $form->format_amount(\%myconfig, $form->parse_amount(\%myconfig, $form->{"paid_1"}) - ($paid - $total), 2) if $paid > $total; + #$form->{"paid_1"} = $form->{invtotal} if $paid > $total; + $form->{paid} = $paid; + if ($paid > $total){ + ++$form->{paidaccounts}; + my $pa = $form->{paidaccounts}; + $form->{"paid_$pa"} = $total - $paid; + $form->{"source_$pa"} = 'cash'; + $form->{"exchangerate_$pa"} = 0; + $form->{"AR_paid_$pa"} = $form->{AR_paid_1} + } ($form->{AR}) = split /--/, $form->{AR}; @@ -667,6 +750,22 @@ sub display_row { sub print { + if (!$form->{invnumber}){ + $form->{invnumber} = $form->update_defaults(\%myconfig, 'sinumber'); + } + $rc = $form->{'rowcount'}; + $pc = $form->{'paidaccounts'}; + if ($form->{"partnumber_$rc"} || $form->{"description_$rc"} || + $form->{"paid_$pc"}){ + &update; + exit; + } + for $i (1 .. $rc - 1){ + if ($form->{"qty_$i"} != $form->{"oldqty_$i"}){ + &update; + exit; + } + } if (!$form->{invnumber}) { $form->{invnumber} = $form->update_defaults(\%myconfig, "sinumber"); @@ -681,7 +780,8 @@ sub print { for (qw(employee department)) { $form->{$_} =~ s/--.*//g; } $form->{invdate} = $form->{transdate}; - $form->{dateprinted} = scalar localtime; + my @lt = localtime(); + $form->{dateprinted} = $lt[2].":".$lt[1].":".$lt[0]; &print_form($old_form); @@ -690,6 +790,7 @@ sub print { sub print_form { my $old_form = shift; + &open_drawer; # if oldcustomer ne customer redo form $customer = $form->{customer}; @@ -743,6 +844,7 @@ sub print_form { $form->{rowcount}--; $form->{pre} = "\n
";
   delete $form->{stylesheet};
+  $form->{cd_open} = $pos_config{rp_cash_drawer_open};
   
   $form->parse_template(\%myconfig, $userspath);
 
@@ -768,7 +870,7 @@ sub print_form {
 
     if (! $form->{printandpost}) {
       $form->{rowcount}--;
-      &display_form;
+      #&display_form;
     }
   }
 
diff --git a/bin/mozilla/ps.pl b/bin/mozilla/ps.pl
index d8a8bef9..7601fd7e 100755
--- a/bin/mozilla/ps.pl
+++ b/bin/mozilla/ps.pl
@@ -50,6 +50,7 @@ require "$form->{path}/ar.pl";
 require "$form->{path}/is.pl";
 require "$form->{path}/rp.pl";
 require "$form->{path}/pos.pl";
+require "pos.conf.pl";
 
 # customizations
 if (-f "$form->{path}/custom_pos.pl") {
diff --git a/bin/mozilla/rc.pl b/bin/mozilla/rc.pl
index c310f9e0..fc5ee24d 100755
--- a/bin/mozilla/rc.pl
+++ b/bin/mozilla/rc.pl
@@ -188,10 +188,299 @@ sub reconciliation {
 
 sub continue { &{ $form->{nextsub} } };
 
+sub till_closing {
+  $form->{callback} = "$form->{script}?path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}";
+
+  @colheadings = qw(Source Actual Expected Error);
+
+  $form->{title} = "Closing Till For $form->{login}";
+  require "pos.conf.pl"; 
+  RC->getposlines(\%myconfig, \%$form);
+  $form->header;
+  print qq|
+
+
+{script}>
+{path}>
+{login}>
+{sessionid}>
+
+
+
+
$form->{title}
|.$locale->text('Check ID').qq| +
@@ -378,12 +437,25 @@ sub form_footer { $form->{"paid_$i"} = $form->format_amount(\%myconfig, $form->{"paid_$i"}, 2); $form->{"exchangerate_$i"} = $form->format_amount(\%myconfig, $form->{"exchangerate_$i"}); - - $column_data{paid} = qq|{"paid_$i"}>{"paid_$i"}>{"paid_$i"}>
+ + + +
$form->{title}
+ +|; + + print ""; + map {print "";} @colheadings; + print ""; + my $j; + my $source; + foreach $source (sort keys %pos_sources){ + $amount = 0; + foreach $ref (@{$form->{TB}}){ + if ($ref->{source} eq $source){ + $amount = $ref->{amount} * -1; + last; + } + } + ++$j; + $j = $j % 2; + print qq| + + + |; + } + print qq| + + +
$_
|.$pos_sources{$source}.qq| + \$$amount 
++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
X \$100 =
X \$50 =
X \$20 =
X \$10 =
X \$5 =
X \$1 =
X \$0.50 =
X \$.25 =
X \$.10 =
X \$.05 =
X \$.01 =
 Subtotal:
+ +|; + print qq||; + print qq| +
+ + + +|; +} + + +sub close_till { + use SL::GL; + require 'pos.conf.pl'; + RC->clear_till(\%myconfig, \%$form); + my $amount = 0; + my $expected = 0; + my $difference = 0; + my $lines = ''; + $form->{rowcount} = 2; + foreach $key (keys %pos_sources){ + $amount = 0; + $expected = 0; + $amount = $form->parse_amount(\%myconfig, $form->{"amount_$key"}); + $expected = $form->parse_amount(\%myconfig, $form->{"expected_$key"}); + $gl_entry = "Closing Till $pos_config{till} source = $key"; + $accno1 = $pos_config{till_accno}; + if (${$pos_config{'source_accno_override'}{$key}}){ + $accno2 = ${$pos_config{'source_accno_override'}{$key}}; + } else { + $accno2 = $pos_config{'close_cash_accno'}; + } + $form->{reference} = $gl_entry; + $form->{accno_1} = $accno1; + $form->{credit_1} = $amount; + $form->{accno_2} = $accno2; + $form->{debit_2} = $amount; + $form->{transdate} = $form->current_date(\%myconfig); + GL->post_transaction(\%myconfig, \%$form); + delete $form->{id}; + $error = $amount - $expected; + $difference += $error; + $lines .= "Source: $key, Amount: $amount\nExpected: $expected. Error= $error\n\n"; + } + $gl_entry = "Closing Till: $pos_config{till} Over/Under"; + $amount = $difference * -1; + $form->{reference} = $gl_entry; + $form->{accno_1} = $accno1; + $form->{credit_1} = $amount; + $form->{accno_2} = $pos_config{coa_prefix}; + $form->{debit_2} = $amount; + $form->{transdate} = $form->current_date(\%myconfig); + GL->post_transaction(\%myconfig, \%$form); + delete $form->{id}; + $lines .= "Cumulative Error: $amount"; + $form->{accno} = $form->{accno_1}; + RC->getbalance(\%myconfig, \%$form); + $amount = $form->{balance} * -1; + $gl_entry = "Resetting Till: $pos_config{till}"; + $form->{reference} = $gl_entry; + $form->{accno_1} = $accno1; + $form->{credit_1} = $amount; + $form->{accno_2} = $pos_config{coa_prefix}; + $form->{debit_2} = $amount; + $form->{transdate} = $form->current_date(\%myconfig); + GL->post_transaction(\%myconfig, \%$form); + delete $form->{id}; + + $head = "Closing Till $pos_config{till} for $form->{login}\n". + "Date: $form->{transdate}\n\n\n"; + $cash = join ("\n", + ("Cash Breakdown:", + "$form->{calc_100} x 100 = $form->{sub_100}", + "$form->{calc_50} x 50 = $form->{sub_50}", + "$form->{calc_20} x 20 = $form->{sub_20}", + "$form->{calc_10} x 10 = $form->{sub_10}", + "$form->{calc_5} x 5 = $form->{sub_5}", + "$form->{calc_1} x 1 = $form->{sub_1}", + "$form->{calc_050} x 0.50 = $form->{sub_050}", + "$form->{calc_025} x 0.25 = $form->{sub_025}", + "$form->{calc_010} x 0.10 = $form->{sub_010}", + "$form->{calc_005} x 0.05 = $form->{sub_005}", + "$form->{calc_001} x 0.01 = $form->{sub_001}", + "Total Cash in Drawer: $form->{sub_sub}", + "Less Cash in Till At Start: $pos_config{till_cash}", + "\n")); + $foot = "Cumulative Error: $difference\n Reset Till By $amount\n\n\n\n\n\n\n\n\n\n"; + open (PRN, "|-", $printer{Printer}); + print PRN $head; + print PRN $lines; + print PRN $cash; + print PRN $cash; + print PRN $foot; + close PRN; + if ($difference > 0){ + $message = "You are over by ".$difference; + } elsif ($difference < 0){ + $message = "You are under by ".$difference * -1; + } + else { + $message = "Congradulations! Your till is exactly balanced."; + } + $form->info($message); +} sub get_payments { ($form->{accno}, $form->{account}) = split /--/, $form->{accno}; + if ($form->{'pos'}){ + require "pos.conf.pl"; + $form->{fromdate} = $form->current_date(\%myconfig); + unless ($form->{source}){ + $form->{source} = (sort keys(%pos_sources))[0]; + } + if ($form->{source} eq 'cash'){ + $form->{summary} = "true"; + } else { + $form->{summary} = ""; + } + $form->{accno} = $pos_config{'coa_prefix'} . "." . $pos_config{'till'}; + $form->{account} = $form->{source}; + } RC->payment_transactions(\%myconfig, \%$form); @@ -243,6 +532,8 @@ sub display_form {
{script}> + + @@ -359,12 +650,15 @@ sub display_form { $column_data{cleared} = qq|{cleared}> {oldcleared}> - |; + + |; } else { $cleared += $ref->{amount} * $ml if $checked; $clearfx = ($checked) ? 1 : 0; $column_data{cleared} = qq||; + + + |; } } @@ -402,6 +696,9 @@ sub display_form { $form->{statementbalance} = $form->parse_amount(\%myconfig, $form->{statementbalance}); $difference = $form->format_amount(\%myconfig, $form->{beginningbalance} + $cleared - $form->{statementbalance}, 2, 0); + if ($form->{source}){ + $difference = 0; + } $form->{statementbalance} = $form->format_amount(\%myconfig, $form->{statementbalance}, 2, 0); print qq| @@ -411,7 +708,46 @@ sub display_form { |; - + if ($form->{'pos'}){ + $close_next = qq||; + $done = ""; + } + else { + $close_next = ""; + $done = qq||; + } + if ($form->{'pos'}){ + $difference = qq| + + + + + + + |; + if ($form->{'over_under'}){ + $o_u = $form->{'over_under'}; + $difference =~ s/(value=$o_u)/SELECTED $1/g; + } + } else { + $difference = qq| + + + + + + |; + } + + if ($form->{report}) { print qq| @@ -434,12 +770,7 @@ sub display_form { - - - - - - + $difference
$form->{title}* -
+
|.$locale->text('Difference').qq|
{statementbalance}>
|.$locale->text('Difference').qq|
@@ -458,7 +789,8 @@ sub display_form {
-|; + $done + $close_next |; } if ($form->{menubar}) { @@ -477,6 +809,7 @@ sub display_form { sub update { + $form->{null2} = $form->{null}; RC->payment_transactions(\%myconfig, \%$form); -- cgit v1.2.3