Speichern/Laden von Auftraegen und Buchen/Laden von Rechnungen modifiziert um diese Variablen zu halten.
# save detail record in invoice table
$query = qq|INSERT INTO invoice (trans_id, parts_id, description, qty,
sellprice, fxsellprice, discount, allocated, assemblyitem,
- unit, deliverydate, project_id, serialnumber, pricegroup_id)
+ unit, deliverydate, project_id, serialnumber, pricegroup_id,
+ ordnumber, transdate, cusordnumber)
VALUES ($form->{id}, $form->{"id_$i"},
'$form->{"description_$i"}', $form->{"qty_$i"},
$form->{"sellprice_$i"}, $fxsellprice,
$form->{"discount_$i"}, $allocated, 'f',
'$form->{"unit_$i"}', $deliverydate, (SELECT id from project where projectnumber = '$project_id'),
- '$form->{"serialnumber_$i"}',
- '$pricegroup_id')|;
+ '$form->{"serialnumber_$i"}', '$pricegroup_id',
+ '$form->{"ordnumber_$i"}', '$form->{"transdate_$i"}', '$form->{"cusordnumber_$i"}')|;
$dbh->do($query) || $form->dberror($query);
if ($form->{lizenzen}) {
i.discount, i.parts_id AS id, i.unit, i.deliverydate,
i.project_id, pr.projectnumber, i.serialnumber,
p.partnumber, p.assembly, p.bin, p.notes AS partnotes, i.id AS invoice_pos,
- pg.partsgroup, i.pricegroup_id, (SELECT pricegroup FROM pricegroup WHERE id=i.pricegroup_id) as pricegroup
+ pg.partsgroup, i.pricegroup_id, (SELECT pricegroup FROM pricegroup WHERE id=i.pricegroup_id) as pricegroup,
+ i.ordnumber, i.transdate, i.cusordnumber
FROM invoice i
JOIN parts p ON (i.parts_id = p.id)
LEFT JOIN project pr ON (i.project_id = pr.id)
$query = qq|INSERT INTO orderitems (|;
$query .= "id, " if $form->{"orderitems_id_$i"};
$query .= qq|trans_id, parts_id, description, qty, sellprice, discount,
- unit, reqdate, project_id, serialnumber, ship, pricegroup_id)
+ unit, reqdate, project_id, serialnumber, ship, pricegroup_id,
+ ordnumber, transdate, cusordnumber)
VALUES (|;
$query .= qq|$form->{"orderitems_id_$i"},|
if $form->{"orderitems_id_$i"};
'$form->{"description_$i"}', $form->{"qty_$i"},
$fxsellprice, $form->{"discount_$i"},
'$form->{"unit_$i"}', $reqdate, (SELECT id from project where projectnumber = '$project_id'),
- '$form->{"serialnumber_$i"}', $form->{"ship_$i"},
- '$pricegroup_id')|;
+ '$form->{"serialnumber_$i"}', $form->{"ship_$i"}, '$pricegroup_id',
+ '$form->{"ordnumber_$i"}', '$form->{"transdate_$i"}', '$form->{"cusordnumber_$i"}')|;
$dbh->do($query) || $form->dberror($query);
$form->{"sellprice_$i"} = $fxsellprice;
# connect to database
my $dbh = $form->dbconnect_noauto($myconfig);
- my $query;
+ my $query, @ids;
# translate the ids (given by id_# and trans_id_#) into one array of ids, so we can join them later
map { push @ids, $form->{"trans_id_$_"} if ($form->{"id_$_"}) } (1 .. $form->{"rowcount"});
c1.accno AS inventory_accno,
c2.accno AS income_accno,
c3.accno AS expense_accno,
- oe.ordnumber, oe.transdate, oe.cusordnumber,
+ oe.ordnumber AS ordnumber_oe, oe.transdate AS transdate_oe, oe.cusordnumber AS cusordnumber_oe,
p.partnumber, p.assembly, o.description, o.qty,
o.sellprice, o.parts_id AS id, o.unit, o.discount, p.bin, p.notes AS partnotes,
o.reqdate, o.project_id, o.serialnumber, o.ship,
+ o.ordnumber, o.transdate, o.cusordnumber,
pr.projectnumber,
pg.partsgroup, o.pricegroup_id, (SELECT pricegroup FROM pricegroup WHERE id=o.pricegroup_id) as pricegroup
FROM orderitems o
$sth->execute || $form->dberror($query);
while ($ref = $sth->fetchrow_hashref(NAME_lc)) {
+
+ # in collective order, copy global ordnumber, transdate, cusordnumber into item scope
+ # unless already present there
+ # remove _oe entries afterwards
+ map { $ref->{$_} = $ref->{"${_}_oe"} if ($ref->{$_} eq '') }
+ qw|ordnumber transdate cusordnumber| if (@ids);
+ map{ delete $ref->{$_} }
+ qw|ordnumber_oe transdate_oe cusordnumber_oe|;
#set expense_accno=inventory_accno if they are different => bilanz
$vendor_accno =
update invoice set fxsellprice=fxsellpriceold;
alter table invoice drop column fxsellpriceold;
--
+alter table invoice add column ordnumber text;
+alter table invoice add column transdate text;
+alter table invoice add column cusordnumber text;
+--
--TABLE oe
alter table oe rename column amount to amountold;
alter table oe add column amount numeric(15,5);
update orderitems set sellprice=sellpriceold;
alter table orderitems drop column sellpriceold;
--
+alter table orderitems add column ordnumber text;
+alter table orderitems add column transdate text;
+alter table orderitems add column cusordnumber text;
+--
--TABLE parts
alter table parts rename column listprice to listpriceold;
alter table parts add column listprice numeric(15,5);
"serialnumber" text,
"itime" timestamp DEFAULT now(),
"mtime" timestamp,
- "pricegroup_id" integer
+ "pricegroup_id" integer,
+ "ordnumber" text,
+ "transdate" text,
+ "cusordnumber" text
);
CREATE TABLE "vendor" (
"id" integer DEFAULT nextval('orderitemsid'::text) PRIMARY KEY,
"itime" timestamp DEFAULT now(),
"mtime" timestamp,
- "pricegroup_id" integer
+ "pricegroup_id" integer,
+ "ordnumber" text,
+ "transdate" text,
+ "cusordnumber" text
);
CREATE TABLE "exchangerate" (