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

SF.net SVN: ledger-smb:[6305] addons/1.3/wxPOS-simple/WXPOS/UI



Revision: 6305
          http://sourceforge.net/p/ledger-smb/code/6305
Author:   einhverfr
Date:     2013-11-21 14:29:11 +0000 (Thu, 21 Nov 2013)
Log Message:
-----------
Fixes for simplified workflow (no tax support, no change counting, just fast in/fast out

Modified Paths:
--------------
    addons/1.3/wxPOS-simple/WXPOS/UI/AP.pm
    addons/1.3/wxPOS-simple/WXPOS/UI/AR.pm

Modified: addons/1.3/wxPOS-simple/WXPOS/UI/AP.pm
===================================================================
--- addons/1.3/wxPOS-simple/WXPOS/UI/AP.pm	2013-11-21 13:16:22 UTC (rev 6304)
+++ addons/1.3/wxPOS-simple/WXPOS/UI/AP.pm	2013-11-21 14:29:11 UTC (rev 6305)
@@ -9,6 +9,7 @@
 use lib 'scripts';
 use WXPOS::UI::AP::Pay;
 use Math::BigFloat; # for rounding
+use Try::Tiny;
 
 # TODO:
 # Need payment/posting screen
@@ -109,14 +110,29 @@
 
 ### Pay
  Wx::StaticLine->new($self->{tab}, -1, [0, 490], [800, 2], wxLI_HORIZONTAL);
- Wx::StaticText->new($self->{tab}, -1, 'Net: ', [100, 500], [90, 24]);
- $self->{net_total} = Wx::StaticText->new($self->{tab}, -1, '', [200, 500], [90, 24]);
- Wx::StaticText->new($self->{tab}, -1, 'Tax: ', [300, 500], [90, 24]);
- $self->{tax_total} = Wx::StaticText->new($self->{tab}, -1, '', [400, 500], [90, 24]);
- Wx::StaticText->new($self->{tab}, -1, 'Total: ', [500, 500], [90, 24]);
- $self->{total} = Wx::StaticText->new($self->{tab}, -1, '', [600, 500], [90, 24]);
+ Wx::StaticText->new($self->{tab}, -1, 'Total: ', [0, 500], [90, 24]);
+ $self->{net_total} = Wx::StaticText->new($self->{tab}, -1, '', [50, 500], [90, 24]);
+ $self->{net_total}->Show(0);
+ $self->{tax_total} = Wx::StaticText->new($self->{tab}, -1, '', [200, 500], [90, 24]);
+ $self->{tax_total}->Show(0);
+ Wx::StaticText->new($self->{tab}, -1, 'Total: ', [0, 500], [90, 24]);
+ $self->{total} = Wx::StaticText->new($self->{tab}, -1, '', [50, 500], [90, 24]);
+## pmt info
+
+ my $paytypes = $WXPOS::Sysconfig::payment_types;
+ $paytypes = [''] unless @$paytypes;
+ Wx::StaticText->new($self->{WxPanel}, -1, 'Type', [150, 500], [80, 24]);
+ $self->{memo} = Wx::ComboBox->new($self->{tab}, -1, $paytypes->[0], 
+                              [200, 500], [75, 24], 
+                              $paytypes, wxCB_READONLY);
+    
+ Wx::StaticText->new($self->{tab}, -1, 'Source', [350, 500], [80, 24]);
+ $self->{source} = Wx::TextCtrl->new($self->{tab}, -1, '', 
+                                 [400, 500], [60, 24]
+ );
+
  my $invoice_post = Wx::Button->new($self->{tab}, -1, 'Pay', [700, 500], [90, 24]);
- EVT_BUTTON($self->{tab}, $invoice_post, sub{$self->_InvoicePay});
+ EVT_BUTTON($self->{tab}, $invoice_post, sub{$self->_Post});
 
 ## Finishing
  if ($dft_vendor){
@@ -306,4 +322,76 @@
     return sprintf("%.0" . ($WXPOS::Sysconfig::money_places) . "f", $num->bstr());
 }
 
+sub get_entity_credit_account {
+    my ($self) = @_;
+    return $self->{customer_search}
+           ->{$self->{customer_list}->GetValue()};;
+}
+
+sub get_amounts {
+    my ($self) = @_;
+    my $amounts = {};
+    $amounts->{netamount} = $self->{total}->GetLabel();
+    $amounts->{amount} = $self->{total}->GetLabel();
+    $amounts->{paid} = $self->{total}->GetLabel();
+    return $amounts;
+}
+
+sub get_lines {
+    my ($self) = @_;
+    my $lines = [];
+    my $list = $self->{list};
+    my $item = -1;
+
+    while (($item = $list->GetNextItem($item)) > -1){
+        my $line = {};
+        $line->{partnumber} = $list->GetItem($item, 0)->GetText(); 
+        $line->{sellprice} = $list->GetItem($item, 2)->GetText();
+        $line->{qty} =  $list->GetItem($item, 5)->GetText();
+        push @$lines, $line;
+    }
+    
+    return $lines; 
+}
+
+sub get_payments {
+    my ($self) = @_;
+    my $list = $self->{list};
+    my $item = -1;
+    my $payments = [];
+    my $amounts = $self->get_amounts();
+    push @$payments, {amount => $amounts->{amount},
+                        memo => $self->{memo}->GetValue,
+                      source => $self->{source}->GetValue,
+    };
+    return $payments;
+}
+
+sub _Post {
+    my ($self) = @_;
+    my $invoice = WXPOS::Invoice->from_UI($self, 2);
+    try {
+      $invoice->post;
+      $invoice->print(); # TODO
+      # Ok, we succeeded, now to close the current tab and window, 
+      # and initialize the next one.  -CT
+    
+      $self->_close_pane;
+      $self->{sesion}->{nb}->AddPage(
+            WXPOS::UI::AR->new($self->{sesion}, 
+                                        'Invoice'), 'Invoice', 1
+      );
+
+    } catch {
+      Wx::MessageBox("Something went wrong.  Please try again",
+                   "More information has been logged on this error",
+                    wxOK|wxCENTRE|wxICON_ERROR, $self->{tab});
+      warn $_;
+      my $dbh = $WXPOS::State::DBH;
+      $dbh->rollback;
+      $dbh->{autocommit} = 1;
+      
+    }
+}
+
 1;

Modified: addons/1.3/wxPOS-simple/WXPOS/UI/AR.pm
===================================================================
--- addons/1.3/wxPOS-simple/WXPOS/UI/AR.pm	2013-11-21 13:16:22 UTC (rev 6304)
+++ addons/1.3/wxPOS-simple/WXPOS/UI/AR.pm	2013-11-21 14:29:11 UTC (rev 6305)
@@ -9,6 +9,7 @@
 use WXPOS::State;
 use lib 'scripts';
 use WXPOS::UI::AR::Pay;
+use Try::Tiny;
 #use WXPOS::UI::Controls::InvoiceEntry; # Not working on wxwidgets 2.8
 use Math::BigFloat; # for rounding
 
@@ -115,14 +116,29 @@
 
 ### Pay
  Wx::StaticLine->new($self->{tab}, -1, [0, 490], [800, 2], wxLI_HORIZONTAL);
- Wx::StaticText->new($self->{tab}, -1, 'Net: ', [100, 500], [90, 24]);
- $self->{net_total} = Wx::StaticText->new($self->{tab}, -1, '', [200, 500], [90, 24]);
- Wx::StaticText->new($self->{tab}, -1, 'Tax: ', [300, 500], [90, 24]);
- $self->{tax_total} = Wx::StaticText->new($self->{tab}, -1, '', [400, 500], [90, 24]);
- Wx::StaticText->new($self->{tab}, -1, 'Total: ', [500, 500], [90, 24]);
- $self->{total} = Wx::StaticText->new($self->{tab}, -1, '', [600, 500], [90, 24]);
+ Wx::StaticText->new($self->{tab}, -1, 'Total: ', [0, 500], [90, 24]);
+ $self->{net_total} = Wx::StaticText->new($self->{tab}, -1, '', [50, 500], [90, 24]);
+ $self->{net_total}->Show(0);
+ $self->{tax_total} = Wx::StaticText->new($self->{tab}, -1, '', [200, 500], [90, 24]);
+ $self->{tax_total}->Show(0);
+ Wx::StaticText->new($self->{tab}, -1, 'Total: ', [0, 500], [90, 24]);
+ $self->{total} = Wx::StaticText->new($self->{tab}, -1, '', [50, 500], [90, 24]);
+## pmt info
+
+ my $paytypes = $WXPOS::Sysconfig::payment_types;
+ $paytypes = [''] unless @$paytypes;
+ Wx::StaticText->new($self->{WxPanel}, -1, 'Type', [150, 500], [80, 24]);
+ $self->{memo} = Wx::ComboBox->new($self->{tab}, -1, $paytypes->[0], 
+                              [200, 500], [75, 24], 
+                              $paytypes, wxCB_READONLY);
+    
+ Wx::StaticText->new($self->{tab}, -1, 'Source', [350, 500], [80, 24]);
+ $self->{source} = Wx::TextCtrl->new($self->{tab}, -1, '', 
+                                 [400, 500], [60, 24]
+ );
+
  my $invoice_post = Wx::Button->new($self->{tab}, -1, 'Pay', [700, 500], [90, 24]);
- EVT_BUTTON($self->{tab}, $invoice_post, sub{$self->_InvoicePay});
+ EVT_BUTTON($self->{tab}, $invoice_post, sub{$self->_Post});
 
 ## Finishing
  if ($dft_custom){
@@ -320,4 +336,76 @@
     return sprintf("%.0" . ($WXPOS::Sysconfig::money_places) . "f", $num->bstr());
 }
 
+sub get_entity_credit_account {
+    my ($self) = @_;
+    return $self->{customer_search}
+           ->{$self->{customer_list}->GetValue()};;
+}
+
+sub get_amounts {
+    my ($self) = @_;
+    my $amounts = {};
+    $amounts->{netamount} = $self->{total}->GetLabel();
+    $amounts->{amount} = $self->{total}->GetLabel();
+    $amounts->{paid} = $self->{total}->GetLabel();
+    return $amounts;
+}
+
+sub get_lines {
+    my ($self) = @_;
+    my $lines = [];
+    my $list = $self->{list};
+    my $item = -1;
+
+    while (($item = $list->GetNextItem($item)) > -1){
+        my $line = {};
+        $line->{partnumber} = $list->GetItem($item, 0)->GetText(); 
+        $line->{sellprice} = $list->GetItem($item, 2)->GetText();
+        $line->{qty} =  $list->GetItem($item, 5)->GetText();
+        push @$lines, $line;
+    }
+    
+    return $lines; 
+}
+
+sub get_payments {
+    my ($self) = @_;
+    my $list = $self->{list};
+    my $item = -1;
+    my $payments = [];
+    my $amounts = $self->get_amounts();
+    push @$payments, {amount => $amounts->{amount},
+                        memo => $self->{memo}->GetValue,
+                      source => $self->{source}->GetValue,
+    };
+    return $payments;
+}
+
+sub _Post {
+    my ($self) = @_;
+    my $invoice = WXPOS::Invoice->from_UI($self, 2);
+    try {
+      $invoice->post;
+      $invoice->print(); # TODO
+      # Ok, we succeeded, now to close the current tab and window, 
+      # and initialize the next one.  -CT
+    
+      $self->_close_pane;
+      $self->{sesion}->{nb}->AddPage(
+            WXPOS::UI::AR->new($self->{sesion}, 
+                                        'Invoice'), 'Invoice', 1
+      );
+
+    } catch {
+      Wx::MessageBox("Something went wrong.  Please try again",
+                   "More information has been logged on this error",
+                    wxOK|wxCENTRE|wxICON_ERROR, $self->{tab});
+      warn $_;
+      my $dbh = $WXPOS::State::DBH;
+      $dbh->rollback;
+      $dbh->{autocommit} = 1;
+      
+    }
+}
+
 1;

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


------------------------------------------------------------------------------
Shape the Mobile Experience: Free Subscription
Software experts and developers: Be at the forefront of tech innovation.
Intel(R) Software Adrenaline delivers strategic insight and game-changing 
conversations that shape the rapidly evolving mobile landscape. Sign up now. 
http://pubads.g.doubleclick.net/gampad/clk?id=63431311&iu=/4140/ostg.clktrk
_______________________________________________
Ledger-smb-commits mailing list
..hidden..
https://lists.sourceforge.net/lists/listinfo/ledger-smb-commits