-
- $customers
-
-
-
-
- |
- . $locale->text('Contact Person') . qq| |
- $contact |
-
-
- |
-
-
-
- | . $locale->text('Credit Limit') . qq| |
- $form->{creditlimit} |
- |
- | . $locale->text('Remaining') . qq| |
- $form->{creditremaining} |
-
-
- |
- $shipto
-
- $business
- $dunning
+
+
+
+ $customers
+
+
+
+
+
+ $contact
+ $shipto
+
+ | . $locale->text('Credit Limit') . qq| |
+ $form->{creditlimit}; | . $locale->text('Remaining') . qq| $form->{creditremaining} |
+
+ $dunning
+ $business
| . $locale->text('Record in') . qq| |
- |
+ |
$taxzone
@@ -746,7 +677,7 @@ print qq|
#
print qq|
|
-
+ |
$employees
$salesman
@@ -784,8 +715,8 @@ print qq|
| . $locale->text('Order Date') . qq| |
- |
- |
+
+ |
| . $locale->text('Quotation Number') . qq| |
@@ -793,8 +724,8 @@ print qq|
| . $locale->text('Quotation Date') . qq| |
- |
- |
+
+ |
| . $locale->text('Customer Order Number') . qq| |
@@ -813,23 +744,11 @@ print qq|
|
-
-| .
-$jsscript
-. qq|
-
-| ;
-map({ print($cgi->hidden("-name" => $_, "-value" => $form->{$_})); }
- qw(shiptoname shiptostreet shiptozipcode shiptocity shiptocountry shiptocontact shiptophone shiptofax shiptoemail shiptodepartment_1 shiptodepartment_2));
-print qq| |;
-map({ print($cgi->hidden("-name" => $_, "-value" => $form->{$_})); }
- qw(message email subject cc bcc taxaccounts));
-print qq||;
+
+ $jsscript
+|;
+ print qq||;
- foreach $item (split(/ /, $form->{taxaccounts})) {
- map({ print($cgi->hidden("-name" => $_, "-value" => $form->{$_})); }
- ("${item}_rate", "${item}_description", "${item}_taxnumber"));
- }
$lxdebug->leave_sub();
}
@@ -849,7 +768,7 @@ sub form_footer {
qq||;
$intnotes =
qq||;
-
+
$form->{taxincluded} = ($form->{taxincluded} ? "checked" : "");
$taxincluded = "";
@@ -951,9 +870,23 @@ sub form_footer {
|
-
+ |
+
+
+ | . $locale->text('Ertrag') . qq| |
+ | . $form->format_amount(\%myconfig, $form->{marge_total}, 2, 0) . qq| |
+
+
+ | . $locale->text('Ertrag prozentual') . qq| |
+ | . $form->format_amount(\%myconfig, $form->{marge_percent}, 2, 0) . qq| % |
+
+
+
+
+ |
+
$taxincluded
-
+
$subtotal
$tax
@@ -979,11 +912,11 @@ sub form_footer {
Dateiname |
Webdavlink |
|;
- foreach $file (keys %{ $form->{WEBDAV} }) {
+ foreach $file (@{ $form->{WEBDAV} }) {
$webdav_list .= qq|
- $file |
- $form->{WEBDAV}{$file} |
+ $file->{name} |
+ $file->{type} |
|;
}
@@ -1037,7 +970,8 @@ if ($form->{type} eq "credit_note") {
";
- my @triggers = ();
+ my @triggers = ();
+ my $totalpaid = 0;
$form->{paidaccounts}++ if ($form->{"paid_$form->{paidaccounts}"});
for $i (1 .. $form->{paidaccounts}) {
@@ -1058,6 +992,9 @@ if ($form->{type} eq "credit_note") {
$form->{"exchangerate_$i"} =
$form->format_amount(\%myconfig, $form->{"exchangerate_$i"});
+ if ($form->{"exchangerate_$i"} == 0) {
+ $form->{"exchangerate_$i"} = "";
+ }
$exchangerate = qq| |;
if ($form->{currency} ne $form->{defaultcurrency}) {
if ($form->{"forex_$i"}) {
@@ -1088,7 +1025,24 @@ if ($form->{type} eq "credit_note") {
push(@triggers, "datepaid_$i", "BL", "trigger_datepaid_$i");
}
- map({ print($cgi->hidden("-name" => $_, "-value" => $form->{$_})); } qw(paidaccounts selectAR_paid oldinvtotal));
+ my $paid_missing = $form->{oldinvtotal} - $totalpaid;
+
+ print qq|
+
+ |
+ |
+ | . $locale->text('Total') . qq| |
+ | . H($form->format_amount(\%myconfig, $totalpaid, 2)) . qq| |
+
+
+ |
+ |
+ | . $locale->text('Missing amount') . qq| |
+ | . H($form->format_amount(\%myconfig, $paid_missing, 2)) . qq| |
+
+|;
+
+ map({ print($cgi->hidden("-name" => $_, "-value" => $form->{$_})); } qw(paidaccounts selectAR_paid oldinvtotal));
print qq|
@@ -1178,17 +1132,22 @@ if ($form->{type} eq "credit_note") {
. Q($form->{id})
. qq|);" name="history" id="history" value="|
. $locale->text('history')
- . qq|">|;
+ . qq|"> |;
}
# /button for saving history
-
-
+
+ # mark_as_paid button
+ if($form->{id} ne "") {
+ print qq||;
+ }
+ # /mark_as_paid button
print $form->write_trigger(\%myconfig, scalar(@triggers) / 3, @triggers) .
qq|
| .
-$cgi->hidden("-name" => "callback", "-value" => $form->{callback})
+$cgi->hidden("-name" => "callback", "-value" => $form->{callback})
. $cgi->hidden('-name' => 'draft_id', '-default' => [$form->{draft_id}])
. $cgi->hidden('-name' => 'draft_description', '-default' => [$form->{draft_description}]);
map({ print $cgi->hidden("-name" => $_ , "-value" => $form->{$_});} qw(login password));
@@ -1203,55 +1162,39 @@ print qq|
$lxdebug->leave_sub();
}
+sub mark_as_paid {
+ $lxdebug->enter_sub();
+ &mark_as_paid_common(\%myconfig,"ar");
+ $lxdebug->leave_sub();
+}
+
sub update {
$lxdebug->enter_sub();
- map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) }
- qw(exchangerate creditlimit creditremaining);
- if ($form->{second_run}) {
- $form->{print_and_post} = 0;
- }
+ my ($recursive_call) = shift;
-
- if($form->{taxincluded}) {
- $taxincluded = "checked";
- }
+ map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) } qw(exchangerate creditlimit creditremaining) unless $recursive_call;
+
+ $form->{print_and_post} = 0 if $form->{second_run};
+ $taxincluded = "checked" if $form->{taxincluded};
$form->{update} = 1;
&check_name(customer);
- if(!$form->{taxincluded}) {
- $form->{taxincluded} = $taxincluded;
- }
-
+ $form->{taxincluded} ||= $taxincluded;
- $form->{exchangerate} = $exchangerate
- if (
- $form->{forex} = (
- $exchangerate =
- $form->check_exchangerate(
- \%myconfig, $form->{currency}, $form->{invdate}, 'buy'
- )));
+ $form->{exchangerate} = $exchangerate if
+ $form->{forex} = $exchangerate = $form->check_exchangerate(\%myconfig, $form->{currency}, $form->{invdate}, 'buy');
for $i (1 .. $form->{paidaccounts}) {
- if ($form->{"paid_$i"}) {
- map {
- $form->{"${_}_$i"} =
- $form->parse_amount(\%myconfig, $form->{"${_}_$i"})
- } qw(paid exchangerate);
-
- $form->{"exchangerate_$i"} = $exchangerate
- if (
- $form->{"forex_$i"} = (
- $exchangerate =
- $form->check_exchangerate(
- \%myconfig, $form->{currency}, $form->{"datepaid_$i"}, 'buy'
- )));
- }
+ next unless $form->{"paid_$i"};
+ map { $form->{"${_}_$i"} = $form->parse_amount(\%myconfig, $form->{"${_}_$i"}) } qw(paid exchangerate);
+ $form->{"exchangerate_$i"} = $exchangerate if
+ $form->{"forex_$i"} = $exchangerate = $form->check_exchangerate(\%myconfig, $form->{currency}, $form->{"datepaid_$i"}, 'buy');
}
$i = $form->{rowcount};
- $exchangerate = ($form->{exchangerate}) ? $form->{exchangerate} : 1;
+ $exchangerate = $form->{exchangerate} || 1;
# if last row empty, check the form otherwise retrieve new item
if ( ($form->{"partnumber_$i"} eq "")
@@ -1267,8 +1210,7 @@ sub update {
$rows = scalar @{ $form->{item_list} };
- $form->{"discount_$i"} =
- $form->format_amount(\%myconfig, $form->{discount} * 100);
+ $form->{"discount_$i"} = $form->format_amount(\%myconfig, $form->{discount} * 100);
if ($rows) {
$form->{"qty_$i"} = ($form->{"qty_$i"} * 1) ? $form->{"qty_$i"} : 1;
@@ -1282,27 +1224,20 @@ sub update {
$sellprice = $form->parse_amount(\%myconfig, $form->{"sellprice_$i"});
- map { $form->{item_list}[$i]{$_} =~ s/\"/"/g }
- qw(partnumber description unit);
- map { $form->{"${_}_$i"} = $form->{item_list}[0]{$_} }
- keys %{ $form->{item_list}[0] };
- if ($form->{"part_payment_id_$i"} ne "") {
- $form->{payment_id} = $form->{"part_payment_id_$i"};
- }
+ map { $form->{item_list}[$i]{$_} =~ s/\"/"/g } qw(partnumber description unit);
+ map { $form->{"${_}_$i"} = $form->{item_list}[0]{$_} } keys %{ $form->{item_list}[0] };
+
+ $form->{payment_id} = $form->{"part_payment_id_$i"} if $form->{"part_payment_id_$i"} ne "";
+ $form->{"discount_$i"} = 0 if $form->{"not_discountable_$i"};
- if ($form->{"not_discountable_$i"}) {
- $form->{"discount_$i"} = 0;
- }
+ $form->{"marge_price_factor_$i"} = $form->{item_list}->[0]->{price_factor};
- $s = ($sellprice) ? $sellprice : $form->{"sellprice_$i"};
- ($dec) = ($s =~ /\.(\d+)/);
- $dec = length $dec;
- $decimalplaces = ($dec > 2) ? $dec : 2;
+ ($sellprice || $form->{"sellprice_$i"}) =~ /\.(\d+)/;
+ $decimalplaces = max 2, length $1;
if ($sellprice) {
$form->{"sellprice_$i"} = $sellprice;
} else {
-
# if there is an exchange rate adjust sellprice
$form->{"sellprice_$i"} *= (1 - $form->{tradediscount});
$form->{"sellprice_$i"} /= $exchangerate;
@@ -1310,36 +1245,24 @@ sub update {
$form->{"listprice_$i"} /= $exchangerate;
- $amount =
- $form->{"sellprice_$i"} * $form->{"qty_$i"} *
- (1 - $form->{"discount_$i"} / 100);
- map { $form->{"${_}_base"} = 0 } (split / /, $form->{taxaccounts});
- map { $form->{"${_}_base"} += $amount }
- (split / /, $form->{"taxaccounts_$i"});
- map { $amount += ($form->{"${_}_base"} * $form->{"${_}_rate"}) }
- split / /, $form->{"taxaccounts_$i"}
- if !$form->{taxincluded};
+ $amount = $form->{"sellprice_$i"} * $form->{"qty_$i"} * (1 - $form->{"discount_$i"} / 100);
+ map { $form->{"${_}_base"} = 0 } split / /, $form->{taxaccounts};
+ map { $form->{"${_}_base"} += $amount } split / /, $form->{"taxaccounts_$i"};
+ map { $amount += ($form->{"${_}_base"} * $form->{"${_}_rate"}) } split / /, $form->{"taxaccounts_$i"} if !$form->{taxincluded};
$form->{creditremaining} -= $amount;
- map {
- $form->{"${_}_$i"} =
- $form->format_amount(\%myconfig, $form->{"${_}_$i"},
- $decimalplaces)
- } qw(sellprice listprice);
+ map { $form->{"${_}_$i"} = $form->format_amount(\%myconfig, $form->{"${_}_$i"}, $decimalplaces) } qw(sellprice listprice);
- $form->{"qty_$i"} =
- $form->format_amount(\%myconfig, $form->{"qty_$i"});
+ $form->{"qty_$i"} = $form->format_amount(\%myconfig, $form->{"qty_$i"});
if ($lizenzen) {
if ($form->{"inventory_accno_$i"} ne "") {
$form->{"lizenzen_$i"} = qq||;
foreach $item (@{ $form->{LIZENZEN}{ $form->{"id_$i"} } }) {
- $form->{"lizenzen_$i"} .=
- qq||;
+ $form->{"lizenzen_$i"} .= qq||;
}
- $form->{"lizenzen_$i"} .=
- qq||;
+ $form->{"lizenzen_$i"} .= qq||;
}
}
@@ -1362,14 +1285,11 @@ sub update {
&& ($form->{"description_$i"} eq "")) {
$form->{rowcount}--;
$form->{"discount_$i"} = "";
- &display_form;
- } else {
+ display_form();
+ } else {
$form->{"id_$i"} = 0;
- $form->{"unit_$i"} = $locale->text('ea');
-
- &new_item;
-
+ new_item();
}
}
}
@@ -1378,6 +1298,8 @@ sub update {
sub post_payment {
$lxdebug->enter_sub();
+
+ $form->{defaultcurrency} = $form->get_default_currency(\%myconfig);
for $i (1 .. $form->{paidaccounts}) {
if ($form->{"paid_$i"}) {
$datepaid = $form->datetonum($form->{"datepaid_$i"}, \%myconfig);
@@ -1399,7 +1321,7 @@ sub post_payment {
($form->{AR}) = split /--/, $form->{AR};
($form->{AR_paid}) = split /--/, $form->{AR_paid};
relink_accounts();
- $form->redirect($locale->text(' Payment posted!'))
+ $form->redirect($locale->text('Payment posted!'))
if (IS->post_payment(\%myconfig, \%$form));
$form->error($locale->text('Cannot post payment!'));
@@ -1409,6 +1331,8 @@ sub post_payment {
sub post {
$lxdebug->enter_sub();
+
+ $form->{defaultcurrency} = $form->get_default_currency(\%myconfig);
$form->isblank("invdate", $locale->text('Invoice Date missing!'));
$form->isblank("customer", $locale->text('Customer missing!'));
@@ -1453,8 +1377,9 @@ sub post {
}
}
- ($form->{AR}) = split /--/, $form->{AR};
- ($form->{AR_paid}) = split /--/, $form->{AR_paid};
+ ($form->{AR}) = split /--/, $form->{AR};
+ ($form->{AR_paid}) = split /--/, $form->{AR_paid};
+ $form->{storno} ||= 0;
$form->{label} = $locale->text('Invoice');
@@ -1481,7 +1406,7 @@ sub post {
"POSTED";
$form->save_history($form->dbconnect(\%myconfig));
}
-
+
$form->redirect( $form->{label} . " $form->{invnumber} " . $locale->text('posted!'))
unless $print_post;
@@ -1552,7 +1477,6 @@ sub preview {
$form->{preview} = 1;
$old_form = new Form;
for (keys %$form) { $old_form->{$_} = $form->{$_} }
- $old_form->{rowcount}++;
&print_form($old_form);
$lxdebug->leave_sub();
@@ -1613,7 +1537,7 @@ sub credit_note {
$form->{script} = 'is.pl';
$script = "is";
$buysell = 'buy';
-
+
# bo creates the id, reset it
map { delete $form->{$_} }
@@ -1656,12 +1580,12 @@ sub yes {
if (IS->delete_invoice(\%myconfig, \%$form, $spool)) {
# saving the history
if(!exists $form->{addition}) {
- $form->{snumbers} = qq|invnumber_| . $form->{invnumber};
+ $form->{snumbers} = qq|invnumber_| . $form->{invnumber};
$form->{addition} = "DELETED";
$form->save_history($form->dbconnect(\%myconfig));
}
- # /saving the history
- $form->redirect($locale->text('Invoice deleted!'));
+ # /saving the history
+ $form->redirect($locale->text('Invoice deleted!'));
}
$form->error($locale->text('Cannot delete invoice!'));
|