From 85d1ba670ff03d85a156b1f3331f24a8af5b6834 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pongr=C3=A1cz=20Istv=C3=A1n?= Date: Fri, 20 Sep 2013 16:43:19 +0000 Subject: [PATCH] Patch for using Invoice Creation Date (crdate) for AP/AR invoices and AP/AR transactions. In Sales Invoice form this field is the current date and readonly. Also includes readonly auto generated invoice number to guarantee gapless serial invoice number. Here is the video how does it work: http://youtu.be/uthH1m9swdg git-svn-id: svn://svn.code.sf.net/p/ledger-smb/code/branches/1.3@6070 4979c152-3d1c-0410-bac9-87ea11338e46 --- LedgerSMB/AA.pm | 14 ++++++++------ LedgerSMB/Form.pm | 2 +- LedgerSMB/IR.pm | 8 +++++--- LedgerSMB/IS.pm | 7 ++++--- bin/aa.pl | 13 +++++++++++-- bin/arapprn.pl | 4 ++-- bin/is.pl | 4 ++-- 7 files changed, 33 insertions(+), 19 deletions(-) diff --git a/LedgerSMB/AA.pm b/LedgerSMB/AA.pm index 42e81cf8e2..3229ec76fb 100644 --- a/LedgerSMB/AA.pm +++ b/LedgerSMB/AA.pm @@ -383,6 +383,7 @@ sub post_transaction { intnotes = ?, department_id = ?, ponumber = ?, + crdate = ?, reverse = ? WHERE id = ? |; @@ -395,8 +396,8 @@ sub post_transaction { $datepaid, $invnetamount, $form->{currency}, $form->{notes}, $form->{intnotes}, $form->{department_id}, - $form->{ponumber}, $form->{reverse}, - $form->{id} + $form->{ponumber}, $form->{crdate}, + $form->{reverse}, $form->{id} ); $dbh->prepare($query)->execute(@queryargs) || $form->dberror($query); @@ -937,7 +938,7 @@ sub transactions { } else { #HV typo error a.ponumber $acc_trans_fields -> a.ponumber $acc_trans_flds $query = qq| - SELECT a.id, a.invnumber, a.ordnumber, a.transdate, + SELECT a.id, a.invnumber, a.ordnumber, a.transdate, a.crdate, a.duedate, a.netamount, a.amount::numeric(20,$p), a.amount::numeric(20,$p) - (sum(acs.amount::numeric(20,$p)) @@ -975,7 +976,7 @@ sub transactions { } } else { $query = qq| - SELECT a.id, a.invnumber, a.ordnumber, a.transdate, + SELECT a.id, a.invnumber, a.ordnumber, a.transdate, a.crdate, a.duedate, a.netamount, a.amount, (a.amount - pd.due) AS paid, a.invoice, a.datepaid, a.terms, a.notes, @@ -1015,7 +1016,7 @@ sub transactions { LEFT JOIN project ip ON (i.project_id = ip.id) LEFT JOIN project p ON ac.project_id = p.id |; $group_by = qq| - GROUP BY a.id, a.invnumber, a.ordnumber, a.transdate, + GROUP BY a.id, a.invnumber, a.ordnumber, a.transdate, a.duedate, a.netamount, a.amount, a.invoice, a.datepaid, a.terms, a.notes, a.shipvia, a.shippingpoint, ee.name , @@ -1030,7 +1031,8 @@ sub transactions { invnumber => 2, ordnumber => 3, transdate => 4, - duedate => 5, + crdate => 5, + duedate => 6, datepaid => 10, shipvia => 13, shippingpoint => 14, diff --git a/LedgerSMB/Form.pm b/LedgerSMB/Form.pm index ad970c9c7f..15dcd37ec4 100644 --- a/LedgerSMB/Form.pm +++ b/LedgerSMB/Form.pm @@ -2574,7 +2574,7 @@ sub create_links { a.person_id, e.name AS employee, c.language_code, a.ponumber, a.reverse, a.approved, ctf.default_reportable, - a.on_hold + a.on_hold, a.crdate FROM $arap a JOIN entity_credit_account c ON (a.entity_credit_account = c.id) diff --git a/LedgerSMB/IR.pm b/LedgerSMB/IR.pm index 61db273518..1eb5d2d149 100644 --- a/LedgerSMB/IR.pm +++ b/LedgerSMB/IR.pm @@ -848,7 +848,8 @@ sub post_invoice { curr = ?, department_id = ?, language_code = ?, - ponumber = ? + ponumber = ?, + crdate = ? WHERE id = ?|; $sth = $dbh->prepare($query); @@ -859,7 +860,8 @@ sub post_invoice { $form->{duedate}, $form->{shippingpoint}, $form->{shipvia}, $form->{taxincluded}, $form->{notes}, $form->{intnotes}, $form->{currency}, $form->{department_id}, - $form->{language_code}, $form->{ponumber}, $form->{id} + $form->{language_code}, $form->{ponumber}, + $form->{crdate}, $form->{id} ) || $form->dberror($query); # add shipto @@ -1224,7 +1226,7 @@ sub retrieve_invoice { SELECT a.invnumber, a.transdate, a.duedate, a.ordnumber, a.quonumber, a.paid, a.taxincluded, a.notes, a.intnotes, a.curr AS currency, - a.entity_credit_account as vendor_id, a.language_code, a.ponumber, + a.entity_credit_account as vendor_id, a.language_code, a.ponumber, a.crdate, a.on_hold, a.reverse FROM ap a WHERE id = ?|; diff --git a/LedgerSMB/IS.pm b/LedgerSMB/IS.pm index cb26ac8c72..2f888be759 100644 --- a/LedgerSMB/IS.pm +++ b/LedgerSMB/IS.pm @@ -1598,7 +1598,8 @@ sub post_invoice { person_id = ?, till = ?, language_code = ?, - ponumber = ? + ponumber = ?, + crdate = ? WHERE id = ? |; $sth = $dbh->prepare($query); @@ -1614,7 +1615,7 @@ sub post_invoice { $form->{currency}, $form->{department_id}, $form->{employee_id}, $form->{till}, $form->{language_code}, $form->{ponumber}, - $form->{id} + $form->{crdate}, $form->{id} ) || $form->dberror($query); # add shipto @@ -2092,7 +2093,7 @@ sub retrieve_invoice { a.duedate, a.taxincluded, a.curr AS currency, a.person_id, e.name AS employee, a.till, a.reverse, - a.language_code, a.ponumber, + a.language_code, a.ponumber, a.crdate, a.on_hold FROM ar a LEFT JOIN entity_employee em ON (em.entity_id = a.person_id) diff --git a/bin/aa.pl b/bin/aa.pl index 1672f545af..85f979bcf4 100644 --- a/bin/aa.pl +++ b/bin/aa.pl @@ -181,6 +181,7 @@ sub create_links { && $form->{type} eq 'invoice'); $duedate = $form->{duedate}; + $crdate = $form->{crdate}; $taxincluded = $form->{taxincluded}; $form->{formname} = "transaction"; @@ -208,6 +209,7 @@ sub create_links { $form->{currency} =~ s/ //g; $form->{duedate} = $duedate if $duedate; + $form->{crdate} = $crdate if $crdate; $form->{taxincluded} = $taxincluded if $form->{id}; $form->{notes} = $form->{intnotes} if !$form->{id}; @@ -1300,6 +1302,7 @@ sub post { # check if there is an invoice number, invoice and due date $form->isblank( "transdate", $locale->text('Invoice Date missing!') ); $form->isblank( "duedate", $locale->text('Due Date missing!') ); + $form->isblank( "crdate", $locale->text('Invoice Created Date missing!') ); $form->isblank( $form->{vc}, $label ); $closedto = $form->datetonum( \%myconfig, $form->{closedto} ); @@ -1696,6 +1699,8 @@ sub search { push @a, qq| | . $locale->text('Paid'); + push @a, qq| | + . $locale->text('Invoice Created'); push @a, qq| | . $locale->text('Due Date'); push @a, qq| | @@ -1975,7 +1980,7 @@ sub transactions { @columns = $form->sort_columns( - qw(transdate id invnumber ordnumber ponumber name netamount tax amount paid due curr datepaid duedate notes till employee manager shippingpoint shipvia department) + qw(transdate id invnumber ordnumber ponumber name netamount tax amount paid due curr datepaid crdate duedate notes till employee manager shippingpoint shipvia department) ); pop @columns if $form->{department}; unshift @columns, "runningnumber"; @@ -2025,6 +2030,10 @@ sub transactions { "" . $locale->text('Date') . ""; + $column_header{crdate} = + "" + . $locale->text('Invoice Created') + . ""; $column_header{duedate} = "" . $locale->text('Due Date') @@ -2290,7 +2299,7 @@ sub transactions { } for (qw(notes description)) { $ref->{$_} =~ s/\r?\n/
/g } for ( - qw(transdate datepaid duedate department ordnumber ponumber notes shippingpoint shipvia employee manager till source description projectnumber) + qw(transdate datepaid crdate duedate department ordnumber ponumber notes shippingpoint shipvia employee manager till source description projectnumber) ) { $column_data{$_} = "$ref->{$_} "; diff --git a/bin/arapprn.pl b/bin/arapprn.pl index 4480399760..e2f5609959 100644 --- a/bin/arapprn.pl +++ b/bin/arapprn.pl @@ -265,7 +265,7 @@ sub print_transaction { ( $form->{employee} ) = split /--/, $form->{employee}; if ( exists $form->{longformat} ) { - for (qw(duedate transdate)) { + for (qw(duedate transdate crdate)) { $form->{$_} = $locale->date( \%myconfig, $form->{$_}, $form->{longformat} ); } @@ -273,7 +273,7 @@ sub print_transaction { $form->{notes} =~ s/^\s+//g; - @a = ( "invnumber", "transdate", "duedate", "notes" ); + @a = ( "invnumber", "transdate", "duedate", "crdate", "notes" ); push @a, qw(company address tel fax businessnumber text_amount text_decimal); diff --git a/bin/is.pl b/bin/is.pl index e7c92fdec0..b5977ad8fd 100644 --- a/bin/is.pl +++ b/bin/is.pl @@ -260,7 +260,7 @@ sub invoice_links { $form->{AR} = $form->{AR_1} unless $form->{id}; $form->{transdate} = $form->{current_date} if (!$form->{transdate}); - $form->{crdate} = $form->{current_date}; + $form->{crdate} = $form->{current_date} if (!$form->{crdate}); $form->{locked} = ( $form->{revtrans} ) ? '1' @@ -568,7 +568,7 @@ sub form_header { $employee | . $locale->text('Invoice Number') . qq| - + | . $locale->text('Order Number') . qq|