summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authoreinhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46>2007-12-29 02:17:13 +0000
committereinhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46>2007-12-29 02:17:13 +0000
commitca962db7ea7be04e01249ace4cf2cc036dbe23b2 (patch)
treee5f88022243ee3b6f83458f7b1c1f431eb8b88f7 /scripts
parentae08355c14b1d079b9f65d57aa937e9ed7bccdd6 (diff)
Adding basic outline of inventory adjustment mechanisms and screens. Objects and stored procs still to do.
git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk@2017 4979c152-3d1c-0410-bac9-87ea11338e46
Diffstat (limited to 'scripts')
-rw-r--r--scripts/inventory.pl120
1 files changed, 120 insertions, 0 deletions
diff --git a/scripts/inventory.pl b/scripts/inventory.pl
new file mode 100644
index 00000000..04f5388d
--- /dev/null
+++ b/scripts/inventory.pl
@@ -0,0 +1,120 @@
+=pod
+
+=head1 NAME
+
+LedgerSMB::Scripts::inventory - LedgerSMB class defining the Controller
+functions, template instantiation and rendering for inventory management.
+
+=head1 SYOPSIS
+
+This module is the UI controller for the customer DB access; it provides the
+View interface, as well as defines the Save customer.
+Save customer will update or create as needed.
+
+
+=head1 METHODS
+
+=cut
+
+package LedgerSMB::Scripts::customer;
+
+use LedgerSMB::Template;
+use LedgerSMB::DBObject::Customer;
+
+require 'lsmb-request.pl';
+
+=over
+
+=item begin_adjust
+
+This entry point specifies the screen for setting up an inventory adjustment.
+
+=back
+
+=cut
+
+sub begin_adjust {
+ my ($request) = @_;
+ my $template = LedgerSMB::Template->new(
+ user => $request->{_user},
+ template => 'adjustment_setup',
+ locale => $request->{_locale},
+ path => 'UI/inventory',
+ format => 'HTML'
+ );
+ $template->render($request);
+}
+
+=over
+
+=item enter_adjust
+
+This entry point specifies the screen for entering an inventory adjustment.
+
+=back
+
+=cut
+
+sub enter_adjust {
+ my ($request) = @_;
+ my $adjustment = LedgerSMB::DBObject::Inventory->new(base => $request);
+ my $template = LedgerSMB::Template->new(
+ user => $request->{_user},
+ template => 'adjustment_entry',
+ locale => $request->{_locale},
+ path => 'UI/inventory',
+ format => 'HTML'
+ );
+ $template->render($adjustment);
+}
+
+
+=over
+
+=item adjustment_next
+
+This function is triggered on the next button on the adjustment entry screen.
+It retrieves inventory information, calculates adjustment values, and displays the
+screen.
+
+=back
+
+=cut
+
+sub adjustment_next {
+ my ($request) = @_;
+ my $adjustment = LedgerSMB::DBObject::Inventory->new(base => $request);
+ for my $i (1 .. $adjustment->{rowcount}){
+ if ($adjustment->{"row_$i"} eq "new"){
+ my $item = $adjustment->retrieve_item_at_date(
+ $adjustment->{"partnumber_new_$i"});
+ $adjustment->{"row_$i"} = $item->{id};
+ $adjustment->{"description_$i"} = $item->{description};
+ $adjustment->{"onhand_$i"} = $item->{onhand}};
+ }
+ $adjustment->{"qty_$i"} = $adjustment->{"onhand_$i"}
+ - $adjustment->{"counted_$i"};
+ }
+ ++$adjustment->{rowcount};
+ enter_adjust($adjustment);
+}
+
+=over
+
+=item adjustment_save
+
+This function saves the inventory adjustment report and then creates the required
+invoices.
+
+=back
+
+=cut
+
+sub adjustment_save {
+ my ($request) = @_;
+ my $adjustment = LedgerSMB::DBObject::Inventory->new(base => $request);
+ $adjustment->save;
+ begin_adjust($request);
+}
+
+1;