[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
SF.net SVN: ledger-smb:[6227] trunk
- Subject: SF.net SVN: ledger-smb:[6227] trunk
- From: ..hidden..
- Date: Wed, 6 Nov 2013 10:23:59 +0000
Revision: 6227
http://sourceforge.net/p/ledger-smb/code/6227
Author: einhverfr
Date: 2013-11-06 10:23:58 +0000 (Wed, 06 Nov 2013)
Log Message:
-----------
Single entry timecard save now works
Modified Paths:
--------------
trunk/LedgerSMB/Scripts/timecard.pm
trunk/LedgerSMB/Timecard.pm
trunk/sql/modules/Fixes.sql
trunk/sql/modules/Inventory.sql
trunk/sql/modules/Timecards.sql
Modified: trunk/LedgerSMB/Scripts/timecard.pm
===================================================================
--- trunk/LedgerSMB/Scripts/timecard.pm 2013-11-06 07:53:43 UTC (rev 6226)
+++ trunk/LedgerSMB/Scripts/timecard.pm 2013-11-06 10:23:58 UTC (rev 6227)
@@ -131,6 +131,11 @@
sub save {
my ($request) = @_;
+ $request->{parts_id} = LedgerSMB::Timecard->get_part_id(
+ $request->{partnumber}
+ );
+ $request->{jctype} ||= 1;
+ $request->{total} = $request->{qty} + $request{non_chargeable};
my $timecard = LedgerSMB::Timecard->new(%$request);
$timecard->save;
$request->{id} = $timecard->id;
Modified: trunk/LedgerSMB/Timecard.pm
===================================================================
--- trunk/LedgerSMB/Timecard.pm 2013-11-06 07:53:43 UTC (rev 6226)
+++ trunk/LedgerSMB/Timecard.pm 2013-11-06 10:23:58 UTC (rev 6227)
@@ -156,7 +156,7 @@
=cut
-has total => (is => 'ro', isa => 'LedgerSMB::Moose::Number', required => 1,
+has total => (is => 'ro', isa => 'LedgerSMB::Moose::Number', required => 0,
coerce => 1);
=item non_billable numeric
@@ -199,6 +199,21 @@
return $retval;
}
+=item get_part_id($partnumber)
+
+Returns the part id for the given partnumber
+
+=cut
+
+sub get_part_id {
+ my ($self, $partnumber) = @_;
+ my ($ref) = __PACKAGE__->call_procedure(
+ procname => 'inventory__get_item_by_partnumber',
+ args => [$partnumber]
+ );
+ return $ref->{id};
+}
+
=item save()
Saves the current timecard to the database, sets id.
Modified: trunk/sql/modules/Fixes.sql
===================================================================
--- trunk/sql/modules/Fixes.sql 2013-11-06 07:53:43 UTC (rev 6226)
+++ trunk/sql/modules/Fixes.sql 2013-11-06 10:23:58 UTC (rev 6227)
@@ -245,3 +245,11 @@
COMMIT;
+
+BEGIN;
+
+ALTER TABLE jcitems DROP CONSTRAINT "jcitems_person_id_fkey";
+ALTER TABLE jcitems ADD FOREIGN KEY (person_id) REFERENCES entity(id);
+
+COMMIT;
+
Modified: trunk/sql/modules/Inventory.sql
===================================================================
--- trunk/sql/modules/Inventory.sql 2013-11-06 07:53:43 UTC (rev 6226)
+++ trunk/sql/modules/Inventory.sql 2013-11-06 10:23:58 UTC (rev 6227)
@@ -1,3 +1,5 @@
+BEGIN;
+
CREATE OR REPLACE FUNCTION inventory_get_item_at_day
(in_transdate date, in_partnumber text)
RETURNS parts AS
@@ -82,3 +84,17 @@
RETURN currval('inventory_report_line_id_seq');
end;
$$ LANGUAGE plpgsql;
+
+CREATE OR REPLACE FUNCTION inventory__get_item_by_partnumber(in_partnumber text)
+RETURNS parts LANGUAGE SQL AS
+$$
+SELECT * FROM parts WHERE obsolete is not true AND partnumber = $1;
+$$;
+
+CREATE OR REPLACE FUNCTION inventory__get_item_by_id(in_id int)
+RETURNS parts LANGUAGE SQL AS
+$$
+SELECT * FROM parts WHERE id = $1;
+$$;
+
+COMMIT;
Modified: trunk/sql/modules/Timecards.sql
===================================================================
--- trunk/sql/modules/Timecards.sql 2013-11-06 07:53:43 UTC (rev 6226)
+++ trunk/sql/modules/Timecards.sql 2013-11-06 10:23:58 UTC (rev 6227)
@@ -20,6 +20,7 @@
in_notes text,
in_total numeric,
in_non_billable numeric,
+ in_curr char(3),
in_jctype int
)
RETURNS jcitems LANGUAGE PLPGSQL AS
@@ -49,14 +50,14 @@
INSERT INTO jcitems
(business_unit_id, parts_id, description, qty, allocated, sellprice,
fxsellprice, serialnumber, checkedin, checkedout, person_id, notes,
- total, non_billable, jctype)
+ total, non_billable, jctype, curr)
VALUES
(in_business_unit_id, in_parts_id, in_description, in_qty, in_allocated,
in_sellprice, in_fxsellprice, in_serialnumber, in_checkedin, in_checkedout,
coalesce(in_person_id, person__get_my_entity_id()), in_notes, in_total,
- in_non_billable, in_jctype);
+ in_non_billable, in_jctype, in_curr);
-SELECT * INTO retval WHERE id = currval('jcitems_id_seq')::int;
+SELECT * INTO retval FROM jcitems WHERE id = currval('jcitems_id_seq')::int;
RETURN retval;
@@ -73,7 +74,7 @@
AND ($1 OR inventory_accno_id IS NULL)
AND ($2 OR (income_accno_id IS NOT NULL
AND inventory_accno_id IS NULL))
- AND ($3 IS NULL OF partnumber like $3 || '%')
+ AND ($3 IS NULL OR partnumber like $3 || '%')
ORDER BY partnumber;
$$;
@@ -118,7 +119,7 @@
j.checkedout::time as checkedout, j.checkedin::date as transdate,
extract('dow' from j.checkedin) as weekday,
extract('week' from j.checkedin) as workweek,
- date_trunc('week', j.checkedin) as weekstarting,
+ date_trunc('week', j.checkedin)::date as weekstarting,
p.partnumber, bu.control_code as business_unit_code,
bu.description AS businessunit_description,
ee.employeenumber, e.name AS employee, j.parts_id, j.sellprice
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