[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

SF.net SVN: ledger-smb:[6279] addons/1.3/wxPOS



Revision: 6279
          http://sourceforge.net/p/ledger-smb/code/6279
Author:   einhverfr
Date:     2013-11-11 09:13:57 +0000 (Mon, 11 Nov 2013)
Log Message:
-----------
Hooray, posting AR invoices via the point of sale client works

Modified Paths:
--------------
    addons/1.3/wxPOS/WXPOS/Invoice.pm
    addons/1.3/wxPOS/WXPOS/UI/AR/Pay.pm
    addons/1.3/wxPOS/scripts/LSMBDB.pm
    addons/1.3/wxPOS/setup/invoices.sql

Modified: addons/1.3/wxPOS/WXPOS/Invoice.pm
===================================================================
--- addons/1.3/wxPOS/WXPOS/Invoice.pm	2013-11-11 08:21:40 UTC (rev 6278)
+++ addons/1.3/wxPOS/WXPOS/Invoice.pm	2013-11-11 09:13:57 UTC (rev 6279)
@@ -61,12 +61,14 @@
     if ('1' eq $self->entity_class){
         $invseq = 'vinumber';
    } elsif ('2' eq $self->entity_class){
-        $invseq = 'cinumber';
+        $invseq = 'sinumber';
    }
     my ($seq) = $self->call_procedure(funcname => 'setting_increment',
                                     funcprefix => '',
                                           args => [$invseq],
     );
+    my ($val) = values %$seq;
+    return $val;
 }
 
 
@@ -238,7 +240,8 @@
     my $dbh = $self->_get_dbh;
      $dbh->{AutoCommit} = 0;
     my $sfx;
-    my $invnumber;
+    $self->invnumber;
+    warn $self->amount;
     my $invseq;
 
     if ('1' eq $self->entity_class){
@@ -246,7 +249,10 @@
     } elsif ('2' eq $self->entity_class){
         $sfx = 'ar';
     } 
-    my ($ref) = $self->call_dbmethod(funcname => "start_$sfx");
+    my $s_args = {};
+    $s_args->{"${sfx}_accno"} = $WXPOS::Sysconfig::accounts->{$sfx};
+    my ($ref) = $self->call_dbmethod(funcname => "start_$sfx", 
+                                         args => $s_args);
     my ($id) = values (%$ref);
     $self->id($id);
     foreach my $line (@{$self->invoice_lines}){

Modified: addons/1.3/wxPOS/WXPOS/UI/AR/Pay.pm
===================================================================
--- addons/1.3/wxPOS/WXPOS/UI/AR/Pay.pm	2013-11-11 08:21:40 UTC (rev 6278)
+++ addons/1.3/wxPOS/WXPOS/UI/AR/Pay.pm	2013-11-11 09:13:57 UTC (rev 6279)
@@ -136,16 +136,20 @@
 sub _Post {
     my ($self) = @_;
     my $invoice = WXPOS::Invoice->from_UI($self, 2);
-    #try {
+    try {
       $invoice->post;
-    #} catch {
-    #  Wx::MessageBox("Something went wrong.  Please try again",
-    #               "More information has been logged on this error",
-    #                wxOK|wxCENTRE|wxICON_ERROR, $self->{tab});
-    #  Carp::cluck($_);
-    #  return undef;
-    #}
+    } catch {
+      Wx::MessageBox("Something went wrong.  Please try again",
+                   "More information has been logged on this error",
+                    wxOK|wxCENTRE|wxICON_ERROR, $self->{tab});
+      warn $_;
+      return undef;
+    }
     $invoice->print(); # TODO
+    # Ok, we succeeded, now to close the current tab and window, 
+    # and initialize the next one.  -CT
+    $self->{parent_window}->_close_pane;
+    $self->EndModal(0);
 }
 
 sub get_entity_credit_account {
@@ -159,7 +163,7 @@
     my $amounts = {};
     $amounts->{paid} = $self->{total_paid}->GetLabel();
     $amounts->{netamount} = $self->{parent_window}->{net_total}->GetLabel();
-    $amounts->{total} = $self->{total}->GetLabel();
+    $amounts->{amount} = $self->{total}->GetLabel();
     return $amounts;
 }
 
@@ -199,9 +203,9 @@
        return undef;
     }
     $amounts->{paid} ||=0;
-    if ($amounts->{total} < $amounts->{paid}){
+    if ($amounts->{amount} < $amounts->{paid}){
         push @$payments, {
-           amount => $amounts->{total} - $amounts->{paid},
+           amount => $amounts->{amount} - $amounts->{paid},
            memo => 'cash',
            source => 'change'
         };

Modified: addons/1.3/wxPOS/scripts/LSMBDB.pm
===================================================================
--- addons/1.3/wxPOS/scripts/LSMBDB.pm	2013-11-11 08:21:40 UTC (rev 6278)
+++ addons/1.3/wxPOS/scripts/LSMBDB.pm	2013-11-11 09:13:57 UTC (rev 6279)
@@ -28,7 +28,7 @@
 sub new {
  my ($class, $user, $pass, $comp, $host) = @_;
  my $self = {};
- $self->{dbh} = DBI->connect("dbi:Pg:dbname=$comp;host=$host", $user, $pass, {RaiseError => 0, AutoCommit => 1});
+ $self->{dbh} = DBI->connect("dbi:Pg:dbname=$comp;host=$host", $user, $pass, {RaiseError => 1, AutoCommit => 1, pg_server_prepare => 0});
  if ($self->{dbh}) {
   $WXPOS::State::DBH = $self->{dbh};
   bless $self, $class;

Modified: addons/1.3/wxPOS/setup/invoices.sql
===================================================================
--- addons/1.3/wxPOS/setup/invoices.sql	2013-11-11 08:21:40 UTC (rev 6278)
+++ addons/1.3/wxPOS/setup/invoices.sql	2013-11-11 09:13:57 UTC (rev 6279)
@@ -54,20 +54,20 @@
 $$;
 
 CREATE OR REPLACE FUNCTION invoice__add_item_ar
-(in_id int, in_parts_id int, in_qty int, in_discount numeric,
- in_unit text)
+(in_id int, in_parts_id int, in_qty numeric, in_discount numeric,
+ in_unit text, in_sellprice numeric)
 RETURNS BOOL LANGUAGE SQL AS
 $$
-INSERT INTO invoice(trans_id, parts_id, qty, discount, unit, allocated)
-SELECT $1, p.id, $3, $4, coalesce($5), 0
+INSERT INTO invoice(trans_id, parts_id, qty, discount, unit, allocated, sellprice)
+SELECT $1, p.id, $3, $4, coalesce($5), 0, $6
   FROM parts p WHERE id = $2;
 
 SELECT TRUE;
 $$;
 
 COMMENT ON FUNCTION invoice__add_item_ar
-(in_id int, in_parts_id int, in_qty int, in_discount numeric,
- in_unit text)
+(in_id int, in_parts_id int, in_qty numeric, in_discount numeric,
+ in_unit text, in_sellprice numeric)
 IS $$This adds an item to the invoice.  This is not safe to use alone.  If you 
 use it, you MUST also use invoice__finalize_ar.  In particular this function does
 not add income, inventory, or COGS calculations. $$;
@@ -94,7 +94,7 @@
    -- income 
    INSERT INTO acc_trans (trans_id, chart_id, transdate, amount, approved, 
                          invoice_id)
-   SELECT in_id, p.income_accno_id, a.transdate, i.qty * i.sellprice, true, i.id
+   SELECT in_id, p.income_accno_id, a.transdate, i.qty * i.sellprice * -1, true, i.id
      FROM parts p
      JOIN invoice i ON i.parts_id = p.id
      JOIN ar a ON i.trans_id = a.id AND a.id = in_id;

This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.


------------------------------------------------------------------------------
November Webinars for C, C++, Fortran Developers
Accelerate application performance with scalable programming models. Explore
techniques for threading, error checking, porting, and tuning. Get the most 
from the latest Intel processors and coprocessors. See abstracts and register
http://pubads.g.doubleclick.net/gampad/clk?id=60136231&iu=/4140/ostg.clktrk
_______________________________________________
Ledger-smb-commits mailing list
..hidden..
https://lists.sourceforge.net/lists/listinfo/ledger-smb-commits