[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
SF.net SVN: ledger-smb:[6299] addons/1.3/wxPOS/WXPOS
- Subject: SF.net SVN: ledger-smb:[6299] addons/1.3/wxPOS/WXPOS
- From: ..hidden..
- Date: Thu, 21 Nov 2013 10:35:36 +0000
Revision: 6299
http://sourceforge.net/p/ledger-smb/code/6299
Author: einhverfr
Date: 2013-11-21 10:35:35 +0000 (Thu, 21 Nov 2013)
Log Message:
-----------
Customers can now be saved, but it dumps core trying to create the invoice
Modified Paths:
--------------
addons/1.3/wxPOS/WXPOS/Counterparty.pm
addons/1.3/wxPOS/WXPOS/UI/AR.pm
addons/1.3/wxPOS/WXPOS/UI/Contact.pm
addons/1.3/wxPOS/WXPOS/UI.pm
Modified: addons/1.3/wxPOS/WXPOS/Counterparty.pm
===================================================================
--- addons/1.3/wxPOS/WXPOS/Counterparty.pm 2013-11-21 06:04:08 UTC (rev 6298)
+++ addons/1.3/wxPOS/WXPOS/Counterparty.pm 2013-11-21 10:35:35 UTC (rev 6299)
@@ -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/WXPOS/UI/AR.pm
===================================================================
--- addons/1.3/wxPOS/WXPOS/UI/AR.pm 2013-11-21 06:04:08 UTC (rev 6298)
+++ addons/1.3/wxPOS/WXPOS/UI/AR.pm 2013-11-21 10:35:35 UTC (rev 6299)
@@ -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::Sysconfig::Args->{name}){
+ $dft_custom = $WXPOS::Sysconfig::Args->{name};
+ delete $WXPOS::Sysconfig::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/WXPOS/UI/Contact.pm
===================================================================
--- addons/1.3/wxPOS/WXPOS/UI/Contact.pm 2013-11-21 06:04:08 UTC (rev 6298)
+++ addons/1.3/wxPOS/WXPOS/UI/Contact.pm 2013-11-21 10:35:35 UTC (rev 6299)
@@ -1,25 +1,27 @@
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::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,66 +29,64 @@
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 {
@@ -104,6 +104,16 @@
}
}
+sub Customer {
+ my ($self) = @_;
+ return $self->Contact(2);
+}
+
+sub Vendor {
+ my ($self) = @_;
+ return $self->Contact(1);
+}
+
sub _save {
my ($self) = @_;
my %args = ();
Modified: addons/1.3/wxPOS/WXPOS/UI.pm
===================================================================
--- addons/1.3/wxPOS/WXPOS/UI.pm 2013-11-21 06:04:08 UTC (rev 6298)
+++ addons/1.3/wxPOS/WXPOS/UI.pm 2013-11-21 10:35:35 UTC (rev 6299)
@@ -95,7 +95,7 @@
$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)});
+ EVT_MENU($self, $AR_CUSTOMER, sub{$self->_load_module(Contact, Customer)});
$bar->Append($ar, "&Sales" );
# my $ic = Wx::Menu->new;
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