[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
SF.net SVN: ledger-smb:[6777] trunk
- Subject: SF.net SVN: ledger-smb:[6777] trunk
- From: ..hidden..
- Date: Thu, 6 Feb 2014 06:20:16 +0000
Revision: 6777
http://sourceforge.net/p/ledger-smb/code/6777
Author: einhverfr
Date: 2014-02-06 06:20:14 +0000 (Thu, 06 Feb 2014)
Log Message:
-----------
More fixes for inventory adjustment approval
Modified Paths:
--------------
trunk/LedgerSMB/Report/Inventory/Adj_Details.pm
trunk/LedgerSMB/Scripts/inv_reports.pm
trunk/sql/modules/Inventory_Report.sql
Modified: trunk/LedgerSMB/Report/Inventory/Adj_Details.pm
===================================================================
--- trunk/LedgerSMB/Report/Inventory/Adj_Details.pm 2014-02-06 05:09:50 UTC (rev 6776)
+++ trunk/LedgerSMB/Report/Inventory/Adj_Details.pm 2014-02-06 06:20:14 UTC (rev 6777)
@@ -15,11 +15,17 @@
use Moose;
use LedgerSMB::Report::Inventory::Search_Adj;
extends 'LedgerSMB::Report';
+use LedgerSMB::Form;
+use LedgerSMB::IS;
+use LedgerSMB::IR;
+use LedgerSMB::App_State;
=head1 DESCRIPTION
This report shows the details of an inventory adjustment report.
+THIS IS NOT SAFE TO CACHE UNTIL THE FINANCIAL LOGIC IS IN THE NEW FRAMEWORK.
+
=head1 CRITERIA PROPERTIES
=over
@@ -134,6 +140,77 @@
$self->rows(\@rows);
}
+=head2 approve
+
+Approves the report. This currently goes through the legacy code and is the
+point where caching becomes unsafe.
+
+=cut
+
+sub approve {
+ my ($self) = @_;
+ my $form_ar = bless({rowcount => 1}, 'Form');
+ my $form_ap = bless({rowcount => 1}, 'Form');
+
+ ## Setting up forms
+ #
+ # ar
+ $form_ar->{dbh} = LedgerSMB::App_State::DBH;
+ $form_ar->{customer} = 'Inventory';
+ AA->get_name( {}, $form_ar );
+
+
+ # ap
+ $form_ap->{dbh} = LedgerSMB::App_State::DBH;
+ $form_ap->{vendor} = 'Inventory';
+ AA->get_name( {}, $form_ar );
+
+
+ ## Processing reports
+ $self->run_report;
+ my @rows = @{$self->rows};
+ for my $row (@rows){
+ next if $row->{variance} == 0;
+ if ($row->{variance} < 0){
+ my $form = $form_ar;
+ my $rc = $form->{rowcount};
+ $form->{"qty_$rc"} = -1 * $row->{variance};
+ $form->{"id_$rc"} = $row->{parts_id};
+ $form->{"description_$rc"} = $row->{description};
+ $form->{"discount_$rc"} = '100';
+ $form->{"sellprice_$rc"} = $row->{sellprice};
+ ++$form->{rowcount};
+ } elsif ($row->{variance} > 0){
+ my $form = $form_ap;
+ my $rc = $form->{rowcount};
+ $form->{"qty_$rc"} = $row->{variance};
+ $form->{"id_$rc"} = $row->{parts_id};
+ $form->{"description_$rc"} = $row->{description};
+ $form->{"discount_$rc"} = '100';
+ $form->{"sellprice_$rc"} = $row->{lastcost};
+ ++$form->{rowcount};
+
+ }
+ }
+ ## Posting
+ IS->post_invoice($form_ar);
+ IR->post_invoice($form_ap);
+ $self->call_procedure(procname => 'inventory_report__approve',
+ args => [$self->id, $form_ar->{id}, $form_ap->{ap}]
+ );
+}
+
+=head2 delete
+
+Deletes the inventory report
+
+=cut
+
+sub delete {
+ my ($self) = @_;
+ $self->exec_method(funcname => 'inventory_report__delete');
+}
+
=back
=head1 SEE ALSO
Modified: trunk/LedgerSMB/Scripts/inv_reports.pm
===================================================================
--- trunk/LedgerSMB/Scripts/inv_reports.pm 2014-02-06 05:09:50 UTC (rev 6776)
+++ trunk/LedgerSMB/Scripts/inv_reports.pm 2014-02-06 06:20:14 UTC (rev 6777)
@@ -39,11 +39,40 @@
sub adj_detail {
my ($request) = @_;
+ $request->{hiddens} = { id => $request->{id}};
my $rpt = LedgerSMB::Report::Inventory::Adj_Details->new(%$request);
$rpt->run_report;
$rpt->render($request);
}
+=item approve
+
+Approves the inventory report and enters invoices against them.
+
+=cut
+
+sub approve {
+ my ($request) = @_;
+ my $rpt = LedgerSMB::Report::Inventory::Adj_Details->new(%$request);
+ $rpt->approve;
+ $request->{report_name} = 'inventory_adj';
+ LedgerSMB::Scripts::reports::start_report($request);
+}
+
+=item delete
+
+Deletes the inventory report
+
+=cut
+
+sub delete {
+ my ($request) = @_;
+ my $rpt = LedgerSMB::Report::Inventory::Adj_Details->new(%$request);
+ $rpt->delete;
+ $request->{report_name} = 'inventory_adj';
+ LedgerSMB::Scripts::reports::start_report($request);
+}
+
=back
=head1 COPYRIGHT
Modified: trunk/sql/modules/Inventory_Report.sql
===================================================================
--- trunk/sql/modules/Inventory_Report.sql 2014-02-06 05:09:50 UTC (rev 6776)
+++ trunk/sql/modules/Inventory_Report.sql 2014-02-06 06:20:14 UTC (rev 6777)
@@ -8,9 +8,20 @@
description text,
counted numeric,
expected numeric,
- variance numeric
+ variance numeric,
+ sellprice numeric,
+ lastcost numeric
);
+CREATE OR REPLACE FUNCTION inventory_report__approve
+(in_id int, in_ar_trans_id int, in_ap_trans_id int)
+RETURNS int LANGUAGE SQL AS
+$$
+update inventory_report
+ SET ar_trans_id = $2, ap_trans_id = $3
+ WHERE id = $1 AND ar_trans_id IS NULL AND ap_trans_id IS NULL
+RETURNING id;
+$$;
DROP TYPE IF EXISTS inventory_adjustment_info CASCADE;
@@ -63,7 +74,7 @@
$$
SELECT l.parts_id, p.partnumber, p.description, l.counted, l.expected,
- l.counted - l.expected
+ l.counted - l.expected, p.sellprice, p.lastcost
FROM inventory_report_line l
JOIN parts p ON l.parts_id = p.id
WHERE l.adjust_id = $1;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
------------------------------------------------------------------------------
Managing the Performance of Cloud-Based Applications
Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
Read the Whitepaper.
http://pubads.g.doubleclick.net/gampad/clk?id=121051231&iu=/4140/ostg.clktrk
_______________________________________________
Ledger-smb-commits mailing list
..hidden..
https://lists.sourceforge.net/lists/listinfo/ledger-smb-commits