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

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



Revision: 6302
          http://sourceforge.net/p/ledger-smb/code/6302
Author:   einhverfr
Date:     2013-11-21 11:38:29 +0000 (Thu, 21 Nov 2013)
Log Message:
-----------
Merging from wxPOS full branch, 6298:6301

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

Modified: addons/1.3/wxPOS-simple/WXPOS/Counterparty.pm
===================================================================
--- addons/1.3/wxPOS-simple/WXPOS/Counterparty.pm	2013-11-21 11:04:56 UTC (rev 6301)
+++ addons/1.3/wxPOS-simple/WXPOS/Counterparty.pm	2013-11-21 11:38:29 UTC (rev 6302)
@@ -17,6 +17,7 @@
 =cut
 
 package WXPOS::Counterparty;
+use WXPOS::Sysconfig;
 use Moo;
 with 'WXPOS::PGObject';
 
@@ -60,8 +61,7 @@
 
 =cut
 
-has id => (is => 'ro', required => 1); 
-    # required will change to 0 if we support saving counterparties
+has id => (is => 'ro', required => 0); 
 
 has name => (is => 'ro', required => 1);
 
@@ -117,23 +117,52 @@
 
 sub save {
     my ($self) = @_;
+    my $dbh = $self->_get_dbh;
+    $dbh->{AutoCommit} = 0;
+
+    my ($ref) = $self->call_dbmethod(funcname => 'increment',
+                                       funcprefix => 'setting_',
+                             args => { key => 'entity_control' }
+    );
+    my ($control_code) = values %$ref;
+    ($ref) = $self->call_dbmethod(funcname => 'get', funcprefix => 'setting_',
+                                    args => {key => 'default_country' });
     # Save customer info
-    my ($company) = $self->call_dbmethod(funcname => 'company__save', 
-                             args => {legal_name => $self->name}
+    my ($company) = $self->call_dbmethod(funcname => 'save', 
+                                       funcprefix => 'company_',
+                             args => {legal_name => $self->name,
+                                      control_code => $control_code,
+                                      country_id  => $ref->{value}},
     );
+    my ($entity_id) = values %$company;
+    my ($ar_acc) = $self->call_dbmethod(
+              funcname => 'get_from_accno',
+            funcprefix => 'account__',
+        args => {accno => $WXPOS::Sysconfig::accounts->{ar} }
+    );
     my ($eca) = $self->call_dbmethod(funcname => 'entity_credit_save',
-                                         args => $company);
+                                       funcprefix => '',
+                                         args => { entity_id => $entity_id,
+                                              ar_ap_account_id => $ar_acc->{id}},
+    );
+    my ($eca_id) = values %$eca;
     # Save contact info
+    #
+   
     $self->call_dbmethod(funcname => 'eca__save_contact',
-                             args => {credit_id => $eca->{id},
+                                       funcprefix => '',
+                             args => {credit_id => $eca_id,
                                   contact_class => 1,
                                         contact => $self->phone,
                                      } ) if $self->phone;
     $self->call_dbmethod(funcname => 'eca__save_contact',
-                             args => {credit_id => $eca->{id},
+                                       funcprefix => '',
+                             args => {credit_id => $eca_id,
                                   contact_class => 12,
                                         contact => $self->email,
                                      } ) if $self->email;
+    $dbh->commit;
+    $dbh->{AutoCommit} = 1;
 }
 
 =head1 COPYRIGHT

Modified: addons/1.3/wxPOS-simple/WXPOS/Invoice.pm
===================================================================
--- addons/1.3/wxPOS-simple/WXPOS/Invoice.pm	2013-11-21 11:04:56 UTC (rev 6301)
+++ addons/1.3/wxPOS-simple/WXPOS/Invoice.pm	2013-11-21 11:38:29 UTC (rev 6302)
@@ -63,9 +63,9 @@
    } elsif ('2' eq $self->entity_class){
         $invseq = 'sinumber';
    }
-    my ($seq) = $self->call_procedure(funcname => 'setting_increment',
-                                    funcprefix => '',
-                                          args => [$invseq],
+    my ($seq) = $self->call_dbmethod(funcname => 'increment',
+                                    funcprefix => 'setting_',
+                                          args => {key => $invseq},
     );
     my ($val) = values %$seq;
     return $val;

Modified: addons/1.3/wxPOS-simple/WXPOS/UI/AP.pm
===================================================================
--- addons/1.3/wxPOS-simple/WXPOS/UI/AP.pm	2013-11-21 11:04:56 UTC (rev 6301)
+++ addons/1.3/wxPOS-simple/WXPOS/UI/AP.pm	2013-11-21 11:38:29 UTC (rev 6302)
@@ -26,7 +26,7 @@
 ####### Invoice Screen
 my $pnumidx = {};
 my $pdescidx = {};
-sub Invoice {
+sub Purchase {
  my ($self) = @_;
 
  my $plist = WXPOS::Part->get_autocomplete_list;

Modified: addons/1.3/wxPOS-simple/WXPOS/UI/AR.pm
===================================================================
--- addons/1.3/wxPOS-simple/WXPOS/UI/AR.pm	2013-11-21 11:04:56 UTC (rev 6301)
+++ addons/1.3/wxPOS-simple/WXPOS/UI/AR.pm	2013-11-21 11:38:29 UTC (rev 6302)
@@ -6,6 +6,7 @@
 use Wx::Grid;
 use WXPOS::Part;
 use WXPOS::Counterparty;
+use WXPOS::State;
 use lib 'scripts';
 use WXPOS::UI::AR::Pay;
 #use WXPOS::UI::Controls::InvoiceEntry; # Not working on wxwidgets 2.8
@@ -50,6 +51,10 @@
 
 ### Customer
  my $dft_custom = $self->{sesion}->{defaults}->{custom} || '';
+ if ($WXPOS::State::Args->{name}){
+    $dft_custom = $WXPOS::State::Args->{name};
+    delete $WXPOS::State::Args->{name};
+ }
  $dft_custom ||= $WXPOS::Sysconfig::default_customer;
  Wx::StaticLine->new($self->{tab}, -1, [0, 0], [800, 2], wxLI_HORIZONTAL);
  Wx::StaticText->new($self->{tab}, -1, 'Customer', [10, 10], [90, 24]);

Modified: addons/1.3/wxPOS-simple/WXPOS/UI/Contact.pm
===================================================================
--- addons/1.3/wxPOS-simple/WXPOS/UI/Contact.pm	2013-11-21 11:04:56 UTC (rev 6301)
+++ addons/1.3/wxPOS-simple/WXPOS/UI/Contact.pm	2013-11-21 11:38:29 UTC (rev 6302)
@@ -1,25 +1,28 @@
 package WXPOS::UI::Contact;
-use Wx qw(:frame :textctrl :sizer :panel :window :id);
+use Wx qw(:frame :textctrl :sizer :panel :window :id 
+         wxDefaultSize wxDefaultPosition);
 use Wx::Event qw(EVT_BUTTON EVT_TEXT EVT_LISTBOX_DCLICK EVT_COMBOBOX EVT_LIST_ITEM_RIGHT_CLICK EVT_LIST_ITEM_SELECTED EVT_LIST_ITEM_DESELECTED);
 use base qw(Wx::Frame);
 use Wx::Grid;
-use WXPOS::AR;
-use WXPOS::AP;
+use WXPOS::State;
+use WXPOS::UI::AR;
+use WXPOS::UI::AP;
 use WXPOS::Counterparty;
 use lib 'scripts';
 
 sub new {
-    my ($class, $sesion, $action, $entity_class) = @_;
+    my ($class, $sesion, $action) = @_;
     my $self = {};
     $self->{sesion} = $sesion;
     bless $self, $class;
-    return $self->$action($entity_class);
+    return $self->$action();
 }
 
 # New Customer/Vendor Screen
 sub Contact {
-    my ($self, $entity_class);
-    $self->{entity_class} = $self->{entity_class};
+    my ($self, $entity_class) = @_;
+    $self->{entity_class} = $entity_class;
+    $self->{tab} = Wx::Panel->new($WXPOS::State::Notebook, -1, wxDefaultPosition, wxDefaultSize);
     # Close button
     my $close_btn = Wx::Button->new($self->{tab}, -1, '[X]', 
                            [750, 3], [30, 24]
@@ -27,88 +30,103 @@
     EVT_BUTTON($self->{tab}, $close_btn, sub{$self->_close_pane});
     # Main Sizer
     my $mainsizer = Wx::BoxSizer->new(wxHORIZONTAL);
-    $self->{mainpanel} = Wx::Panel->new(
-        $self->{tab}, -1, [-1,-1], [-1,-1],
-        wxTAB_TRAVERSAL|wxBORDER_NONE
-    );
+    my $panel = $self->{tab};
     # Customer/Contact Sizer
     my $contactsizer = Wx::BoxSizer->new(wxVERTICAL);
      # Name
     my $namerowsizer = Wx::BoxSizer->new(wxHORIZONTAL);
-    my $name_lbl = Wx::StaticText->new($self->{tab}, -1, "Name:", 
-                         [-1, -1], [200, 2]);
-    $namerowsizer->Add($name_lbl, 1, wxEXPAND | wxALIGH_RIGHT, 0);
+    my $name_lbl = Wx::StaticText->new($panel, -1, "Name:", 
+                         [-1, -1], [50, 2]);
+    $namerowsizer->Add($name_lbl, 0, wxEXPAND | wxALIGN_RIGHT, 0);
 
     $self->{name} = Wx::TextCtrl->new(
         $panel, -1, '',
-        [-1,-1],[300,60],
-        wxTE_MULTILINE
+        [-1,-1],[300,20],
     );
-    $namerowsizer->Add($self->{name}, 1, wxEXPAND | wxALIGH_LEFT, 0);
-    $contactsizer->add($namerowsizer, 0, wxALIGN_LEFT); 
+    $namerowsizer->Add($self->{name}, 0, wxEXPAND | wxALIGN_LEFT, 0);
+    $contactsizer->Add($namerowsizer, 0, wxALIGN_LEFT); 
      # Phone Number
     my $telrowsizer = Wx::BoxSizer->new(wxHORIZONTAL);
-    my $tel_lbl = Wx::StaticText->new($self->{tab}, -1, "Tel:", 
-                         [-1, -1], [200, 2]);
-    $telrowsizer->Add($tel_lbl, 1, wxEXPAND | wxALIGH_RIGHT, 0);
+    my $tel_lbl = Wx::StaticText->new($panel, -1, "Tel:", 
+                         [-1, -1], [50, 2]);
+    $telrowsizer->Add($tel_lbl, 0, wxEXPAND | wxALIGN_RIGHT, 0);
 
     $self->{tel} = Wx::TextCtrl->new(
         $panel, -1, '',
-        [-1,-1],[300,60],
-        wxTE_MULTILINE
+        [-1,-1],[300,20],
     );
-    $namerowsizer->Add($self->{tel}, 1, wxEXPAND | wxALIGH_LEFT, 0);
-    $contactsizer->add($telrowsizer, 0, wxALIGN_LEFT); 
+    $telrowsizer->Add($self->{tel}, 1, wxALIGN_LEFT, 0);
+    $contactsizer->Add($telrowsizer, 0, wxALIGN_LEFT); 
 
      # Email
     my $emailrowsizer = Wx::BoxSizer->new(wxHORIZONTAL);
-    my $email_lbl = Wx::StaticText->new($self->{tab}, -1, "Email:", 
-                         [-1, -1], [200, 2]);
-    $emailrowsizer->Add($email_lbl, 1, wxEXPAND | wxALIGH_RIGHT, 0);
+    my $email_lbl = Wx::StaticText->new($panel, -1, "Email:", 
+                         [-1, -1], [50, 2]);
+    $emailrowsizer->Add($email_lbl, 0,  wxEXPAND | wxALIGN_RIGHT, 0);
 
     $self->{email} = Wx::TextCtrl->new(
         $panel, -1, '',
-        [-1,-1],[300,60],
-        wxTE_MULTILINE
+        [-1,-1],[300,20],
     );
-    $emailrowsizer->Add($self->{email}, 1, wxEXPAND | wxALIGH_LEFT, 0);
-    $contactsizer->add($emailrowsizer, 0, wxALIGN_LEFT); 
+    $emailrowsizer->Add($self->{email}, 1, wxALIGN_LEFT, 0);
+    $contactsizer->Add($emailrowsizer, 0, wxALIGN_LEFT); 
 
-    $mainsizer->Add($contactsizer, 0, wx_ALIGN_CENTER);
+    $spacer = Wx::BoxSizer->new(wxHORIZONTAL);
+    my $btnsizer = Wx::BoxSizer->new(wxHORIZONTAL);
+    my $save_btn = Wx::Button->new($self->{tab}, -1, 'Invoice', 
+                                                       [-1, -1], [100, 24]);
+    $btnsizer->Add($save_btn, 0, wxEXPAND | wxALIGN_LEFT);
+    $contactsizer->Add($btnsizer, 1, wxALIGN_CENTER);
+    EVT_BUTTON($self->{tab}, $save_btn, sub{$self->_add_invoice});
+    
+    $mainsizer->Add($contactsizer, 0, wxALIGN_TOP);
+    $panel->SetSizer($mainsizer);
+    
     # Address Sizer
     # TODO
      # Address lines (3)
      # City State Zip
     # Button row
-    my $close_btn = Wx::Button->new($self->{tab}, -1, '[X]', 
-                                                       [750, 3], [30, 24]);
-    EVT_BUTTON($self->{tab}, $close_btn, sub{$self->_close_pane});
-
-    my $save_btn = Wx::Button->new($self->{tab}, -1, 'Invoice', 
-    EVT_BUTTON($self->{tab}, $save_btn, sub{$self->_add_invoice});
-                                                       [700, 550], [30, 24]);
+    return $panel;
 }
 
 sub _add_invoice {
     my ($self) = @_;
     $self->_save;
+    print STDERR "Saved \n";
     $self->_close_pane;
+    print STDERR "Closed Pane \n";
     my $nb = $WXPOS::State::Notebook;
-    $WXPOS::State::Args = {name => $self->{name}->GetValue};
+    $WXPOS::State::Args = {name => $self->{name_value} };
+    print STDERR "Set Args.  nb = $nb, WXPOS::State::Args->{name} = $WXPOS::State::Args->{name} \n";
     if ($self->{entity_class} == 2){
-        $nb->AddPage(WXPOS::UI::AR->new($self->{parent_window}->{sesion},
-                                        'Invoice'), 'Invoice', 1);
+        my $tab = WXPOS::UI::AR->new($self->{sesion},
+                                        'Invoice');
+        print STDERR "Set Tab\n";
+        $nb->AddPage($tab, 'Invoice', 1);
     } else {
-        $nb->AddPage(WXPOS::UI::AP->new($self->{parent_window}->{sesion},
-                                        'Invoice'), 'Invoice', 1);
+        $nb->AddPage(WXPOS::UI::AP->new($self->{sesion},
+                                        'Invoice'), 'Purchase', 1);
     }
+    print STDERR "Done\n";
 }
 
+sub Customer {
+    my ($self) = @_;
+    return $self->Contact(2);
+}
+
+sub Vendor {
+    my ($self) = @_;
+    return $self->Contact(1);
+}
+
 sub _save {
     my ($self) = @_;
     my %args = ();
     $args{entity_class} = $self->{entity_class};
     $args{name} = $self->{name}->GetValue;
+    $self->{name_value} = $args{name};
     $args{phone} = $self->{tel}->GetValue;
     $args{email} = $self->{email}->GetValue;
     my $contact = WXPOS::Counterparty->new(%args);

Modified: addons/1.3/wxPOS-simple/WXPOS/UI.pm
===================================================================
--- addons/1.3/wxPOS-simple/WXPOS/UI.pm	2013-11-21 11:04:56 UTC (rev 6301)
+++ addons/1.3/wxPOS-simple/WXPOS/UI.pm	2013-11-21 11:38:29 UTC (rev 6302)
@@ -95,17 +95,17 @@
  $ar->Append($AR_INVOICE, "&Invoice");
  EVT_MENU($self, $AR_INVOICE, sub{$self->_load_module(AR, Invoice)});
  $ar->Append($AR_CUSTOMER, "&Customer");
- EVT_MENU($self, $AR_CUSTOMER, sub{$self->_load_module(AR, Customer)});
- $bar->Append($ar, "&AR" );
+ EVT_MENU($self, $AR_CUSTOMER, sub{$self->_load_module(Contact, Customer)});
+ $bar->Append($ar, "&Sales" );
 
 # my $ic = Wx::Menu->new;
 # $ic->Append($IC_PARTS, "&Parts");
 # EVT_MENU($self, $IC_PARTS, sub{$self->_load_module(IC, Parts)});
 # $bar->Append($ic, "&Inventory" );
  my $ap = Wx::Menu->new;
- $ap->Append($AP_INVOICE, "&Invoice");
- EVT_MENU($self, $AP_INVOICE, sub{$self->_load_module('AP', 'Invoice')}); 
- $bar->Append($ap, "&AP" );
+ $ap->Append($AP_INVOICE, "&Purchase");
+ EVT_MENU($self, $AP_INVOICE, sub{$self->_load_module('AP', 'Purchase')}); 
+ $bar->Append($ap, "&Purchases" );
 
  $self->SetMenuBar($bar);
  return $self;

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