From bca5826c5485e2c1f3d8cfdf36f247826ea4afed Mon Sep 17 00:00:00 2001 From: einhverfr Date: Tue, 12 Aug 2008 16:37:02 +0000 Subject: Merging fix for bug 1974974 git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk@2250 4979c152-3d1c-0410-bac9-87ea11338e46 --- LedgerSMB/CA.pm | 9 ----- LedgerSMB/DBObject/Company.pm | 82 +++++++++++++++++++++++++++++++++++++------ 2 files changed, 71 insertions(+), 20 deletions(-) (limited to 'LedgerSMB') diff --git a/LedgerSMB/CA.pm b/LedgerSMB/CA.pm index fa10a985..117d9d1e 100644 --- a/LedgerSMB/CA.pm +++ b/LedgerSMB/CA.pm @@ -403,9 +403,6 @@ sub all_transactions { $dpt_where AND ($approved OR (a.approved AND ac.approved)) $project|; - if ($d_id) { - push @queryargs, $d_id; - } push @queryargs, $id; if ($fdate) { push @queryargs, $fdate; @@ -437,9 +434,6 @@ sub all_transactions { $dpt_where $project|; - if ($d_id) { - push @queryargs, $d_id; - } push @queryargs, $id; if ($fdate) { push @queryargs, $fdate; @@ -471,9 +465,6 @@ sub all_transactions { $dpt_where $project |; - if ($d_id) { - push @queryargs, $d_id; - } push @queryargs, $id; if ($fdate) { push @queryargs, $fdate; diff --git a/LedgerSMB/DBObject/Company.pm b/LedgerSMB/DBObject/Company.pm index 23a56cec..b2eed72c 100644 --- a/LedgerSMB/DBObject/Company.pm +++ b/LedgerSMB/DBObject/Company.pm @@ -88,8 +88,16 @@ This method saves an address for a company. sub save_location { my $self = shift @_; + $self->{country_id} = $self->{country_code}; - $self->exec_method(funcname => 'company__location_save'); + + if($self->{credit_id}){ + $self->exec_method(funcname => 'eca__location_save'); + } else { + my ($ref) = $self->exec_method(funcname => 'company__location_save'); + my @vals = values %$ref; + $self->{location_id} = $vals[0]; + } $self->{dbh}->commit; } @@ -154,13 +162,15 @@ sub get_metadata { @{$self->{contact_class_list}} = $self->exec_method(funcname => 'entity_list_contact_class'); - @{$self->{credit_list}} = - $self->exec_method(funcname => 'entity__list_credit'); } sub save_contact { my ($self) = @_; - $self->exec_method(funcname => 'company__save_contact'); + if ($self->{credit_id}){ + $self->exec_method(funcname => 'eca__save_contact'); + } else { + $self->exec_method(funcname => 'company__save_contact'); + } $self->{dbh}->commit; } @@ -172,7 +182,11 @@ sub save_bank_account { sub save_notes { my $self = shift @_; - $self->exec_method(funcname => 'entity__save_notes'); + if ($self->{credit_id} && $self->{note_class} eq '3'){ + $self->exec_method(funcname => 'eca__save_notes'); + } else { + $self->exec_method(funcname => 'entity__save_notes'); + } $self->{dbh}->commit; } @@ -198,19 +212,65 @@ sub get { $self->merge($ref); $self->{threshold} = $self->format_amount(amount => $self->{threshold}); + @{$self->{credit_list}} = + $self->exec_method(funcname => 'entity__list_credit'); + + for (@{$self->{credit_list}}){ + print STDERR "credit_id: $_->{credit_id}\n"; + if (($_->{credit_id} eq $self->{credit_id}) + or ($_->{meta_number} eq $self->{meta_number})){ + $self->merge($_); + last; + } + } $self->{name} = $self->{legal_name}; + if ($self->{credit_id} and $self->{meta_number}){ + $self->get_credit_id; + } - @{$self->{locations}} = $self->exec_method( + if ($self->{credit_id}){ + @{$self->{locations}} = $self->exec_method( + funcname => 'eca__list_locations'); + @{$self->{contacts}} = $self->exec_method( + funcname => 'eca__list_contacts'); + @{$self->{notes}} = $self->exec_method( + funcname => 'eca__list_notes'); + + } + else { + @{$self->{locations}} = $self->exec_method( funcname => 'company__list_locations'); - - @{$self->{contacts}} = $self->exec_method( + @{$self->{contacts}} = $self->exec_method( funcname => 'company__list_contacts'); + @{$self->{notes}} = $self->exec_method( + funcname => 'company__list_notes'); + + } + + if ($self->{location_id}){ + for (@{$self->{locations}}){ + if ($_->{id} = $self->{location_id}){ + my $old_id = $self->{id}; + $self->merge($_); + $self->{id} = $old_id; + last; + } + } + } + + if ($self->{contact_id}){ + for (@{$self->{contacts}}){ + if ($_->{id} = $self->{contact_id}){ + my $old_id = $self->{id}; + $self->merge($_); + $self->{id} = $old_id; + last; + } + } + } @{$self->{bank_account}} = $self->exec_method( funcname => 'company__list_bank_account'); - - @{$self->{notes}} = $self->exec_method( - funcname => 'company__list_notes'); }; 1; -- cgit v1.2.3