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

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



Revision: 6271
          http://sourceforge.net/p/ledger-smb/code/6271
Author:   einhverfr
Date:     2013-11-09 08:25:46 +0000 (Sat, 09 Nov 2013)
Log Message:
-----------
Closer to posting invoices

Modified Paths:
--------------
    addons/1.3/wxPOS/WXPOS/Invoice.pm
    addons/1.3/wxPOS/WXPOS/UI/AR/Pay.pm
    addons/1.3/wxPOS/WXPOS/UI/AR.pm

Modified: addons/1.3/wxPOS/WXPOS/Invoice.pm
===================================================================
--- addons/1.3/wxPOS/WXPOS/Invoice.pm	2013-11-09 04:23:37 UTC (rev 6270)
+++ addons/1.3/wxPOS/WXPOS/Invoice.pm	2013-11-09 08:25:46 UTC (rev 6271)
@@ -60,7 +60,7 @@
 
 =cut
 
-has transdate => (is => 'ro', default => 'today');
+has transdate => (is => 'ro', default => sub { return 'today'} );
 
 =head2 amount
 
@@ -92,7 +92,7 @@
 
 =cut
 
-has invoice => (is => 'ro', default => 1);
+has invoice => (is => 'ro', default => sub { return 1} );
 
 =head2 curr
 
@@ -108,7 +108,7 @@
 
 =cut
 
-has entity_credit_account => (is => 'ro', default => 1);
+has entity_credit_account => (is => 'ro', default => sub { return 1} );
 
 =head2 payments
 
@@ -154,6 +154,7 @@
 
 sub _isa_invoice_lines {
     my ($lines) = @_;
+    croak "No invoice lines" unless @$lines;
     foreach my $line (@$lines){
         for my $key (qw(partnumber qty sellprice)){
             croak "Invoice line missing key $key" unless $line->{$key};
@@ -206,7 +207,7 @@
         $arghash{$key} = $amts->{$key};
     }
     $arghash{payments} = $widget->get_payments;
-    $arghash{invoice_lines} = $wisget->get_lines;
+    $arghash{invoice_lines} = $widget->get_lines;
     return __PACKAGE__->new(%arghash);
 }
 

Modified: addons/1.3/wxPOS/WXPOS/UI/AR/Pay.pm
===================================================================
--- addons/1.3/wxPOS/WXPOS/UI/AR/Pay.pm	2013-11-09 04:23:37 UTC (rev 6270)
+++ addons/1.3/wxPOS/WXPOS/UI/AR/Pay.pm	2013-11-09 08:25:46 UTC (rev 6271)
@@ -6,6 +6,7 @@
 use base qw(Wx::Dialog);
 use Wx::Event qw(EVT_BUTTON EVT_LIST_ITEM_SELECTED EVT_LIST_ITEM_DESELECTED);
 use WXPOS::Sysconfig;
+use WXPOS::Invoice;
 
 sub new{
     my ($class, $parent) = @_;
@@ -129,12 +130,65 @@
 }
 
 sub _Post {
+    my ($self) = @_;
+    my $invoice = WXPOS::Invoice->from_UI($self, 2);
+    $invoice->post;
+    $invoice->print(); # TODO
 }
 
-sub _Serialize {
+sub get_entity_credit_account {
+    my ($self) = @_;
+    return $self->{parent_window}->{customer_list}->GetValue();
 }
 
-sub _SerializeParent {
+sub get_amounts {
+    my ($self) = @_;
+    my $amounts = {};
+    $amounts->{paid} = $self->{total_paid}->GetLabel();
+    $amounts->{netamount} = $self->{parent_window}->{net_total}->GetLabel();
+    $amounts->{total} = $self->{total}->GetLabel();
+    return $amounts;
 }
 
+sub get_lines {
+    my ($self) = @_;
+    my $lines = [];
+    my $list = $self->{parent_window}->list;
+    my $item = -1;
+
+    while ($item = $list->GetNextItem($item)){
+        my $line = {};
+        $line->{partnumber} = $list->GetItemData($item, 0)->GetText(); 
+        $line->{sellprice} = $list->GetItemData($item, 2)->GetText();
+        $line->{qty} =  $list->GetItemData($item, 6)->GetText();
+        push @$lines, @line;
+    }
+    return $lines; 
+}
+
+sub get_payments {
+    my ($self) = @_;
+    my $list = $self->{list};
+    my $item = -1;
+    my $payments = [];
+    while (($item = $list->GetNextItem($item)) > -1){
+       my $pmt = {};
+       $pmt->{amount} = $list->GetItemData($item, 0)->GetText();
+       $pmt->{memo} = $list->GetItemData($item, 1)->GetText();
+       $pmt->{source} = $list->GetItemData($item, 2)->GetText();
+       push @$payments, $pmt;
+    }
+
+    # Change
+    my $amounts = $self->get_amounts();
+    if ($amonts->{total} < $amounts->{paid}){
+        push @$payments, {
+           amount => $amonts->{total} - $amounts->{paid},
+           memo => 'cash',
+           source => 'change'
+        };
+    }   
+    return $payments;
+}
+
 1;

Modified: addons/1.3/wxPOS/WXPOS/UI/AR.pm
===================================================================
--- addons/1.3/wxPOS/WXPOS/UI/AR.pm	2013-11-09 04:23:37 UTC (rev 6270)
+++ addons/1.3/wxPOS/WXPOS/UI/AR.pm	2013-11-09 08:25:46 UTC (rev 6271)
@@ -1,8 +1,8 @@
 package WXPOS::UI::AR;
 
+use Wx qw(wxDefaultPosition wxDefaultSize wxLI_HORIZONTAL wxCB_READONLY wxICON_ERROR wxOK wxCENTRE wxLC_REPORT wxLIST_NEXT_ALL wxLIST_STATE_SELECTED wxLIST_STATE_DONTCARE wxLIST_NEXT_BELOW wxLC_VIRTUAL);
+use Wx::Event qw(EVT_BUTTON 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::Event qw(EVT_BUTTON EVT_LISTBOX_DCLICK EVT_COMBOBOX EVT_LIST_ITEM_RIGHT_CLICK EVT_LIST_ITEM_SELECTED EVT_LIST_ITEM_DESELECTED);
-use Wx qw(wxDefaultPosition wxDefaultSize wxLI_HORIZONTAL wxCB_READONLY wxICON_ERROR wxOK wxCENTRE wxLC_REPORT wxLIST_NEXT_ALL wxLIST_STATE_SELECTED wxLIST_STATE_DONTCARE wxLIST_NEXT_BELOW wxLC_VIRTUAL);
 use Wx::Grid;
 use WXPOS::Part;
 use WXPOS::Counterparty;
@@ -140,7 +140,7 @@
 }
 
 sub _listPartsByName {
- my($self, $event) = @_;
+ my ($self, $event) = @_;
  my $desc = $self->{desc}->GetValue();
  my $wh = $self->{sesion}->{defaults}->{wh};
  my $list;
@@ -239,7 +239,7 @@
 sub _delParts {
  my($self) = @_;
  if ($self->{list}->GetSelectedItemCount < 1) {
-  Wx::MessageBox("Please, try again selecting an item.", "Item not deleted!", wxOK|wxCENTRE|wxICON_ERROR, $self->{tab});
+  # Nothing to do, removing dialog since this is time-critical.
   return 0;
  }
  my $item = $self->{list}->GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);

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