Skip to content

Commit

Permalink
Patch for using Invoice Creation Date (crdate) for AP/AR invoices and…
Browse files Browse the repository at this point in the history
… 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
  • Loading branch information
pongraczi committed Sep 20, 2013
1 parent 5342270 commit 85d1ba6
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 19 deletions.
14 changes: 8 additions & 6 deletions LedgerSMB/AA.pm
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,7 @@ sub post_transaction {
intnotes = ?,
department_id = ?,
ponumber = ?,
crdate = ?,
reverse = ?
WHERE id = ?
|;
Expand All @@ -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);
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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 ,
Expand All @@ -1030,7 +1031,8 @@ sub transactions {
invnumber => 2,
ordnumber => 3,
transdate => 4,
duedate => 5,
crdate => 5,
duedate => 6,
datepaid => 10,
shipvia => 13,
shippingpoint => 14,
Expand Down
2 changes: 1 addition & 1 deletion LedgerSMB/Form.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 5 additions & 3 deletions LedgerSMB/IR.pm
Original file line number Diff line number Diff line change
Expand Up @@ -848,7 +848,8 @@ sub post_invoice {
curr = ?,
department_id = ?,
language_code = ?,
ponumber = ?
ponumber = ?,
crdate = ?
WHERE id = ?|;

$sth = $dbh->prepare($query);
Expand All @@ -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
Expand Down Expand Up @@ -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 = ?|;
Expand Down
7 changes: 4 additions & 3 deletions LedgerSMB/IS.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1598,7 +1598,8 @@ sub post_invoice {
person_id = ?,
till = ?,
language_code = ?,
ponumber = ?
ponumber = ?,
crdate = ?
WHERE id = ?
|;
$sth = $dbh->prepare($query);
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand Down
13 changes: 11 additions & 2 deletions bin/aa.pl
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ sub create_links {
&& $form->{type} eq 'invoice');

$duedate = $form->{duedate};
$crdate = $form->{crdate};
$taxincluded = $form->{taxincluded};

$form->{formname} = "transaction";
Expand Down Expand Up @@ -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};
Expand Down Expand Up @@ -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} );
Expand Down Expand Up @@ -1696,6 +1699,8 @@ sub search {
push @a,
qq|<input name="l_paid" class=checkbox type=checkbox value=Y checked> |
. $locale->text('Paid');
push @a, qq|<input name="l_crdate" class=checkbox type=checkbox value=Y> |
. $locale->text('Invoice Created');
push @a, qq|<input name="l_duedate" class=checkbox type=checkbox value=Y> |
. $locale->text('Due Date');
push @a, qq|<input name="l_due" class=checkbox type=checkbox value=Y> |
Expand Down Expand Up @@ -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";
Expand Down Expand Up @@ -2025,6 +2030,10 @@ sub transactions {
"<th><a class=listheading href=$href&sort=transdate>"
. $locale->text('Date')
. "</a></th>";
$column_header{crdate} =
"<th><a class=listheading href=$href&sort=crdate>"
. $locale->text('Invoice Created')
. "</a></th>";
$column_header{duedate} =
"<th><a class=listheading href=$href&sort=duedate>"
. $locale->text('Due Date')
Expand Down Expand Up @@ -2290,7 +2299,7 @@ sub transactions {
}
for (qw(notes description)) { $ref->{$_} =~ s/\r?\n/<br>/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{$_} = "<td>$ref->{$_}&nbsp;</td>";
Expand Down
4 changes: 2 additions & 2 deletions bin/arapprn.pl
Original file line number Diff line number Diff line change
Expand Up @@ -265,15 +265,15 @@ 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} );
}
}

$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);
Expand Down
4 changes: 2 additions & 2 deletions bin/is.pl
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -568,7 +568,7 @@ sub form_header {
$employee
<tr class="invnumber-row">
<th align=right nowrap>| . $locale->text('Invoice Number') . qq|</th>
<td><input name="invnumber" size="20" value="$form->{invnumber}"></td>
<td><input name="invnumber" size="20" value="$form->{invnumber}" readonly></td>
</tr>
<tr class="ordnumber-row">
<th align=right nowrap>| . $locale->text('Order Number') . qq|</th>
Expand Down

0 comments on commit 85d1ba6

Please sign in to comment.