Skip to content

Commit

Permalink
Merge pull request #8 from ledgersmb/1.4
Browse files Browse the repository at this point in the history
1.4 refresh my repository before fixing hu.po
  • Loading branch information
pongraczi committed Jun 19, 2014
2 parents 0a3130e + 99bcf91 commit 1d30761
Show file tree
Hide file tree
Showing 57 changed files with 977 additions and 512 deletions.
3 changes: 3 additions & 0 deletions Changelog
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ Installation/Upgrade
* LaTeX format detection now run-time call, not configured (Chris T)
* configure_apache.sh: Add search for apache user & config path
Do not overwrite ledgersmb-httpd.conf without warning (Havard S)
* Validation of database schema load processes in setup.pl (Erik H)

Code/API improvements
* scripts/* files moved to make inheritance possible (Chris T)
Expand Down Expand Up @@ -115,6 +116,8 @@ Changelog for 1.3.40
* Fixed #1133 (FX rate changed after selecting part/service) (Pongracz I)
* Fixed #1078 (Don't populate all empty projects automatically) (Pongracz I)
* Fixed #1139 (Vendor can show up as default customer in sales order, confusing...) (Pongracz I)
* Fixed type mismatch between invoice.qty and invoice.allocated (Chris T)
* Fixed manual tax invoices not reversing properly (Chris T, 1134)

Chris T is Chris Travers
Pongracz I is Pongracz Istvan
Expand Down
4 changes: 3 additions & 1 deletion LedgerSMB.pm
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,9 @@ sub close_form {

sub get_user_info {
my ($self) = @_;
$self->{_user} = LedgerSMB::User->fetch_config($self);
$LedgerSMB::App_State::User =
$self->{_user} =
LedgerSMB::User->fetch_config($self);
$self->{_user}->{language} ||= 'en';
}
#This function needs to be moved into the session handler.
Expand Down
5 changes: 1 addition & 4 deletions LedgerSMB/AA.pm
Original file line number Diff line number Diff line change
Expand Up @@ -423,10 +423,7 @@ sub post_transaction {
} else {
$batch_class = 'ap';
}
my $vqh = $dbh->prepare(
'SELECT * FROM batch
WHERE id = ? FOR UPDATE'
);
my $vqh = $dbh->prepare('SELECT * FROM batch__lock_for_update(?)');
$vqh->execute($form->{batch_id});
my $bref = $vqh->fetchrow_hashref('NAME_lc');
# Change the below to die with localization in 1.4
Expand Down
15 changes: 13 additions & 2 deletions LedgerSMB/Entity/Bank.pm
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,6 @@ setting things like the id field.
sub save {
my ($self) = @_;
my ($ref) = $self->exec_method({funcname => 'entity__save_bank_account'});
$self->prepare_dbhash($ref);
$self = $self->new(%$ref);
}

=item delete
Expand All @@ -137,6 +135,19 @@ sub delete {
return $ref;
}

=over get($id)
Returns the account with the id.
=cut

sub get {
my ($self, $id) = @_;
my ($ref) = __PACKAGE__->call_procedure (procname => 'entity__get_bank_account',
args => [$id]);
return __PACKAGE__->new(%$ref);
}

=back
=head1 COPYRIGHT
Expand Down
2 changes: 1 addition & 1 deletion LedgerSMB/Entity/Contact.pm
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ contains either entity_id or credit_id, and location_id, and location class.

sub delete {
my ($ref) = @_;
if ($ref->{credit_id}){
if ($ref->{for_credit}){
__PACKAGE__->call_procedure(procname => 'eca__delete_contact',
args => [$ref->{credit_id}, $ref->{class_id},
$ref->{contact}]);
Expand Down
8 changes: 4 additions & 4 deletions LedgerSMB/Entity/Credit_Account.pm
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ The id for the AR or AP account, use for payment reversals. Required on save.
=cut

has 'ar_ap_account_id' => (is => 'rw', isa => 'Int', required => 1);
has 'ar_ap_account_id' => (is => 'rw', isa => 'Int');

=item cash_account_id
Expand Down Expand Up @@ -318,10 +318,10 @@ identified by $meta_number

sub get_by_meta_number {
my ($self, $meta_number, $entity_class) = @_;
my ($ref) = __PACKAGE__->call_procedure(procname => 'eca__get_by_met_number',
my ($ref) = __PACKAGE__->call_procedure(procname => 'eca__get_by_meta_number',
args => [$meta_number,
$entity_class]);
$ref->{tax_ids} = __PACKAGE__->_set_tax_ids($ref->{id});
$ref->{tax_ids} = __PACKAGE__->_get_tax_ids($ref->{id});
return __PACKAGE__->new(%$ref);
}

Expand Down Expand Up @@ -379,7 +379,7 @@ Saves the entity credit account. This also sets db defaults if not set.

sub save {
my ($self) = @_;
warn $self->{entity_class};
die 'No AR/AP Account ID Set' unless $self->ar_ap_account_id;
my ($ref) = $self->exec_method({funcname => 'eca__save'});
$self->{id}=$ref->{eca__save};
$self->exec_method(funcname => 'eca__set_taxes');
Expand Down
5 changes: 1 addition & 4 deletions LedgerSMB/GL.pm
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,7 @@ sub post_transaction {
if (not defined $form->{batch_id}){
$form->error($locale->text('Batch ID Missing'));
}
my $vqh = $dbh->prepare(
'SELECT * FROM batch
WHERE id = ? FOR UPDATE'
);
my $vqh = $dbh->prepare('SELECT * FROM batch__lock_for_update(?)');
$vqh->execute($form->{batch_id});
my $bref = $vqh->fetchrow_hashref('NAME_lc');
# Change the below to die with localization in 1.4
Expand Down
43 changes: 21 additions & 22 deletions LedgerSMB/IS.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1213,7 +1213,6 @@ sub post_invoice {

}
}

# save detail record in invoice table
$query = qq|
INSERT INTO invoice (description)
Expand Down Expand Up @@ -1353,8 +1352,11 @@ sub post_invoice {
foreach $ref ( sort { $b->{amount} <=> $a->{amount} }
@{ $form->{acc_trans}{lineitems} } )
{
$diff ||= 0;
$ref->{fxdiff} ||= 0;

$amount = $ref->{amount} + $diff; # Subtracting included taxes

$query = qq|
INSERT INTO acc_trans
(trans_id, chart_id, amount,
Expand Down Expand Up @@ -1714,13 +1716,11 @@ sub process_assembly {
$project_id );
next;
}
else {
if ( $ref->{inventory_accno_id} ) {
$allocated =
&cogs( $dbh, $form, $ref->{parts_id}, $ref->{qty},
$project_id );
}
}
next unless $ref->{inventory_accno_id};

$allocated =
&cogs( $dbh, $form, $ref->{parts_id}, $ref->{qty},
$project_id );

$query = qq|
INSERT INTO invoice
Expand All @@ -1731,13 +1731,10 @@ sub process_assembly {

my $sth = $dbh->prepare($query);
$sth->execute( $form->{id}, $ref->{description}, $ref->{parts_id},
$ref->{qty}, $allocated, $ref->{unit} )
|| $form->dberror($query);

$ref->{qty}, $allocated, $ref->{unit} )
|| $form->dberror($query);
$sth->finish;
}

$sth->finish;

}

sub cogs {
Expand All @@ -1746,7 +1743,7 @@ sub cogs {
my $dbh = $form->{dbh};

# Parts info
my $part_sth = $dbh->prepare('SELECT * FROM parts WHERE id = ?');
my $part_sth = $dbh->prepare('SELECT * FROM parts__get_by_id(?)');
$part_sth->execute($id);
my ($part_ref) = $part_sth->fetchrow_hashref('NAME_lc');

Expand All @@ -1757,41 +1754,43 @@ sub cogs {
# Getting cogs
my $cogs_sth = $dbh->prepare('SELECT * FROM cogs__add_for_ar(?, ?)');
$cogs_sth->execute($id, $totalqty);
my ($cogs) = $cogs_sth->fetchrow_array();
my ($cogs_ref) = $cogs_sth->fetchrow_array();
my $cogs = pop @$cogs_ref;

push @{ $form->{acc_trans}{lineitems} },
{
chart_id => $parts_ref->{expense_accno_id},
chart_id => $part_ref->{expense_accno_id},
amount => $cogs * -1,
project_id => $project_id,
invoice_id => $inv_id
} if $cogs;

push @{ $form->{acc_trans}{lineitems} },
{
chart_id => $parts_ref->{inventory_accno_id},
chart_id => $part_ref->{inventory_accno_id},
amount => $cogs,
project_id => $project_id,
invoice_id => $inv_id
} if $cogs;

} else {
# Getting cogs
my $cogs_sth = $dbh->prepare('SELECT * FROM cogs__reverse_ar(?, ?)');
$cogs_sth->execute($id, $totalqty);
my ($cogs) = $cogs_sth->fetchrow_array();
my ($cogs_ref) = $cogs_sth->fetchrow_array();
my $cogs = pop @$cogs_ref;

push @{ $form->{acc_trans}{lineitems} },
{
chart_id => $parts_ref->{expense_accno_id},
amount => $linetotal,
amount => $cogs,
project_id => $project_id,
invoice_id => $inv_id
};

push @{ $form->{acc_trans}{lineitems} },
{
chart_id => $parts_ref->{inventory_accno_id},
amount => -$linetotal,
amount => -$cogs,
project_id => $project_id,
invoice_id => $inv_id
};
Expand Down
10 changes: 9 additions & 1 deletion LedgerSMB/Report/Aging.pm
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,15 @@ has 'date_ref' => (is => 'rw', coerce => 1, isa => 'LedgerSMB::Moose::Date');
=cut

has 'entity_class' => (is => 'rw', isa => 'Maybe[Int]');
has 'entity_class' => (is => 'ro', isa => 'Maybe[Int]');

=item entity_id
Customer/Vendor entity id
=cut

has entity_id => (is => 'ro', isa => 'Maybe[Int]');

=back
Expand Down
Loading

0 comments on commit 1d30761

Please sign in to comment.