From: Jan Büren Date: Mon, 6 Dec 2010 11:45:31 +0000 (+0100) Subject: Merge branch 'master' of ssh://git-jbueren@lx-office.linet-services.de/~/lx-office-erp X-Git-Tag: release-2.6.2beta1~80 X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/commitdiff_plain/57463eed482c9f107a6bb35d8b24d666175570a3?hp=914d2b3fda11d4cf465c0ee33f07c03fa2e1f45f Merge branch 'master' of ssh://git-jbueren@lx-office.linet-services.de/~/lx-office-erp Conflicts: doc/changelog --- diff --git a/SL/Dispatcher.pm b/SL/Dispatcher.pm index 8bd296804..98c93d4f4 100644 --- a/SL/Dispatcher.pm +++ b/SL/Dispatcher.pm @@ -155,7 +155,7 @@ sub handle_request { $::form->{titlebar} = "Lx-Office " . $::locale->text('Version') . " $::form->{version}"; ::run($::auth->restore_session); - } elsif ($action) { + } else { # copy from am.pl routines my $session_result = $::auth->restore_session; @@ -172,14 +172,15 @@ sub handle_request { $::auth->create_or_refresh_session; delete $::form->{password}; - map { $::form->{$_} = $::myconfig{$_} } qw(stylesheet charset) - unless $action eq 'save' && $::form->{type} eq 'preferences'; - - $::form->set_standard_title; - ::call_sub('::' . $::locale->findsub($action)); + if ($action) { + map { $::form->{$_} = $::myconfig{$_} } qw(stylesheet charset) + unless $action eq 'save' && $::form->{type} eq 'preferences'; - } else { - $::form->error($::locale->text('action= not defined!')); + $::form->set_standard_title; + ::call_sub('::' . $::locale->findsub($action)); + } else { + $::form->error($::locale->text('action= not defined!')); + } } 1; diff --git a/SL/IC.pm b/SL/IC.pm index f1840d8cb..ad1703650 100644 --- a/SL/IC.pm +++ b/SL/IC.pm @@ -504,7 +504,11 @@ sub save { $value = $form->parse_amount($myconfig, $form->{"lastcost_$i"}); if ($value == $form->{"old_lastcost_$i"}) { - $lastupdate = $dbh->quote($form->{"lastupdate_$i"}); + if ($form->{"lastupdate_$i"} eq "") { + $lastupdate = 'now()'; + } else { + $lastupdate = $dbh->quote($form->{"lastupdate_$i"}); + } } else { $lastupdate = 'now()'; } @@ -1467,8 +1471,8 @@ sub follow_account_chain { $form->{ACCOUNT_CHAIN_BY_ID} ||= { map { $_->{id} => $_ } - selectall_hashref_query($form, $dbh, <= c.valid_from AS is_valid, cnew.accno + selectall_hashref_query($form, $dbh, <= c.valid_from AS is_valid, cnew.accno FROM chart c LEFT JOIN chart cnew ON c.new_chart_id = cnew.id WHERE NOT c.new_chart_id IS NULL AND (c.new_chart_id > 0) @@ -1518,7 +1522,7 @@ sub retrieve_accounts { if ($transdate eq "") { $transdate = "current_date"; } else { - $transdate = 'date(' . $dbh->quote($transdate) . ')'; + $transdate = $dbh->quote($transdate); } #/transdate my $inc_exp = $form->{"vc"} eq "customer" ? "income_accno_id" : "expense_accno_id"; @@ -1551,7 +1555,7 @@ SQL WHERE t.id IN (SELECT tk.tax_id FROM taxkeys tk - WHERE tk.chart_id = ? AND startdate <= ${transdate} + WHERE tk.chart_id = ? AND startdate <= ? ORDER BY startdate DESC LIMIT 1) SQL @@ -1569,7 +1573,7 @@ SQL $form->{"${_}_accno_$index"} = $accounts{"${_}_accno"} for qw(inventory income expense); - $sth_tax->execute($accounts{$inc_exp}); + $sth_tax->execute($accounts{$inc_exp}, quote_db_date($transdate)); $ref = $sth_tax->fetchrow_hashref or next; $form->{"taxaccounts_$index"} = $ref->{"accno"}; diff --git a/SL/ReportGenerator.pm b/SL/ReportGenerator.pm index afae86333..f02f56875 100644 --- a/SL/ReportGenerator.pm +++ b/SL/ReportGenerator.pm @@ -425,7 +425,7 @@ sub generate_pdf_content { my (@data, @column_props, @cell_props); my ($data_row, $cell_props_row); - my @visible_columns = $self->get_visible_columns('HTML'); + my @visible_columns = $self->get_visible_columns('PDF'); my $num_columns = scalar @visible_columns; my $num_header_rows = 1; diff --git a/SL/SEPA.pm b/SL/SEPA.pm index a5fd4e1ed..9a2978314 100644 --- a/SL/SEPA.pm +++ b/SL/SEPA.pm @@ -16,28 +16,31 @@ sub retrieve_open_invoices { my $form = $main::form; my $dbh = $params{dbh} || $form->get_standard_dbh($myconfig); + my $arap = $params{vc} eq 'customer' ? 'ar' : 'ap'; + my $vc = $params{vc} eq 'customer' ? 'customer' : 'vendor'; my $query = qq| - SELECT ap.id, ap.invnumber, ap.vendor_id, ap.amount AS invoice_amount, ap.invoice, - v.name AS vendorname, ap.duedate as duedate, + SELECT ${arap}.id, ${arap}.invnumber, ${arap}.${vc}_id, ${arap}.amount AS invoice_amount, ${arap}.invoice, + vc.name AS vcname, vc.language_id, ${arap}.duedate as duedate, - COALESCE(v.iban, '') <> '' AND COALESCE(v.bic, '') <> '' AS vendor_bank_info_ok, + COALESCE(vc.iban, '') <> '' AND COALESCE(vc.bic, '') <> '' AS vc_bank_info_ok, - ap.amount - ap.paid - COALESCE(open_transfers.amount, 0) AS open_amount + ${arap}.amount - ${arap}.paid - COALESCE(open_transfers.amount, 0) AS open_amount - FROM ap - LEFT JOIN vendor v ON (ap.vendor_id = v.id) + FROM ${arap} + LEFT JOIN ${vc} vc ON (${arap}.${vc}_id = vc.id) LEFT JOIN (SELECT sei.ap_id, SUM(sei.amount) AS amount FROM sepa_export_items sei LEFT JOIN sepa_export se ON (sei.sepa_export_id = se.id) WHERE NOT se.closed + AND (se.vc = '${vc}') GROUP BY sei.ap_id) - AS open_transfers ON (ap.id = open_transfers.ap_id) + AS open_transfers ON (${arap}.id = open_transfers.ap_id) - WHERE ap.amount > (COALESCE(open_transfers.amount, 0) + ap.paid) + WHERE ${arap}.amount > (COALESCE(open_transfers.amount, 0) + ${arap}.paid) - ORDER BY lower(v.name) ASC, lower(ap.invnumber) ASC + ORDER BY lower(vc.name) ASC, lower(${arap}.invnumber) ASC |; my $results = selectall_hashref_query($form, $dbh, $query); @@ -53,46 +56,49 @@ sub create_export { my $self = shift; my %params = @_; - Common::check_params(\%params, qw(employee bank_transfers)); + Common::check_params(\%params, qw(employee bank_transfers vc)); my $myconfig = \%main::myconfig; my $form = $main::form; + my $arap = $params{vc} eq 'customer' ? 'ar' : 'ap'; + my $vc = $params{vc} eq 'customer' ? 'customer' : 'vendor'; + my $ARAP = uc $arap; my $dbh = $params{dbh} || $form->get_standard_dbh($myconfig); my ($export_id) = selectfirst_array_query($form, $dbh, qq|SELECT nextval('sepa_export_id_seq')|); my $query = - qq|INSERT INTO sepa_export (id, employee_id) + qq|INSERT INTO sepa_export (id, employee_id, vc) VALUES (?, (SELECT id FROM employee - WHERE login = ?))|; - do_query($form, $dbh, $query, $export_id, $params{employee}); + WHERE login = ?), ?)|; + do_query($form, $dbh, $query, $export_id, $params{employee}, $vc); my $q_item_id = qq|SELECT nextval('id')|; my $h_item_id = prepare_query($form, $dbh, $q_item_id); my $q_insert = - qq|INSERT INTO sepa_export_items (id, sepa_export_id, ap_id, chart_id, + qq|INSERT INTO sepa_export_items (id, sepa_export_id, ${arap}_id, chart_id, amount, requested_execution_date, reference, end_to_end_id, - our_iban, our_bic, vendor_iban, vendor_bic) + our_iban, our_bic, vc_iban, vc_bic) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)|; my $h_insert = prepare_query($form, $dbh, $q_insert); my $q_reference = - qq|SELECT ap.invnumber, + qq|SELECT arap.invnumber, (SELECT COUNT(at.*) FROM acc_trans at LEFT JOIN chart c ON (at.chart_id = c.id) WHERE (at.trans_id = ?) - AND (c.link LIKE '%AP_paid%')) + AND (c.link LIKE '%${ARAP}_paid%')) + (SELECT COUNT(sei.*) FROM sepa_export_items sei WHERE (sei.ap_id = ?)) AS num_payments - FROM ap + FROM ${arap} arap WHERE id = ?|; my $h_reference = prepare_query($form, $dbh, $q_reference); @@ -100,7 +106,7 @@ sub create_export { foreach my $transfer (@{ $params{bank_transfers} }) { if (!$transfer->{reference}) { - do_statement($form, $h_reference, $q_reference, (conv_i($transfer->{ap_id})) x 3); + do_statement($form, $h_reference, $q_reference, (conv_i($transfer->{"${arap}_id"})) x 3); my ($invnumber, $num_payments) = $h_reference->fetchrow_array(); $num_payments++; @@ -118,11 +124,11 @@ sub create_export { $end_to_end_id .= $item_id; $end_to_end_id = substr $end_to_end_id, 0, 35; - my @values = ($item_id, $export_id, - conv_i($transfer->{ap_id}), conv_i($transfer->{chart_id}), - $transfer->{amount}, conv_date($transfer->{requested_execution_date}), - $transfer->{reference}, $end_to_end_id, - map { my $pfx = $_; map { $transfer->{"${pfx}_${_}"} } qw(iban bic) } qw(our vendor)); + my @values = ($item_id, $export_id, + conv_i($transfer->{"${arap}_id"}), conv_i($transfer->{chart_id}), + $transfer->{amount}, conv_date($transfer->{requested_execution_date}), + $transfer->{reference}, $end_to_end_id, + map { my $pfx = $_; map { $transfer->{"${pfx}_${_}"} } qw(iban bic) } qw(our vc)); do_statement($form, $h_insert, $q_insert, @values); } @@ -143,18 +149,20 @@ sub retrieve_export { my $self = shift; my %params = @_; - Common::check_params(\%params, qw(id)); + Common::check_params(\%params, qw(id vc)); my $myconfig = \%main::myconfig; my $form = $main::form; + my $vc = $params{vc} eq 'customer' ? 'customer' : 'vendor'; + my $arap = $params{vc} eq 'customer' ? 'ar' : 'ap'; my $dbh = $params{dbh} || $form->get_standard_dbh($myconfig); my ($joins, $columns); if ($params{details}) { - $columns = ', ap.invoice'; - $joins = 'LEFT JOIN ap ON (se.ap_id = ap.id)'; + $columns = ', arap.invoice'; + $joins = "LEFT JOIN ${arap} arap ON (se.${arap}_id = arap.id)"; } my $query = @@ -170,10 +178,10 @@ sub retrieve_export { my ($columns, $joins); if ($params{details}) { - $columns = qq|, ap.invnumber, ap.invoice, v.name AS vendor_name, c.accno AS chart_accno, c.description AS chart_description|; - $joins = qq|LEFT JOIN ap ON (sei.ap_id = ap.id) - LEFT JOIN vendor v ON (ap.vendor_id = v.id) - LEFT JOIN chart c ON (sei.chart_id = c.id)|; + $columns = qq|, arap.invnumber, arap.invoice, arap.transdate AS reference_date, vc.name AS vc_name, c.accno AS chart_accno, c.description AS chart_description|; + $joins = qq|LEFT JOIN ${arap} arap ON (sei.${arap}_id = arap.id) + LEFT JOIN ${vc} vc ON (arap.${vc}_id = vc.id) + LEFT JOIN chart c ON (sei.chart_id = c.id)|; } $query = qq|SELECT sei.* @@ -181,6 +189,7 @@ sub retrieve_export { FROM sepa_export_items sei $joins WHERE sei.sepa_export_id = ?|; + $export->{items} = selectall_hashref_query($form, $dbh, $query, conv_i($params{id})); } else { @@ -224,6 +233,8 @@ sub list_exports { my $myconfig = \%main::myconfig; my $form = $main::form; + my $vc = $params{vc} eq 'customer' ? 'customer' : 'vendor'; + my $arap = $params{vc} eq 'customer' ? 'ar' : 'ap'; my $dbh = $params{dbh} || $form->get_standard_dbh($myconfig); @@ -255,16 +266,16 @@ sub list_exports { } if ($filter->{invnumber}) { - push @where_sub, "ap.invnumber ILIKE ?"; + push @where_sub, "arap.invnumber ILIKE ?"; push @values_sub, '%' . $filter->{invnumber} . '%'; - $joins_sub{ap} = 1; + $joins_sub{$arap} = 1; } - if ($filter->{vendor}) { - push @where_sub, "v.name ILIKE ?"; - push @values_sub, '%' . $filter->{vendor} . '%'; - $joins_sub{ap} = 1; - $joins_sub{vendor} = 1; + if ($filter->{vc}) { + push @where_sub, "vc.name ILIKE ?"; + push @values_sub, '%' . $filter->{vc} . '%'; + $joins_sub{$arap} = 1; + $joins_sub{vc} = 1; } foreach my $type (qw(requested_execution execution)) { @@ -277,8 +288,8 @@ sub list_exports { if (@where_sub) { my $joins_sub = ''; - $joins_sub .= ' LEFT JOIN ap ON (items.ap_id = ap.id)' if ($joins_sub{ap}); - $joins_sub .= ' LEFT JOIN vendor v ON (ap.vendor_id = v.id)' if ($joins_sub{vendor}); + $joins_sub .= " LEFT JOIN ${arap} arap ON (items.${arap}_id = arap.id)" if ($joins_sub{$arap}); + $joins_sub .= " LEFT JOIN ${vc} vc ON (arap.${vc}_id = vc.id)" if ($joins_sub{vc}); my $where_sub = join(' AND ', map { "(${_})" } @where_sub); @@ -291,6 +302,9 @@ sub list_exports { push @values, @values_sub; } + push @where, 'se.vc = ?'; + push @values, $vc; + my $where = ' WHERE ' . join(' AND ', map { "(${_})" } @where) if (@where); my $query = @@ -322,6 +336,10 @@ sub post_payment { my $myconfig = \%main::myconfig; my $form = $main::form; + my $vc = $params{vc} eq 'customer' ? 'customer' : 'vendor'; + my $arap = $params{vc} eq 'customer' ? 'ar' : 'ap'; + my $mult = $params{vc} eq 'customer' ? -1 : 1; + my $ARAP = uc $arap; my $dbh = $params{dbh} || $form->get_standard_dbh($myconfig); @@ -332,17 +350,17 @@ sub post_payment { FROM sepa_export_items sei WHERE sei.id = ?| ], - 'get_ap' => [ qq|SELECT at.chart_id + 'get_arap' => [ qq|SELECT at.chart_id FROM acc_trans at LEFT JOIN chart c ON (at.chart_id = c.id) WHERE (trans_id = ?) - AND ((c.link LIKE '%:AP') OR (c.link LIKE 'AP:%') OR (c.link = 'AP')) + AND ((c.link LIKE '%:${ARAP}') OR (c.link LIKE '${ARAP}:%') OR (c.link = '${ARAP}')) LIMIT 1| ], 'add_acc_trans' => [ qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, gldate, source, memo) VALUES (?, ?, ?, ?, current_date, ?, '')| ], - 'update_ap' => [ qq|UPDATE ap + 'update_arap' => [ qq|UPDATE ${arap} SET paid = paid + ? WHERE id = ?| ], @@ -374,16 +392,16 @@ sub post_payment { next if (!$orig_item); - # Retrieve the invoice's AP chart ID. - do_statement($form, @{ $handles{get_ap} }, $orig_item->{ap_id}); - my ($ap_chart_id) = $handles{get_ap}->[0]->fetchrow_array(); + # Retrieve the invoice's AR/AP chart ID. + do_statement($form, @{ $handles{get_arap} }, $orig_item->{"${arap}_id"}); + my ($arap_chart_id) = $handles{get_arap}->[0]->fetchrow_array(); - # Record the payment in acc_trans offsetting AP. - do_statement($form, @{ $handles{add_acc_trans} }, $orig_item->{ap_id}, $ap_chart_id, -1 * $orig_item->{amount}, $item->{execution_date}, ''); - do_statement($form, @{ $handles{add_acc_trans} }, $orig_item->{ap_id}, $orig_item->{chart_id}, $orig_item->{amount}, $item->{execution_date}, $orig_item->{reference}); + # Record the payment in acc_trans offsetting AR/AP. + do_statement($form, @{ $handles{add_acc_trans} }, $orig_item->{"${arap}_id"}, $arap_chart_id, -1 * $mult * $orig_item->{amount}, $item->{execution_date}, ''); + do_statement($form, @{ $handles{add_acc_trans} }, $orig_item->{"${arap}_id"}, $orig_item->{chart_id}, $mult * $orig_item->{amount}, $item->{execution_date}, $orig_item->{reference}); # Update the invoice to reflect the new paid amount. - do_statement($form, @{ $handles{update_ap} }, $orig_item->{amount}, $orig_item->{ap_id}); + do_statement($form, @{ $handles{update_arap} }, $orig_item->{amount}, $orig_item->{"${arap}_id"}); # Update the item to reflect that it has been posted. do_statement($form, @{ $handles{finish_item} }, $item->{execution_date}, $item_id); diff --git a/SL/SEPA/XML.pm b/SL/SEPA/XML.pm index ddac25e26..2c7f63253 100644 --- a/SL/SEPA/XML.pm +++ b/SL/SEPA/XML.pm @@ -32,14 +32,15 @@ sub _init { $self->{src_charset} = 'UTF-8'; $self->{grouped} = 0; - map { $self->{$_} = $params{$_} if (exists $params{$_}) } qw(src_charset company message_id grouped); + map { $self->{$_} = $params{$_} if (exists $params{$_}) } qw(src_charset company creditor_id message_id grouped collection); $self->{iconv} = SL::Iconv->new($self->{src_charset}, "UTF-8") || croak "Unsupported source charset $self->{src_charset}."; my $missing_parameter = first { !$self->{$_} } qw(company message_id); croak "Missing parameter: $missing_parameter" if ($missing_parameter); + croak "Missing parameter: creditor_id" if !$self->{creditor_id} && $self->{collection}; - map { $self->{$_} = $self->_replace_special_chars($self->{iconv}->convert($self->{$_})) } qw(company message_id); + map { $self->{$_} = $self->_replace_special_chars($self->{iconv}->convert($self->{$_})) } qw(company message_id creditor_id); } sub add_transaction { @@ -77,7 +78,7 @@ sub _format_amount { my $self = shift; my $amount = shift; - return sprintf '%d.%02d', int($amount), int($amount * 100) % 100; + return sprintf '%.02f', $amount; } sub _group_transactions { @@ -116,19 +117,27 @@ sub to_xml { DATA_INDENT => 2, ENCODING => 'utf-8'); - my @now = localtime; - my $time_zone = strftime "%z", @now; - my $now_str = strftime('%Y-%m-%dT%H:%M:%S', @now) . substr($time_zone, 0, 3) . ':' . substr($time_zone, 3, 2); + my @now = localtime; + my $time_zone = strftime "%z", @now; + my $now_str = strftime('%Y-%m-%dT%H:%M:%S', @now) . substr($time_zone, 0, 3) . ':' . substr($time_zone, 3, 2); + + my $is_coll = $self->{collection}; + my $cd_src = $is_coll ? 'Cdtr' : 'Dbtr'; + my $cd_dst = $is_coll ? 'Dbtr' : 'Cdtr'; + my $pain_id = $is_coll ? 'pain.008.002.01' : 'pain.001.001.02'; + my $pain_elmt = $is_coll ? 'pain.008.001.01' : 'pain.001.001.02'; + my @pii_base = (strftime('PII%Y%m%d%H%M%S', @now), rand(1000000000)); my $grouped_transactions = $self->_group_transactions(); $xml->xmlDecl(); + $xml->startTag('Document', - 'xmlns' => 'urn:sepade:xsd:pain.001.001.02.grp', + 'xmlns' => "urn:swift:xsd:\$${pain_id}", 'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance', - 'xsi:schemaLocation' => 'urn:sepade:xsd:pain.001.001.02.grp pain.001.001.02.grp.xsd'); + 'xsi:schemaLocation' => "urn:swift:xsd:\$${pain_id} ${pain_id}.xsd"); - $xml->startTag('pain.001.001.02'); + $xml->startTag($pain_elmt); $xml->startTag('GrpHdr'); $xml->dataElement('MsgId', encode('UTF-8', substr($self->{message_id}, 0, 35))); @@ -148,73 +157,111 @@ sub to_xml { my $master_transaction = $transaction_group->{transactions}->[0]; $xml->startTag('PmtInf'); - $xml->dataElement('PmtMtd', 'TRF'); + if ($is_coll) { + $xml->dataElement('PmtInfId', sprintf('%s%010d', @pii_base)); + $pii_base[1]++; + } + $xml->dataElement('PmtMtd', $is_coll ? 'DD' : 'TRF'); $xml->startTag('PmtTpInf'); $xml->startTag('SvcLvl'); $xml->dataElement('Cd', 'SEPA'); $xml->endTag('SvcLvl'); + + if ($is_coll) { + $xml->startTag('LclInstrm'); + $xml->dataElement('Cd', 'CORE'); + $xml->endTag('LclInstrm'); + $xml->dataElement('SeqTp', 'OOFF'); + } $xml->endTag('PmtTpInf'); - $xml->dataElement('ReqdExctnDt', $master_transaction->get('execution_date')); - $xml->startTag('Dbtr'); + $xml->dataElement($is_coll ? 'ReqdColltnDt' : 'ReqdExctnDt', $master_transaction->get('execution_date')); + $xml->startTag($cd_src); $xml->dataElement('Nm', encode('UTF-8', substr($self->{company}, 0, 70))); - $xml->endTag('Dbtr'); + $xml->endTag($cd_src); - $xml->startTag('DbtrAcct'); + $xml->startTag($cd_src . 'Acct'); $xml->startTag('Id'); $xml->dataElement('IBAN', $master_transaction->get('src_iban', 34)); $xml->endTag('Id'); - $xml->endTag('DbtrAcct'); + $xml->endTag($cd_src . 'Acct'); - $xml->startTag('DbtrAgt'); + $xml->startTag($cd_src . 'Agt'); $xml->startTag('FinInstnId'); $xml->dataElement('BIC', $master_transaction->get('src_bic', 20)); $xml->endTag('FinInstnId'); - $xml->endTag('DbtrAgt'); + $xml->endTag($cd_src . 'Agt'); $xml->dataElement('ChrgBr', 'SLEV'); foreach my $transaction (@{ $transaction_group->{transactions} }) { - $xml->startTag('CdtTrfTxInf'); + $xml->startTag($is_coll ? 'DrctDbtTxInf' : 'CdtTrfTxInf'); $xml->startTag('PmtId'); $xml->dataElement('EndToEndId', $transaction->get('end_to_end_id', 35)); $xml->endTag('PmtId'); - $xml->startTag('Amt'); - $xml->startTag('InstdAmt', 'Ccy' => 'EUR'); - $xml->characters($self->_format_amount($transaction->{amount})); - $xml->endTag('InstdAmt'); - $xml->endTag('Amt'); - - $xml->startTag('CdtrAgt'); + if ($is_coll) { + $xml->startTag('InstdAmt', 'Ccy' => 'EUR'); + $xml->characters($self->_format_amount($transaction->{amount})); + $xml->endTag('InstdAmt'); + + $xml->startTag('DrctDbtTx'); + + $xml->startTag('MndtRltdInf'); + $xml->dataElement('MndtId', $transaction->get('reference', 35)); + $xml->dataElement('DtOfSgntr', $transaction->get('reference_date', 2010-12-02)); + $xml->endTag('MndtRltdInf'); + + $xml->startTag('CdtrSchmeId'); + $xml->startTag('Id'); + $xml->startTag('PrvtId'); + $xml->startTag('OthrId'); + $xml->dataElement('Id', encode('UTF-8', substr($self->{creditor_id}, 0, 35))); + $xml->dataElement('IdTp', 'SEPA'); + $xml->endTag('OthrId'); + $xml->endTag('PrvtId'); + $xml->endTag('Id'); + $xml->endTag('CdtrSchmeId'); + + $xml->endTag('DrctDbtTx'); + + } else { + $xml->startTag('Amt'); + $xml->startTag('InstdAmt', 'Ccy' => 'EUR'); + $xml->characters($self->_format_amount($transaction->{amount})); + $xml->endTag('InstdAmt'); + $xml->endTag('Amt'); + } + + $xml->startTag("${cd_dst}Agt"); $xml->startTag('FinInstnId'); $xml->dataElement('BIC', $transaction->get('dst_bic', 20)); $xml->endTag('FinInstnId'); - $xml->endTag('CdtrAgt'); + $xml->endTag("${cd_dst}Agt"); - $xml->startTag('Cdtr'); - $xml->dataElement('Nm', $transaction->get('recipient', 70)); - $xml->endTag('Cdtr'); + $xml->startTag("${cd_dst}"); + $xml->dataElement('Nm', $transaction->get('company', 70)); + $xml->endTag("${cd_dst}"); - $xml->startTag('CdtrAcct'); + $xml->startTag("${cd_dst}Acct"); $xml->startTag('Id'); $xml->dataElement('IBAN', $transaction->get('dst_iban', 34)); $xml->endTag('Id'); - $xml->endTag('CdtrAcct'); + $xml->endTag("${cd_dst}Acct"); $xml->startTag('RmtInf'); $xml->dataElement('Ustrd', $transaction->get('reference', 140)); $xml->endTag('RmtInf'); - $xml->endTag('CdtTrfTxInf'); + $xml->endTag($is_coll ? 'DrctDbtTxInf' : 'CdtTrfTxInf'); } $xml->endTag('PmtInf'); } - $xml->endTag('pain.001.001.02'); + $xml->endTag($pain_elmt); $xml->endTag('Document'); return $output; diff --git a/SL/SEPA/XML/Transaction.pm b/SL/SEPA/XML/Transaction.pm index be444af8b..83a749e37 100644 --- a/SL/SEPA/XML/Transaction.pm +++ b/SL/SEPA/XML/Transaction.pm @@ -25,7 +25,7 @@ sub _init { $self->{sepa} = $params{sepa}; delete $params{sepa}; - my $missing_parameter = first { !$params{$_} } qw(src_iban src_bic dst_iban dst_bic recipient reference amount end_to_end_id); + my $missing_parameter = first { !$params{$_} } qw(src_iban src_bic dst_iban dst_bic company reference amount end_to_end_id); croak "Missing parameter: $missing_parameter" if ($missing_parameter); $params{end_to_end_id} ||= 'NOTPROVIDED'; @@ -35,7 +35,7 @@ sub _init { map { $self->{$_} = $self->{sepa}->{iconv}->convert($params{$_}) } keys %params; map { $self->{$_} =~ s/\s+//g } qw(src_iban src_bic dst_iban dst_bic); - map { $self->{$_} = $self->{sepa}->_replace_special_chars($self->{$_}) } qw(recipient reference end_to_end_id); + map { $self->{$_} = $self->{sepa}->_replace_special_chars($self->{$_}) } qw(company reference end_to_end_id); } sub get { diff --git a/SL/Template/Simple.pm b/SL/Template/Simple.pm index 3baeaac2d..d7a7c3525 100644 --- a/SL/Template/Simple.pm +++ b/SL/Template/Simple.pm @@ -163,6 +163,7 @@ sub _parse_block_if { my $not = $1; my $var = $2; + my $comparison = $3; # Optionaler Match um $4..$8 my $operator_neg = $4; # '=' oder '!' oder undef, wenn kein Vergleich erkannt my $operator_type = $5; # '=' oder '~' für Stringvergleich oder Regex my $quoted_word = $7; # nur gültig, wenn quoted string angegeben (siehe unten); dann "value" aus <%if var == "value" %> @@ -173,7 +174,7 @@ sub _parse_block_if { substr($$contents, 0, length($&)) = ""; my $block; - ($block, $$contents) = $self->find_end($$contents, 0, $var, $not); + ($block, $$contents) = $self->find_end($$contents, 0, "$var $comparison", $not); if (!$block) { $self->{"error"} = "Unclosed $self->{tag_start}if$self->{tag_end}." unless ($self->{"error"}); $main::lxdebug->leave_sub(); diff --git a/SL/User.pm b/SL/User.pm index 46fe85581..b1a904afd 100644 --- a/SL/User.pm +++ b/SL/User.pm @@ -1000,7 +1000,8 @@ sub config_vars { bestellungen rechnungen anfragen lieferantenbestellungen einkaufsrechnungen taxnumber co_ustid duns menustyle template_format default_media default_printer_id copies show_form_details favorites - pdonumber sdonumber hide_cvar_search_options mandatory_departments); + pdonumber sdonumber hide_cvar_search_options mandatory_departments + sepa_creditor_id); $main::lxdebug->leave_sub(); diff --git a/SL/VK.pm b/SL/VK.pm new file mode 100644 index 000000000..458c35158 --- /dev/null +++ b/SL/VK.pm @@ -0,0 +1,114 @@ +#===================================================================== +# LX-Office ERP +# Copyright (C) 2004 +# Based on SQL-Ledger Version 2.1.9 +# Web http://www.lx-office.org +# +#===================================================================== +# SQL-Ledger Accounting +# Copyright (C) 2001 +# +# Author: Dieter Simader +# Email: dsimader@sql-ledger.org +# Web: http://www.sql-ledger.org +# +# Contributors: +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +#====================================================================== +# +# Sold Items report +# +#====================================================================== + +package VK; + +use SL::DBUtils; +use SL::IO; +use SL::MoreCommon; + +use strict; + +sub invoice_transactions { + $main::lxdebug->enter_sub(); + + my ($self, $myconfig, $form) = @_; + + # connect to database + my $dbh = $form->get_standard_dbh($myconfig); + + my @values; + + my $query = + qq|SELECT cus.name,ar.invnumber,ar.id,ar.transdate,p.partnumber,i.parts_id,i.qty,i.price_factor,i.discount,i.description,i.lastcost,i.sellprice,i.marge_total,i.marge_percent,i.unit | . + qq|FROM invoice i | . + qq|join ar on (i.trans_id = ar.id) | . + qq|join parts p on (i.parts_id = p.id) | . + qq|join customer cus on (cus.id = ar.customer_id) |; + + my $where = "1 = 1"; + + # Stornierte Rechnungen und Stornorechnungen in invoice rausfiltern + $where .= " AND ar.storno is not true "; + + my $sortorder = "cus.name,i.parts_id,ar.transdate"; + if ($form->{sortby} eq 'artikelsort') { + $sortorder = "i.parts_id,cus.name,ar.transdate"; + }; + + if ($form->{customer_id}) { + $where .= " AND ar.customer_id = ?"; + push(@values, $form->{customer_id}); + }; + if ($form->{partnumber}) { + $where .= qq| AND (p.partnumber ILIKE ?)|; + push(@values, '%' . $form->{partnumber} . '%'); + } + # nimmt man description am Besten aus invoice oder parts? + if ($form->{description}) { + $where .= qq| AND (i.description ILIKE ?)|; + push(@values, '%' . $form->{description} . '%'); + } + if ($form->{transdatefrom}) { + $where .= " AND ar.transdate >= ?"; + push(@values, $form->{transdatefrom}); + } + if ($form->{transdateto}) { + $where .= " AND ar.transdate <= ?"; + push(@values, $form->{transdateto}); + } + if ($form->{department}) { + my ($null, $department_id) = split /--/, $form->{department}; + $where .= " AND ar.department_id = ?"; + push(@values, $department_id); + } + if ($form->{project_id}) { + $where .= + qq|AND ((ar.globalproject_id = ?) OR EXISTS | . + qq| (SELECT * FROM invoice i | . + qq| WHERE i.project_id = ? AND i.trans_id = ar.id))|; + push(@values, $form->{"project_id"}, $form->{"project_id"}); + } + + $query .= " WHERE $where ORDER BY $sortorder"; + + my @result = selectall_hashref_query($form, $dbh, $query, @values); + + $form->{AR} = [ @result ]; + + $main::lxdebug->leave_sub(); +} + +1; + diff --git a/bin/mozilla/generictranslations.pl b/bin/mozilla/generictranslations.pl index 385ce8094..7b8d4a196 100644 --- a/bin/mozilla/generictranslations.pl +++ b/bin/mozilla/generictranslations.pl @@ -71,4 +71,56 @@ sub save_greetings { $main::lxdebug->leave_sub(); } +sub edit_sepa_strings { + $main::lxdebug->enter_sub(); + + $main::auth->assert('config'); + + my $form = $main::form; + my $locale = $main::locale; + + $form->get_lists('languages' => 'LANGUAGES'); + + my $translation_list = GenericTranslations->list(translation_type => 'sepa_remittance_info_pfx'); + my %translations = map { ( ($_->{language_id} || 'default') => $_->{translation} ) } @{ $translation_list }; + + unshift @{ $form->{LANGUAGES} }, { 'id' => 'default', }; + + foreach my $language (@{ $form->{LANGUAGES} }) { + $language->{translation} = $translations{$language->{id}}; + } + + $form->{title} = $locale->text('Edit SEPA strings'); + $form->header(); + print $form->parse_html_template('generictranslations/edit_sepa_strings'); + + $main::lxdebug->leave_sub(); +} + +sub save_sepa_strings { + $main::lxdebug->enter_sub(); + + $main::auth->assert('config'); + + my $form = $main::form; + my $locale = $main::locale; + + $form->get_lists('languages' => 'LANGUAGES'); + + unshift @{ $form->{LANGUAGES} }, { }; + + foreach my $language (@{ $form->{LANGUAGES} }) { + GenericTranslations->save('translation_type' => 'sepa_remittance_info_pfx', + 'translation_id' => undef, + 'language_id' => $language->{id}, + 'translation' => $form->{"translation__" . ($language->{id} || 'default')},); + } + + $form->{message} = $locale->text('The SEPA strings have been saved.'); + + edit_sepa_strings(); + + $main::lxdebug->leave_sub(); +} + 1; diff --git a/bin/mozilla/sepa.pl b/bin/mozilla/sepa.pl index bf220e380..f6041fbcd 100755 --- a/bin/mozilla/sepa.pl +++ b/bin/mozilla/sepa.pl @@ -8,6 +8,7 @@ use SL::BankAccount; use SL::Chart; use SL::CT; use SL::Form; +use SL::GenericTranslations; use SL::ReportGenerator; use SL::SEPA; use SL::SEPA::XML; @@ -20,8 +21,9 @@ sub bank_transfer_add { my $form = $main::form; my $locale = $main::locale; + my $vc = $form->{vc} eq 'customer' ? 'customer' : 'vendor'; - $form->{title} = $locale->text('Prepare bank transfer via SEPA XML'); + $form->{title} = $vc eq 'customer' ? $::locale->text('Prepare bank collection via SEPA XML') : $locale->text('Prepare bank transfer via SEPA XML'); my $bank_accounts = SL::BankAccount->list(); @@ -29,7 +31,7 @@ sub bank_transfer_add { $form->error($locale->text('You have not added bank accounts yet.')); } - my $invoices = SL::SEPA->retrieve_open_invoices(); + my $invoices = SL::SEPA->retrieve_open_invoices(vc => $vc); if (!scalar @{ $invoices }) { $form->show_generic_information($locale->text('Either there are no open invoices, or you have already initiated bank transfers ' . @@ -40,11 +42,22 @@ sub bank_transfer_add { my $bank_account_label_sub = sub { $locale->text('Account number #1, bank code #2, #3', $_[0]->{account_number}, $_[0]->{bank_code}, $_[0]->{bank}) }; + my $translation_list = GenericTranslations->list(translation_type => 'sepa_remittance_info_pfx'); + my %translations = map { ( ($_->{language_id} || 'default') => $_->{translation} ) } @{ $translation_list }; + + foreach my $invoice (@{ $invoices }) { + my $prefix = $translations{ $invoice->{language_id} } || $translations{default} || $::locale->text('Invoice'); + $prefix .= ' ' unless $prefix =~ m/ $/; + $invoice->{reference_prefix} = $prefix; + } + $form->header(); print $form->parse_html_template('sepa/bank_transfer_add', { 'INVOICES' => $invoices, 'BANK_ACCOUNTS' => $bank_accounts, - 'bank_account_label' => $bank_account_label_sub, }); + 'bank_account_label' => $bank_account_label_sub, + 'vc' => $vc, + }); $main::lxdebug->leave_sub(); } @@ -55,8 +68,9 @@ sub bank_transfer_create { my $form = $main::form; my $locale = $main::locale; my $myconfig = \%main::myconfig; + my $vc = $form->{vc} eq 'customer' ? 'customer' : 'vendor'; - $form->{title} = $locale->text('Create bank transfer via SEPA XML'); + $form->{title} = $vc eq 'customer' ? $::locale->text('Create bank collection via SEPA XML') : $locale->text('Create bank transfer via SEPA XML'); my $bank_accounts = SL::BankAccount->list(); @@ -70,11 +84,13 @@ sub bank_transfer_create { $form->error($locale->text('The selected bank account does not exist anymore.')); } - my $invoices = SL::SEPA->retrieve_open_invoices(); + my $arap_id = $vc eq 'customer' ? 'ar_id' : 'ap_id'; + my $invoices = SL::SEPA->retrieve_open_invoices(vc => $vc); + my %invoices_map = map { $_->{id} => $_ } @{ $invoices }; my @bank_transfers = - map +{ %{ $invoices_map{ $_->{ap_id} } }, %{ $_ } }, - grep { $_->{selected} && (0 < $_->{amount}) && $invoices_map{ $_->{ap_id} } } + map +{ %{ $invoices_map{ $_->{$arap_id} } }, %{ $_ } }, + grep { $_->{selected} && (0 < $_->{amount}) && $invoices_map{ $_->{$arap_id} } } map { $_->{amount} = $form->parse_amount($myconfig, $_->{amount}); $_ } @{ $form->{bank_transfers} || [] }; @@ -82,13 +98,13 @@ sub bank_transfer_create { $form->error($locale->text('You have selected none of the invoices.')); } - my ($vendor_bank_info); + my ($vc_bank_info); my $error_message; if ($form->{confirmation}) { - $vendor_bank_info = { map { $_->{id} => $_ } @{ $form->{vendor_bank_info} || [] } }; + $vc_bank_info = { map { $_->{id} => $_ } @{ $form->{vc_bank_info} || [] } }; - foreach my $info (values %{ $vendor_bank_info }) { + foreach my $info (values %{ $vc_bank_info }) { if (any { !$info->{$_} } qw(iban bic)) { $error_message = $locale->text('The bank information must not be empty.'); last; @@ -97,10 +113,10 @@ sub bank_transfer_create { } if ($error_message || !$form->{confirmation}) { - my @vendor_ids = uniq map { $_->{vendor_id} } @bank_transfers; - $vendor_bank_info ||= CT->get_bank_info('vc' => 'vendor', - 'id' => \@vendor_ids); - my @vendor_bank_info = sort { lc $a->{name} cmp lc $b->{name} } values %{ $vendor_bank_info }; + my @vc_ids = uniq map { $_->{"${vc}_id"} } @bank_transfers; + $vc_bank_info ||= CT->get_bank_info('vc' => $vc, + 'id' => \@vc_ids); + my @vc_bank_info = sort { lc $a->{name} cmp lc $b->{name} } values %{ $vc_bank_info }; my $bank_account_label_sub = sub { $locale->text('Account number #1, bank code #2, #3', $_[0]->{account_number}, $_[0]->{bank_code}, $_[0]->{bank}) }; @@ -110,27 +126,29 @@ sub bank_transfer_create { print $form->parse_html_template('sepa/bank_transfer_create', { 'BANK_TRANSFERS' => \@bank_transfers, 'BANK_ACCOUNTS' => $bank_accounts, - 'VENDOR_BANK_INFO' => \@vendor_bank_info, + 'VC_BANK_INFO' => \@vc_bank_info, 'bank_account' => $bank_account, 'bank_account_label' => $bank_account_label_sub, 'error_message' => $error_message, + 'vc' => $vc, }); } else { foreach my $bank_transfer (@bank_transfers) { foreach (qw(iban bic)) { - $bank_transfer->{"vendor_${_}"} = $vendor_bank_info->{ $bank_transfer->{vendor_id} }->{$_}; - $bank_transfer->{"our_${_}"} = $bank_account->{$_}; + $bank_transfer->{"vc_${_}"} = $vc_bank_info->{ $bank_transfer->{"${vc}_id"} }->{$_}; + $bank_transfer->{"our_${_}"} = $bank_account->{$_}; } $bank_transfer->{chart_id} = $bank_account->{chart_id}; } my $id = SL::SEPA->create_export('employee' => $form->{login}, - 'bank_transfers' => \@bank_transfers); + 'bank_transfers' => \@bank_transfers, + 'vc' => $vc); $form->header(); - print $form->parse_html_template('sepa/bank_transfer_created', { 'id' => $id }); + print $form->parse_html_template('sepa/bank_transfer_created', { 'id' => $id, 'vc' => $vc }); } $main::lxdebug->leave_sub(); @@ -141,12 +159,13 @@ sub bank_transfer_search { my $form = $main::form; my $locale = $main::locale; + my $vc = $form->{vc} eq 'customer' ? 'customer' : 'vendor'; - $form->{title} = $locale->text('List of bank transfers'); + $form->{title} = $vc eq 'customer' ? $::locale->text('List of bank collections') : $locale->text('List of bank transfers'); $form->{jsscript} = 1; $form->header(); - print $form->parse_html_template('sepa/bank_transfer_search'); + print $form->parse_html_template('sepa/bank_transfer_search', { vc => $vc }); $main::lxdebug->leave_sub(); } @@ -158,17 +177,18 @@ sub bank_transfer_list { my $form = $main::form; my $locale = $main::locale; my $cgi = $main::cgi; + my $vc = $form->{vc} eq 'customer' ? 'customer' : 'vendor'; - $form->{title} = $locale->text('List of bank transfers'); + $form->{title} = $vc eq 'customer' ? $::locale->text('List of bank collections') : $locale->text('List of bank transfers'); $form->{sort} ||= 'id'; $form->{sortdir} = '1' if (!defined $form->{sortdir}); - $form->{callback} = build_std_url('action=bank_transfer_list', 'sort', 'sortdir'); + $form->{callback} = build_std_url('action=bank_transfer_list', 'sort', 'sortdir', 'vc'); my %filter = map +( $_ => $form->{"f_${_}"} ), grep { $form->{"f_${_}"} } - (qw(vendor invnumber), + (qw(vc invnumber), map { ("${_}_date_from", "${_}_date_to") } qw(export requested_execution execution)); $filter{executed} = $form->{l_executed} ? 1 : 0 if ($form->{l_executed} != $form->{l_not_executed}); @@ -176,13 +196,14 @@ sub bank_transfer_list { my $exports = SL::SEPA->list_exports('filter' => \%filter, 'sortorder' => $form->{sort}, - 'sortdir' => $form->{sortdir}); + 'sortdir' => $form->{sortdir}, + 'vc' => $vc); my $open_available = any { !$_->{closed} } @{ $exports }; my $report = SL::ReportGenerator->new(\%main::myconfig, $form); - my @hidden_vars = grep { m/^[fl]_/ && $form->{$_} } keys %{ $form }; + my @hidden_vars = ('vc', grep { m/^[fl]_/ && $form->{$_} } keys %{ $form }); my $href = build_std_url('action=bank_transfer_list', @hidden_vars); @@ -202,12 +223,12 @@ sub bank_transfer_list { $column_defs{$name}->{link} = $href . "&sort=$name&sortdir=$sortdir"; } - $column_defs{selected}->{visible} = $open_available ? 1 : 0; + $column_defs{selected}->{visible} = $open_available ? 'HTML' : 0; $column_defs{executed}->{visible} = $form->{l_executed} && $form->{l_not_executed} ? 1 : 0; $column_defs{closed}->{visible} = $form->{l_closed} && $form->{l_open} ? 1 : 0; my @options = (); - push @options, $locale->text('Vendor') . ' : ' . $form->{f_vendor} if ($form->{f_vendor}); + push @options, ($vc eq 'customer' ? $::locale->text('Customer') : $locale->text('Vendor')) . ' : ' . $form->{f_vc} if ($form->{f_vc}); push @options, $locale->text('Invoice number') . ' : ' . $form->{f_invnumber} if ($form->{f_invnumber}); push @options, $locale->text('Export date from') . ' : ' . $form->{f_export_date_from} if ($form->{f_export_date_from}); push @options, $locale->text('Export date to') . ' : ' . $form->{f_export_date_to} if ($form->{f_export_date_to}); @@ -220,7 +241,7 @@ sub bank_transfer_list { $report->set_options('top_info_text' => join("\n", @options), 'raw_top_info_text' => $form->parse_html_template('sepa/bank_transfer_list_top'), - 'raw_bottom_info_text' => $form->parse_html_template('sepa/bank_transfer_list_bottom', { 'show_buttons' => $open_available }), + 'raw_bottom_info_text' => $form->parse_html_template('sepa/bank_transfer_list_bottom', { 'show_buttons' => $open_available, vc => $vc }), 'std_column_visibility' => 1, 'output_format' => 'HTML', 'title' => $form->{title}, @@ -240,7 +261,7 @@ sub bank_transfer_list { map { $row->{$_}->{data} = $export->{$_} ? $locale->text('yes') : $locale->text('no') } qw(executed closed); - $row->{id}->{link} = $edit_url . '&id=' . E($export->{id}); + $row->{id}->{link} = $edit_url . '&id=' . E($export->{id}) . '&vc=' . E($vc); if (!$export->{closed}) { $row->{selected}->{raw_data} = @@ -261,6 +282,7 @@ sub bank_transfer_edit { my $form = $main::form; my $locale = $main::locale; + my $vc = $form->{vc} eq 'customer' ? 'customer' : 'vendor'; my @ids = (); if (!$form->{mode} || ($form->{mode} eq 'single')) { @@ -276,7 +298,7 @@ sub bank_transfer_edit { my $export; foreach my $id (@ids) { - my $curr_export = SL::SEPA->retrieve_export('id' => $id, 'details' => 1); + my $curr_export = SL::SEPA->retrieve_export('id' => $id, 'details' => 1, 'vc' => $vc); foreach my $item (@{ $curr_export->{items} }) { map { $item->{"export_${_}"} = $curr_export->{$_} } grep { !ref $curr_export->{$_} } keys %{ $curr_export }; @@ -318,6 +340,7 @@ sub bank_transfer_post_payments { my $form = $main::form; my $locale = $main::locale; + my $vc = $form->{vc} eq 'customer' ? 'customer' : 'vendor'; my @items = grep { $_->{selected} } @{ $form->{items} || [] }; @@ -325,7 +348,7 @@ sub bank_transfer_post_payments { $form->show_generic_error($locale->text('You have not selected any item.'), 'back_button' => 1); } my @export_ids = uniq map { $_->{sepa_export_id} } @items; - my %exports = map { $_ => SL::SEPA->retrieve_export('id' => $_, 'details' => 1) } @export_ids; + my %exports = map { $_ => SL::SEPA->retrieve_export('id' => $_, 'details' => 1, vc => $vc) } @export_ids; my @items_to_post = (); foreach my $item (@items) { @@ -343,7 +366,7 @@ sub bank_transfer_post_payments { $form->show_generic_error($locale->text('You have to specify an execution date for each antry.'), 'back_button' => 1); } - SL::SEPA->post_payment('items' => \@items_to_post); + SL::SEPA->post_payment('items' => \@items_to_post, vc => $vc); $form->show_generic_information($locale->text('The payments have been posted.')); @@ -356,13 +379,14 @@ sub bank_transfer_payment_list_as_pdf { my $form = $main::form; my %myconfig = %main::myconfig; my $locale = $main::locale; + my $vc = $form->{vc} eq 'customer' ? 'customer' : 'vendor'; my @ids = @{ $form->{items} || [] }; my @export_ids = uniq map { $_->{export_id} } @ids; $form->show_generic_error($locale->text('Multi mode not supported.'), 'back_button' => 1) if 1 != scalar @export_ids; - my $export = SL::SEPA->retrieve_export('id' => $export_ids[0], 'details' => 1); + my $export = SL::SEPA->retrieve_export('id' => $export_ids[0], 'details' => 1, vc => $vc); my @items = (); foreach my $id (@ids) { @@ -375,25 +399,25 @@ sub bank_transfer_payment_list_as_pdf { my $report = SL::ReportGenerator->new(\%main::myconfig, $form); my %column_defs = ( - 'invnumber' => { 'text' => $locale->text('Invoice'), }, - 'vendor_name' => { 'text' => $locale->text('Vendor'), }, - 'our_iban' => { 'text' => $locale->text('Source IBAN'), }, - 'our_bic' => { 'text' => $locale->text('Source BIC'), }, - 'vendor_iban' => { 'text' => $locale->text('Destination IBAN'), }, - 'vendor_bic' => { 'text' => $locale->text('Destination BIC'), }, - 'amount' => { 'text' => $locale->text('Amount'), }, - 'reference' => { 'text' => $locale->text('Reference'), }, - 'execution_date' => { 'text' => $locale->text('Execution date'), }, + 'invnumber' => { 'text' => $locale->text('Invoice'), }, + 'vc_name' => { 'text' => $vc eq 'customer' ? $locale->text('Customer') : $locale->text('Vendor'), }, + 'our_iban' => { 'text' => $vc eq 'customer' ? $locale->text('Destination IBAN') : $locale->text('Source IBAN'), }, + 'our_bic' => { 'text' => $vc eq 'customer' ? $locale->text('Destination BIC') : $locale->text('Source BIC'), }, + 'vc_iban' => { 'text' => $vc eq 'customer' ? $locale->text('Source IBAN') : $locale->text('Destination IBAN'), }, + 'vc_bic' => { 'text' => $vc eq 'customer' ? $locale->text('Source BIC') : $locale->text('Destination BIC'), }, + 'amount' => { 'text' => $locale->text('Amount'), }, + 'reference' => { 'text' => $locale->text('Reference'), }, + 'execution_date' => { 'text' => $locale->text('Execution date'), }, ); map { $column_defs{$_}->{align} = 'right' } qw(amount execution_date); - my @columns = qw(invnumber vendor_name our_iban our_bic vendor_iban vendor_bic amount reference execution_date); + my @columns = qw(invnumber vc_name our_iban our_bic vc_iban vc_bic amount reference execution_date); $report->set_options('std_column_visibility' => 1, 'output_format' => 'PDF', - 'title' => $locale->text('Bank transfer payment list for export #1', $export->{id}), - 'attachment_basename' => $locale->text('bank_transfer_payment_list_#1', $export->{id}) . strftime('_%Y%m%d', localtime time), + 'title' => $vc eq 'customer' ? $locale->text('Bank collection payment list for export #1', $export->{id}) : $locale->text('Bank transfer payment list for export #1', $export->{id}), + 'attachment_basename' => ($vc eq 'customer' ? $locale->text('bank_collection_payment_list_#1', $export->{id}) : $locale->text('bank_transfer_payment_list_#1', $export->{id})) . strftime('_%Y%m%d', localtime time), ); $report->set_columns(%column_defs); @@ -411,6 +435,7 @@ sub bank_transfer_payment_list_as_pdf { $main::lxdebug->leave_sub(); } +# TODO sub bank_transfer_download_sepa_xml { $main::lxdebug->enter_sub(); @@ -418,11 +443,16 @@ sub bank_transfer_download_sepa_xml { my $myconfig = \%main::myconfig; my $locale = $main::locale; my $cgi = $main::cgi; + my $vc = $form->{vc} eq 'customer' ? 'customer' : 'vendor'; if (!$myconfig->{company}) { $form->show_generic_error($locale->text('You have to enter a company name in your user preferences (see the "Program" menu, "Preferences").'), 'back_button' => 1); } + if (($vc eq 'customer') && !$myconfig->{sepa_creditor_id}) { + $form->show_generic_error($locale->text('You have to enter the SEPA creditor ID in your user preferences (see the "Program" menu, "Preferences").'), 'back_button' => 1); + } + my @ids; if ($form->{mode} && ($form->{mode} eq 'multi')) { @ids = map $_->{id}, grep { $_->{selected} } @{ $form->{exports} || [] }; @@ -438,7 +468,7 @@ sub bank_transfer_download_sepa_xml { my @items = (); foreach my $id (@ids) { - my $export = SL::SEPA->retrieve_export('id' => $id, 'details' => 1); + my $export = SL::SEPA->retrieve_export('id' => $id, 'details' => 1, vc => $vc); push @items, grep { !$_->{executed} } @{ $export->{items} } if ($export && !$export->{closed}); } @@ -449,9 +479,11 @@ sub bank_transfer_download_sepa_xml { my $message_id = strftime('MSG%Y%m%d%H%M%S', localtime) . sprintf('%06d', $$); my $sepa_xml = SL::SEPA::XML->new('company' => $myconfig->{company}, + 'creditor_id' => $myconfig->{sepa_creditor_id}, 'src_charset' => $main::dbcharset || 'ISO-8859-15', 'message_id' => $message_id, 'grouped' => 1, + 'collection' => $vc eq 'customer', ); foreach my $item (@items) { @@ -461,13 +493,19 @@ sub bank_transfer_download_sepa_xml { $requested_execution_date = sprintf '%04d-%02d-%02d', $yy, $mm, $dd; } + if ($vc eq 'customer') { + my ($yy, $mm, $dd) = $locale->parse_date($myconfig, $item->{reference_date}); + $item->{reference_date} = sprintf '%04d-%02d-%02d', $yy, $mm, $dd; + } + $sepa_xml->add_transaction({ 'src_iban' => $item->{our_iban}, 'src_bic' => $item->{our_bic}, - 'dst_iban' => $item->{vendor_iban}, - 'dst_bic' => $item->{vendor_bic}, - 'recipient' => $item->{vendor_name}, + 'dst_iban' => $item->{vc_iban}, + 'dst_bic' => $item->{vc_bic}, + 'company' => $item->{vc_name}, 'amount' => $item->{amount}, 'reference' => $item->{reference}, + 'reference_date' => $item->{reference_date}, 'execution_date' => $requested_execution_date, 'end_to_end_id' => $item->{end_to_end_id} }); } @@ -475,7 +513,7 @@ sub bank_transfer_download_sepa_xml { my $xml = $sepa_xml->to_xml(); print $cgi->header('-type' => 'application/octet-stream', - '-content-disposition' => 'attachment; filename="SEPA_' . $message_id . '.cct"', + '-content-disposition' => 'attachment; filename="SEPA_' . $message_id . ($vc eq 'customer' ? '.cdd' : '.cct') . '"', '-content-length' => length $xml); print $xml; @@ -487,6 +525,7 @@ sub bank_transfer_mark_as_closed_step1 { my $form = $main::form; my $locale = $main::locale; + my $vc = $form->{vc} eq 'customer' ? 'customer' : 'vendor'; my @export_ids = map { $_->{id} } grep { $_->{selected} } @{ $form->{exports} || [] }; @@ -496,7 +535,7 @@ sub bank_transfer_mark_as_closed_step1 { my @open_export_ids = (); foreach my $id (@export_ids) { - my $export = SL::SEPA->retrieve_export('id' => $id); + my $export = SL::SEPA->retrieve_export('id' => $id, vc => $vc); push @open_export_ids, $id if (!$export->{closed}); } @@ -506,7 +545,7 @@ sub bank_transfer_mark_as_closed_step1 { $form->{title} = $locale->text('Close SEPA exports'); $form->header(); - print $form->parse_html_template('sepa/bank_transfer_mark_as_closed_step1', { 'OPEN_EXPORT_IDS' => \@open_export_ids }); + print $form->parse_html_template('sepa/bank_transfer_mark_as_closed_step1', { 'OPEN_EXPORT_IDS' => \@open_export_ids, vc => $vc }); $main::lxdebug->leave_sub(); } diff --git a/bin/mozilla/vk.pl b/bin/mozilla/vk.pl new file mode 100644 index 000000000..dbbc2bdc5 --- /dev/null +++ b/bin/mozilla/vk.pl @@ -0,0 +1,392 @@ +#===================================================================== +# LX-Office ERP +# Copyright (C) 2004 +# Based on SQL-Ledger Version 2.1.9 +# Web http://www.lx-office.org +# +#===================================================================== +# SQL-Ledger Accounting +# Copyright (c) 2001 +# +# Author: Dieter Simader +# Email: dsimader@sql-ledger.org +# Web: http://www.sql-ledger.org +# +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +#====================================================================== +# +# Sales report +# +#====================================================================== + +use POSIX qw(strftime); +use List::Util qw(sum first); + +use SL::VK; +use SL::ReportGenerator; +use Data::Dumper; + +require "bin/mozilla/arap.pl"; +require "bin/mozilla/common.pl"; +require "bin/mozilla/drafts.pl"; +require "bin/mozilla/reportgenerator.pl"; + +use strict; + + +sub search_invoice { + $main::lxdebug->enter_sub(); + $main::auth->assert('general_ledger | invoice_edit'); + + my $form = $main::form; + my %myconfig = %main::myconfig; + my $locale = $main::locale; + my $cgi = $main::cgi; + + my ($customer, $department); + + # setup customer selection + $form->all_vc(\%myconfig, "customer", "AR"); + + $form->{title} = $locale->text('Sales Report'); + $form->{jsscript} = 1; + + $form->get_lists("projects" => { "key" => "ALL_PROJECTS", "all" => 1 }, + "departments" => "ALL_DEPARTMENTS", + "customers" => "ALL_VC"); + + $form->{vc_keys} = sub { "$_[0]->{name}--$_[0]->{id}" }; + + $form->header; + print $form->parse_html_template('vk/search_invoice', { %myconfig }); + + $main::lxdebug->leave_sub(); +} + +sub invoice_transactions { + $main::lxdebug->enter_sub(); + + $main::auth->assert('general_ledger | invoice_edit'); + + my $form = $main::form; + my %myconfig = %main::myconfig; + my $locale = $main::locale; + + my ($callback, $href, @columns); + + $form->{customer} = $form->unescape($form->{customer}); + + ($form->{customername}, $form->{customer_id}) = split(/--/, $form->{customer}); + + # decimalplaces überprüfen oder auf Default 2 setzen + $form->{decimalplaces} = 2 unless $form->{decimalplaces} > 0 && $form->{decimalplaces} < 6; + +# report_generator_set_default_sort('transdate', 1); + + VK->invoice_transactions(\%myconfig, \%$form); + + # anhand von radio button die Sortierreihenfolge festlegen + if ($form->{sortby} eq 'artikelsort') { + $form->{'mainsort'} = 'parts_id'; + $form->{'subsort'} = 'name'; + } else { + $form->{'mainsort'} = 'name'; + $form->{'subsort'} = 'parts_id'; + }; + + $form->{title} = $locale->text('Sales Report'); + + @columns = + qw(description invnumber partnumber parts_id transdate qty unit sellprice sellprice_total discount lastcost lastcost_total marge_total marge_percent); + + # hidden variables für pdf/csv export übergeben + # einmal mit l_ um zu bestimmen welche Spalten ausgegeben werden sollen + # einmal optionen für die Überschrift (z.B. transdatefrom, partnumber, ...) + my @hidden_variables = (qw(l_headers l_subtotal l_total transdatefrom transdateto decimalplaces customer customername customer_id department partnumber description project_id), "$form->{db}number", map { "l_$_" } @columns); + my @hidden_nondefault = grep({ $form->{$_} } @hidden_variables); + # Variablen werden dann als Hidden Variable mitgegeben, z.B. + # + + $href = build_std_url('action=invoice_transactions', grep { $form->{$_} } @hidden_variables); + # href = vk.pl?action=invoice_transactions&l_headers=Y&l_subtotal=Y&l_total=Y&transdatefrom=04.03.2010 ... + + my %column_defs = ( + 'description' => { 'text' => $locale->text('Description'), }, + 'partnumber' => { 'text' => $locale->text('Part Number'), }, + 'invnumber' => { 'text' => $locale->text('Invoice Number'), }, + 'transdate' => { 'text' => $locale->text('Invoice Date'), }, + 'qty' => { 'text' => $locale->text('Quantity'), }, + 'unit' => { 'text' => $locale->text('Unit'), }, + 'sellprice' => { 'text' => $locale->text('Sales price'), }, + 'sellprice_total' => { 'text' => $locale->text('Sales net amount'), }, + 'lastcost_total' => { 'text' => $locale->text('Purchase net amount'), }, + 'discount' => { 'text' => $locale->text('Discount'), }, + 'lastcost' => { 'text' => $locale->text('Purchase price'), }, + 'marge_total' => { 'text' => $locale->text('Sales margin'), }, + 'marge_percent' => { 'text' => $locale->text('Sales margin %'), }, + ); + + my %column_alignment = map { $_ => 'right' } qw(lastcost sellprice sellprice_total lastcost_total unit discount marge_total marge_percent qty); + + $form->{"l_type"} = "Y"; + map { $column_defs{$_}->{visible} = $form->{"l_${_}"} ? 1 : 0 } @columns; + + + my @options; + if ($form->{description}) { + push @options, $locale->text('description') . " : $form->{description}"; + } + if ($form->{customer}) { + push @options, $locale->text('Customer') . " : $form->{customername}"; + } + if ($form->{department}) { + my ($department) = split /--/, $form->{department}; + push @options, $locale->text('Department') . " : $department"; + } + if ($form->{invnumber}) { + push @options, $locale->text('Invoice Number') . " : $form->{invnumber}"; + } + if ($form->{invdate}) { + push @options, $locale->text('Invoice Date') . " : $form->{invdate}"; + } + if ($form->{partnumber}) { + push @options, $locale->text('Part Number') . " : $form->{partnumber}"; + } + if ($form->{ordnumber}) { + push @options, $locale->text('Order Number') . " : $form->{ordnumber}"; + } + if ($form->{notes}) { + push @options, $locale->text('Notes') . " : $form->{notes}"; + } + if ($form->{transaction_description}) { + push @options, $locale->text('Transaction description') . " : $form->{transaction_description}"; + } + if ($form->{transdatefrom}) { + push @options, $locale->text('From') . " " . $locale->date(\%myconfig, $form->{transdatefrom}, 1); + } + if ($form->{transdateto}) { + push @options, $locale->text('Bis') . " " . $locale->date(\%myconfig, $form->{transdateto}, 1); + } + + my $report = SL::ReportGenerator->new(\%myconfig, $form); + + $report->set_options('top_info_text' => join("\n", @options), + 'output_format' => 'HTML', + 'title' => $form->{title}, + 'attachment_basename' => $locale->text('sales_report') . strftime('_%Y%m%d', localtime time), + ); + $report->set_options_from_form(); + + $report->set_columns(%column_defs); + $report->set_column_order(@columns); + + $report->set_export_options('invoice_transactions', @hidden_variables, qw(mainsort sortdir)); + + $report->set_sort_indicator($form->{mainsort}, $form->{sortdir}); + + # add sort and escape callback, this one we use for the add sub + $form->{callback} = $href .= "&sort=$form->{mainsort}"; + + # escape callback for href + $callback = $form->escape($href); + + my @subtotal_columns = qw(qty sellprice sellprice_total lastcost lastcost_total marge_total marge_percent discount); + # Gesamtsumme: + # Summe von sellprice_total, lastcost_total und marge_total + # Durchschnitt von marge_percent + my @total_columns = qw(sellprice_total lastcost_total marge_total marge_percent ); + + my %totals = map { $_ => 0 } @total_columns; + my %subtotals1 = map { $_ => 0 } @subtotal_columns; + my %subtotals2 = map { $_ => 0 } @subtotal_columns; + + my $idx = 0; + + foreach my $ar (@{ $form->{AR} }) { + + $ar->{price_factor} = 1 unless $ar->{price_factor}; + # calculate individual sellprice + # discount was already accounted for in db sellprice + $ar->{sellprice} = $ar->{sellprice} / $ar->{price_factor}; + $ar->{lastcost} = $ar->{lastcost} / $ar->{price_factor}; + $ar->{sellprice_total} = $ar->{qty} * $ar->{sellprice}; + $ar->{lastcost_total} = $ar->{qty} * $ar->{lastcost}; + # marge_percent wird neu berechnet, da Wert in invoice leer ist (Bug) + $ar->{marge_percent} = $ar->{sellprice_total} ? (($ar->{sellprice_total}-$ar->{lastcost_total}) / $ar->{sellprice_total}) : 0; + # marge_total neu berechnen + $ar->{marge_total} = $ar->{sellprice_total} ? $ar->{sellprice_total}-$ar->{lastcost_total} : 0; + $ar->{discount} *= 100; # für Ausgabe formatieren, 10% stored as 0.1 in db + + # Anfangshauptüberschrift + if ( $form->{l_headers} eq "Y" && ( $idx == 0 or $ar->{ $form->{'mainsort'} } ne $form->{AR}->[$idx - 1]->{ $form->{'mainsort'} } )) { + my $name; + my $headerrow; + if ( $form->{mainsort} eq 'parts_id' ) { + $headerrow->{description}->{data} = "$ar->{description}"; + } else { + $headerrow->{description}->{data} = "$ar->{name}"; + }; + $headerrow->{description}->{class} = "listmainsortheader"; + my $headerrow_set = [ $headerrow ]; + $report->add_data($headerrow_set); + + # add empty row after main header +# my $emptyheaderrow->{description}->{data} = ""; +# $emptyheaderrow->{description}->{class} = "listmainsortheader"; +# my $emptyheaderrow_set = [ $emptyheaderrow ]; +# $report->add_data($emptyheaderrow_set) if $form->{l_headers} eq "Y"; + }; + + # subsort überschriften + if ( $idx == 0 + or $ar->{ $form->{'subsort'} } ne $form->{AR}->[$idx - 1]->{ $form->{'subsort'} } + or $ar->{ $form->{'mainsort'} } ne $form->{AR}->[$idx - 1]->{ $form->{'mainsort'} } + ) { + my $headerrow; + my $name; + if ( $form->{subsort} eq 'parts_id' ) { + $name = 'description'; + $headerrow->{description}->{data} = "$ar->{$name}"; + } else { + $name = 'name'; + $headerrow->{description}->{data} = "$ar->{$name}"; + }; + $headerrow->{description}->{class} = "listsubsortheader"; + my $headerrow_set = [ $headerrow ]; + $report->add_data($headerrow_set) if $form->{l_headers} eq "Y"; + }; + + map { $subtotals1{$_} += $ar->{$_}; + $subtotals2{$_} += $ar->{$_}; + } @subtotal_columns; + + map { $totals{$_} += $ar->{$_} } @total_columns; + + $subtotals2{sellprice} = $subtotals2{sellprice_total} / $subtotals2{qty} if $subtotals2{qty} != 0; + $subtotals1{sellprice} = $subtotals1{sellprice_total} / $subtotals1{qty} if $subtotals1{qty} != 0; + $subtotals2{lastcost} = $subtotals2{lastcost_total} / $subtotals2{qty} if $subtotals2{qty} != 0; + $subtotals1{lastcost} = $subtotals1{lastcost_total} / $subtotals1{qty} if $subtotals1{qty} != 0; + + # Ertrag prozentual in den Summen: (summe VK - summe Ertrag) / summe VK + $subtotals1{marge_percent} = $subtotals1{sellprice_total} ? (($subtotals1{sellprice_total} - $subtotals1{lastcost_total}) / $subtotals1{sellprice_total}) : 0; + $subtotals2{marge_percent} = $subtotals2{sellprice_total} ? (($subtotals2{sellprice_total} - $subtotals2{lastcost_total}) / $subtotals2{sellprice_total}) : 0; + + # Ertrag prozentual: (Summe VK betrag - Summe EK betrag) / Summe VK betrag + # wird laufend bei jeder Position neu berechnet + $totals{marge_percent} = $totals{sellprice_total} ? ( ($totals{sellprice_total} - $totals{lastcost_total}) / $totals{sellprice_total} ) : 0; + + map { $ar->{$_} = $form->format_amount(\%myconfig, $ar->{$_}, 2) } qw(marge_total marge_percent); + map { $ar->{$_} = $form->format_amount(\%myconfig, $ar->{$_}, $form->{"decimalplaces"} )} qw(lastcost sellprice sellprice_total lastcost_total); + + my $row = { }; + + foreach my $column (@columns) { + $row->{$column} = { + 'data' => $ar->{$column}, + 'align' => $column_alignment{$column}, + }; + } + + $row->{description}->{class} = 'listsortdescription'; + + $row->{invnumber}->{link} = build_std_url("script=is.pl", 'action=edit') + . "&id=" . E($ar->{id}) . "&callback=${callback}"; + + my $row_set = [ $row ]; + + if (($form->{l_subtotal} eq 'Y') + && (($idx == (scalar @{ $form->{AR} } - 1)) # last element always has a subtotal + || ($ar->{ $form->{'subsort'} } ne $form->{AR}->[$idx + 1]->{ $form->{'subsort'} }) + || ($ar->{ $form->{'mainsort'} } ne $form->{AR}->[$idx + 1]->{ $form->{'mainsort'} }) + )) { # if value that is sorted by changes, print subtotal + my $name; + if ( $form->{subsort} eq 'parts_id' ) { + $name = 'description'; + } else { + $name = 'name'; + }; + + if ($form->{l_subtotal} eq 'Y' ) { + push @{ $row_set }, create_subtotal_row_invoice(\%subtotals2, \@columns, \%column_alignment, \@subtotal_columns, 'listsubsortsubtotal', $ar->{$name}) ; + push @{ $row_set }, insert_empty_row(); + }; + } + + # if mainsort has changed, add mainsort subtotal and empty row + if (($form->{l_subtotal} eq 'Y') + && (($idx == (scalar @{ $form->{AR} } - 1)) # last element always has a subtotal + || ($ar->{ $form->{'mainsort'} } ne $form->{AR}->[$idx + 1]->{ $form->{'mainsort'} }) + )) { # if value that is sorted by changes, print subtotal + my $name; + if ( $form->{mainsort} eq 'parts_id' ) { + $name = 'description'; + } else { + $name = 'name'; + }; + if ($form->{l_subtotal} eq 'Y' ) { + push @{ $row_set }, create_subtotal_row_invoice(\%subtotals1, \@columns, \%column_alignment, \@subtotal_columns, 'listmainsortsubtotal', $ar->{$name}); + push @{ $row_set }, insert_empty_row(); + }; + } + + $report->add_data($row_set); + + $idx++; + } + if ( $form->{l_total} eq "Y" ) { + $report->add_separator(); + $report->add_data(create_subtotal_row_invoice(\%totals, \@columns, \%column_alignment, \@total_columns, 'listtotal')) + }; + + $report->generate_with_headers(); + $main::lxdebug->leave_sub(); +} + + +sub insert_empty_row { + my $dummyrow; + $dummyrow->{description}->{data} = ""; + my $dummyrowset = [ $dummyrow ]; + return $dummyrow; +}; + + + +sub create_subtotal_row_invoice { + $main::lxdebug->enter_sub(); + + my ($totals, $columns, $column_alignment, $subtotal_columns, $class, $name) = @_; + + my $form = $main::form; + my %myconfig = %main::myconfig; + + my $row = { map { $_ => { 'data' => '', 'class' => $class, 'align' => $column_alignment->{$_}, } } @{ $columns } }; + + $row->{description}->{data} = "Summe " . $name; + + map { $row->{$_}->{data} = $form->format_amount(\%myconfig, $totals->{$_}, 2) } qw(marge_total marge_percent); + map { $row->{$_}->{data} = $form->format_amount(\%myconfig, $totals->{$_}, 0) } qw(qty); + map { $row->{$_}->{data} = $form->format_amount(\%myconfig, $totals->{$_}, $form->{decimalplaces}) } qw(lastcost sellprice sellprice_total lastcost_total); + + + map { $totals->{$_} = 0 } @{ $subtotal_columns }; + + $main::lxdebug->leave_sub(); + + return $row; +} + +1; + diff --git a/css/lx-office-erp.css b/css/lx-office-erp.css index 404c76725..8d09f8e96 100644 --- a/css/lx-office-erp.css +++ b/css/lx-office-erp.css @@ -211,6 +211,14 @@ body.menu { .listtotal, .listtotal td { font-size: 8pt; background-color: rgb(236,233,216); color: black; font-weight: bolder;} +/* Verkaufsbericht */ +.listmainsortheader { font-size: 8pt; background-color: rgb(236,233,216); color: red; font-weight: bolder; padding-left: 10px; padding-top: 0px;} +.listmainsortsubtotal { font-size: 8pt; background-color: rgb(236,233,216); color: red; font-weight: bolder; padding-left: 10px;} +.listsubsortheader { font-size: 8pt; background-color: rgb(236,233,216); color: green; font-weight: bolder; padding-left: 20px} +.listsubsortsubtotal { font-size: 8pt; background-color: rgb(236,233,216); color: green; font-weight: bolder; padding-left: 20px} +.listsortdescription { font-size: 8pt; background-color: rgb(236,233,216); color: black; font-weight: normal; padding-left: 30px} + + .submit { font-family: Verdana, Arial, Helvetica; color: #000000; diff --git a/doc/changelog b/doc/changelog index 757c00661..e3acfd403 100644 --- a/doc/changelog +++ b/doc/changelog @@ -21,6 +21,7 @@ - Ansprechpartner für abweichende Lieferadresse, um das Attribut Geschlecht erweitert - FiBu -> Bericht -> Offene Forderung | Offene Verbindlichkeiten um Altersstrukturliste (30, 60, 90, 120) erweitert - SEPA Hinzufügen von Überweisungen um das Infofeld Fälligkeitsdatum erweitert + - Verkaufsbericht mit Statistiken zu Margen - Wenn ein Auftrag komplett geliefert ist, den Workflow-Knopf 'Lieferschein' ausblenden API Änderungen: diff --git a/locale/de/all b/locale/de/all index 97a436685..d4255175c 100644 --- a/locale/de/all +++ b/locale/de/all @@ -197,6 +197,7 @@ $self->{texts} = { 'Are you sure you want to update the prices' => 'Sind Sie sicher, dass Sie die Preise aktualisieren wollen?', 'Article Code' => 'Artikelkürzel', 'Article Code missing!' => 'Artikelkürzel fehlt', + 'Artikel' => '', 'As a result, the saved onhand values of the present goods can be stored into a warehouse designated by you, or will be reset for a proper warehouse tracking' => 'Als Konsequenz können die gespeicherten Mengen entweder in ein Lager überführt werden, oder für eine frische Lagerverwaltung resettet werden.', 'Assemblies' => 'Erzeugnisse', 'Assembly Description' => 'Erzeugnis-Beschreibung', @@ -242,6 +243,10 @@ $self->{texts} = { 'Bank Connections' => 'Bankverbindungen', 'Bank accounts' => 'Bankkonten', 'Bank code' => 'Bankleitzahl', + 'Bank collection amount' => 'Einzugsbetrag', + 'Bank collection payment list for export #1' => 'Bankeinzugszahlungsliste für SEPA-Export #1', + 'Bank collection via SEPA' => 'Bankeinzug via SEPA', + 'Bank collections via SEPA' => 'Bankeinzüge via SEPA', 'Bank transfer amount' => 'Überweisungssumme', 'Bank transfer payment list for export #1' => 'Überweisungszahlungsliste für SEPA-Export #1', 'Bank transfer via SEPA' => 'Überweisung via SEPA', @@ -416,6 +421,8 @@ $self->{texts} = { 'Create and edit sales orders' => 'Auftragsbestätigungen erfassen und bearbeiten', 'Create and edit sales quotations' => 'Angebote erfassen und bearbeiten', 'Create and edit vendor invoices' => 'Eingangsrechnungen erfassen und bearbeiten', + 'Create bank collection' => 'Bankeinzug erstellen', + 'Create bank collection via SEPA XML' => 'Bankeinzug via SEPA XML erstellen', 'Create bank transfer' => 'Überweisung erstellen', 'Create bank transfer via SEPA XML' => 'Überweisung via SEPA XML erzeugen', 'Create invoice?' => 'Rechnung erstellen?', @@ -550,6 +557,7 @@ $self->{texts} = { 'Display' => 'Anzeigen', 'Display file' => 'Datei anzeigen', 'Display options' => 'Anzeigeoptionen', + 'Do you really want to close the following SEPA exports? No payment will be recorded for bank collections that haven\'t been marked as executed yet.' => 'Wollen Sie wirklich die folgenden SEPA-Exporte abschließen? Für Überweisungen, die noch nicht gebucht wurden, werden dann keine Zahlungen verbucht.', 'Do you really want to close the following SEPA exports? No payment will be recorded for bank transfers that haven\'t been marked as executed yet.' => 'Wollen Sie wirklich die folgenden SEPA-Exporte abschließen? Für Überweisungen, die noch nicht gebucht wurden, werden dann keine Zahlungen verbucht.', 'Do you really want to delete AP transaction #1?' => 'Wollen Sie wirklich die Kreditorenbuchung #1 löschen?', 'Do you really want to delete AR transaction #1?' => 'Wollen Sie wirklich die Debitorenbuchung #1 löschen?', @@ -639,6 +647,7 @@ $self->{texts} = { 'Edit Purchase Order' => 'Lieferantenaufrag bearbeiten', 'Edit Quotation' => 'Angebot bearbeiten', 'Edit Request for Quotation' => 'Anfrage bearbeiten', + 'Edit SEPA strings' => 'Begriffe bei SEPA-Überweisungen bearbeiten', 'Edit Sales Delivery Order' => 'Lieferschein (Verkauf) bearbeiten', 'Edit Sales Invoice' => 'Rechnung bearbeiten', 'Edit Sales Order' => 'Auftrag bearbeiten', @@ -792,6 +801,7 @@ $self->{texts} = { 'Hardcopy' => 'Seite drucken', 'Has serial number' => 'Hat eine Serienummer', 'Header' => 'Überschrift', + 'Headers' => 'Überschriften', 'Heading' => 'Überschrift', 'Help' => 'Hilfe', 'Help Template Variables' => 'Hilfe zu Dokumenten-Variablen', @@ -950,6 +960,7 @@ $self->{texts} = { 'List bank accounts' => 'Bankkonten anzeigen', 'List export' => 'Export anzeigen', 'List of bank accounts' => 'Liste der Bankkonten', + 'List of bank collections' => 'Bankeinzugsliste', 'List of bank transfers' => 'Überweisungsliste', 'List of custom variables' => 'Liste der benutzerdefinierten Variablen', 'List open SEPA exports' => 'Noch nicht ausgeführte SEPA-Exporte anzeigen', @@ -976,6 +987,7 @@ $self->{texts} = { 'MAILED' => 'Gesendet', 'MSG_BROWSER_DOES_NOT_SUPPORT_IFRAMES' => 'Ihr Browser kann leider keine eingebetteten Frames anzeigen. Bitte wählen Sie ein anderes Menü in der Benutzerkonfiguration im Administrationsmenü aus.', 'Main Preferences' => 'Grundeinstellungen', + 'Main sorting' => 'Hauptsortierung', 'Make' => 'Lieferant', 'Manage Custom Variables' => 'Benutzerdefinierte Variablen', 'Manage license keys' => 'Lizenzschlüssel verwalten', @@ -983,6 +995,8 @@ $self->{texts} = { 'Mandatory Departments' => 'Benutzer muss Abteilungen vergeben', 'Mar' => 'März', 'March' => 'März', + 'Margepercent' => 'Ertrag prozentual', + 'Margetotal' => 'Ertrag', 'Margins' => 'Seitenränder', 'Mark as closed' => 'Abschließen', 'Mark as paid?' => 'Als bezahlt markieren?', @@ -1056,6 +1070,7 @@ $self->{texts} = { 'No Vendor was found matching the search parameters.' => 'Zu dem Suchbegriff wurde kein Händler gefunden', 'No action defined.' => 'Keine Aktion definiert.', 'No backup file has been uploaded.' => 'Es wurde keine Sicherungsdatei hochgeladen.', + 'No bank information has been entered in this customer\'s master data entry. You cannot create bank collections unless you enter bank information.' => 'Für diesen Kunden wurden in seinen Stammdaten keine Kontodaten hinterlegt. Solange dies nicht geschehen ist, können Sie keine Überweisungen für den Lieferanten anlegen.', 'No bank information has been entered in this vendor\'s master data entry. You cannot create bank transfers unless you enter bank information.' => 'Für diesen Lieferanten wurden in seinen Stammdaten keine Kontodaten hinterlegt. Solange dies nicht geschehen ist, können Sie keine Überweisungen für den Lieferanten anlegen.', 'No bins have been added to this warehouse yet.' => 'Es wurden zu diesem Lager noch keine Lagerplätze angelegt.', 'No customer has been selected yet.' => 'Es wurde noch kein Kunde ausgewählt.', @@ -1193,6 +1208,7 @@ $self->{texts} = { 'Phone1' => 'Telefon 1 ', 'Phone2' => 'Telefon 2', 'Pick List' => 'Sammelliste', + 'Please Check the bank information for each customer:' => 'Bitte überprüfen Sie die Bankinformationen der Kunden:', 'Please Check the bank information for each vendor:' => 'Bitte überprüfen Sie die Kontoinformationen der Lieferanten:', 'Please ask your administrator to create warehouses and bins.' => 'Bitten Sie Ihren Administrator, dass er Lager und Lagerplätze anlegt.', 'Please enter a license key.' => 'Bitte geben Sie einen Lizenzschlüssel an.', @@ -1214,6 +1230,7 @@ $self->{texts} = { 'Please select a vendor from the list below.' => 'Bitte einen Händler aus der Liste auswählen', 'Please select the chart of accounts this installation is using from the list below.' => 'Bitte wählen Sie den Kontenrahmen aus, der bei dieser Installation verwendet wird.', 'Please select the database you want to backup' => 'Bitte wählen Sie die zu sichernde Datenbank gefunden', + 'Please select the destination bank account for the collections:' => 'Bitte wählen Sie das Bankkonto als Ziel für die Einzüge aus:', 'Please select the source bank account for the transfers:' => 'Bitte wählen Sie das Bankkonto als Quelle für die Überweisungen aus:', 'Please seletct the dataset you want to delete:' => 'Bitte wählen Sie die zu löschende Datenbank aus:', 'Please specify a description for the warehouse designated for these goods.' => 'Bitte geben Sie den Namen des Ziellagers für die übernommenen Daten ein.', @@ -1231,6 +1248,7 @@ $self->{texts} = { 'Preis' => 'Preis', 'Preisgruppe' => 'Preisgruppe', 'Preisklasse' => 'Preisgruppe', + 'Prepare bank collection via SEPA XML' => 'Einzug via SEPA XML vorbereiten', 'Prepare bank transfer via SEPA XML' => 'Überweisung via SEPA XML vorbereiten', 'Prepayment' => 'Vorauszahlung', 'Preview' => 'Druckvorschau', @@ -1285,6 +1303,9 @@ $self->{texts} = { 'Purchase Prices' => 'Einkaufspreise', 'Purchase delivery order' => 'Lieferschein (Einkauf)', 'Purchase invoices' => 'Einkaufsrechnungen', + 'Purchase net amount' => 'EK-Betrag', + 'Purchase price' => 'EK-Preis', + 'Purchase price total' => 'EK-Betrag', 'Purpose' => 'Verwendungszweck', 'Qty' => 'Menge', 'Qty according to delivery order' => 'Menge laut Lieferschein', @@ -1327,6 +1348,7 @@ $self->{texts} = { 'Reference missing!' => 'Referenz fehlt!', 'Release From Stock' => 'Lagerausgang', 'Remaining' => 'Rest', + 'Remittance information prefix' => 'Verwendungszweckvorbelegung (Präfix)', 'Removal' => 'Entnahme', 'Removal from Warehouse' => 'Lagerentnahme', 'Removal from warehouse' => 'Entnahme aus Lager', @@ -1364,7 +1386,9 @@ $self->{texts} = { 'SAVED FOR DUNNING' => 'Gespeichert', 'SCREENED' => 'Angezeigt', 'SEPA XML download' => 'SEPA-XML-Download', + 'SEPA creditor ID' => 'SEPA-Kreditoren-Identifikation', 'SEPA exports:' => 'SEPA-Exporte:', + 'SEPA strings' => 'SEPA-Überweisungen', 'Saldo Credit' => 'Saldo Haben', 'Saldo Debit' => 'Saldo Soll', 'Saldo neu' => 'Saldo neu', @@ -1374,10 +1398,16 @@ $self->{texts} = { 'Sales Invoices' => 'Kundenrechnung', 'Sales Order' => 'Kundenauftrag', 'Sales Orders' => 'Aufträge', + 'Sales Report' => 'Verkaufsbericht', 'Sales and purchase invoices with inventory transactions with taxkeys' => 'Einkaufs- und Verkaufsrechnungen mit Warenbestandsbuchungen mit Steuerschlüsseln', 'Sales delivery order' => 'Lieferschein (Verkauf)', 'Sales invoice number' => 'Ausgangsrechnungsnummer', 'Sales invoices' => 'Verkaufsrechnungen', + 'Sales margin' => 'Marge', + 'Sales margin %' => 'Marge prozentual', + 'Sales net amount' => 'VK-Betrag', + 'Sales price' => 'VK-Preis', + 'Sales price total' => 'VK-Betrag', 'Sales quotation' => 'Angebot', 'Salesman' => 'Verkäufer/in', 'Salesperson' => 'Verkäufer', @@ -1562,6 +1592,7 @@ $self->{texts} = { 'The GL transaction #1 has been deleted.' => 'Die Dialogbuchung #1 wurde gelöscht.', 'The LDAP server "#1:#2" is unreachable. Please check config/authentication.pl.' => 'Der LDAP-Server "#1:#2" ist nicht erreichbar. Bitte überprüfen Sie die Angaben in config/authentication.pl.', 'The SEPA export has been created.' => 'Der SEPA-Export wurde erstellt', + 'The SEPA strings have been saved.' => 'Die bei SEPA-Überweisungen verwendeten Begriffe wurden gespeichert.', 'The access rights have been saved.' => 'Die Zugriffsrechte wurden gespeichert.', 'The account 3804 already exists, the update will be skipped.' => 'Das Konto 3804 existiert schon, das Update wird übersprungen.', 'The account 3804 will not be added automatically.' => 'Das Konto 3804 wird nicht automatisch hinzugefügt.', @@ -1896,6 +1927,7 @@ $self->{texts} = { 'You have to create at least one group, grant it access to Lx-Office\'s functions and assign users to it.' => 'Sie müssen mindestens eine Benutzergruppe anlegen, ihr Zugriff auf die verschiedenen Funktionsbereiche von Lx-Office gewähren und Benutzer dieser Gruppe zuordnen.', 'You have to create new Buchungsgruppen for all the combinations of inventory, income and expense accounts that have been used already.' => 'Sie müssen neue Buchungsgruppen für alle Kombinationen aus Inventar-, Erlös- und Aufwandskonto, die bereits benutzt wurden.', 'You have to enter a company name in your user preferences (see the "Program" menu, "Preferences").' => 'Sie müssen einen Firmennamen in Ihren Einstellungen angeben (siehe Menü "Programm", "Einstellungen").', + 'You have to enter the SEPA creditor ID in your user preferences (see the "Program" menu, "Preferences").' => 'Sie müssen die SEPA-Kreditoren-Identifikation in Ihren Einstellungen angeben (siehe Menü "Programm", "Einstellungen").', 'You have to fill in at least an account number, the bank code, the IBAN and the BIC.' => 'Sie müssen zumindest die Kontonummer, die Bankleitzahl, die IBAN und den BIC angeben.', 'You have to specify a department.' => 'Sie müssen eine Abteilung wählen.', 'You have to specify an execution date for each antry.' => 'Sie müssen für jeden zu buchenden Eintrag ein Ausführungsdatum angeben.', @@ -1923,7 +1955,8 @@ $self->{texts} = { 'as at' => 'zum Stand', 'assembly_list' => 'erzeugnisliste', 'back' => 'zurück', - 'bank_transfer_payment_list_#1' => 'ueberweisungs_zahlungsliste_#1', + 'bank_collection_payment_list_#1' => 'bankeinzugszahlungsliste_#1', + 'bank_transfer_payment_list_#1' => 'ueberweisungszahlungsliste_#1', 'bankaccounts' => 'Bankkonten', 'banktransfers' => 'ueberweisungen', 'bestbefore #1' => 'Mindesthaltbarkeit #1', @@ -1951,6 +1984,7 @@ $self->{texts} = { 'debug' => 'Debug', 'delete' => 'Löschen', 'deliverydate' => 'Lieferdatum', + 'description' => 'Beschreibung', 'direct debit' => 'Lastschrift', 'disposed' => 'Entsorgung', 'done' => 'erledigt', @@ -2026,6 +2060,7 @@ $self->{texts} = { 'sales_order' => 'Kundenauftrag', 'sales_order_list' => 'auftragsliste', 'sales_quotation' => 'Verkaufsangebot', + 'sales_report' => 'verkaufsbericht', 'saved' => 'gespeichert', 'saved!' => 'gespeichert', 'sent' => 'gesendet', diff --git a/lxo-import/addressB.php b/lxo-import/addressB.php index bd5317f05..df0cfc50e 100644 --- a/lxo-import/addressB.php +++ b/lxo-import/addressB.php @@ -69,12 +69,11 @@ if (!$file) ende ("Kein Datenfile"); $trenner=($_POST["trenner"])?$_POST["trenner"]:","; if ($trenner=="other") { $trenner=trim($trennzeichen); - if (substr($trenner,0,1)=="#") if (strlen($trenner)>1) $trenner=chr(substr($trenner,1)); } +if (substr($trenner,0,1)=="#") if (strlen($trenner)>1) $trenner=chr(substr($trenner,1)); if (!file_exists($dir.$file.".csv")) ende("$file.csv nicht im Ordner oder leer"); - if (!$db->chkcol($file)) ende("Importspalte kann nicht angelegt werden"); $employee=chkUsr($_SESSION["employee"]); @@ -114,18 +113,54 @@ $kunde_fld = array_keys($address); } } +function chkBusiness($data,$id=true) { +global $db; + if ($id) { + $rs = $db->getAll("select id from business where id =$data"); + } else { + $rs = $db->getAll("select id from business where decription ilike '$data'"); + } + if ($rs[0]["id"]) { + return $rs[0]["id"]; + } else { + return "null"; + } +} + +function chkSalesman($data,$id=true) { +global $db; + if ($id) { + $rs = $db->getAll("select id from employee where id =$data"); + } else { + $rs = $db->getAll("select id from employee where login ilike '$data'"); + } + if ($rs[0]["id"]) { + return $rs[0]["id"]; + } else { + return "null"; + } +} + $f=fopen($dir.$file.".csv","r"); $zeile=fgets($f,1200); $infld=explode($trenner,strtolower($zeile)); $first=true; $ok=true; +$p=0; foreach ($infld as $fld) { $fld = strtolower(trim(strtr($fld,array("\""=>"","'"=>"")))); - if ($fld=="branche" && !$crm) { $in_fld[]=""; continue; }; - if ($fld=="sw" && !$crm) { $in_fld[]=""; continue; }; - $in_fld[]=$fld; + if (in_array($fld,$kunde_fld)) { + if ($fld=="branche" && !$crm) { continue; }; + if ($fld=="sw" && !$crm) { continue; }; + $in_fld[$fld]=$p; + //$fldpos[$fld]=$p; + //$in_fld[]=$fld; + } + $p++; } - +$infld = array_keys($in_fld); +$infld[] = "import"; +$infld = implode(",",$infld); $j=0; $m=0; $zeile=fgetcsv($f,1200,$trenner); @@ -135,16 +170,75 @@ if ($ok) while (!feof($f)){ $anrede=""; $Matchcode=""; $sql="insert into $file "; - $keys="("; - $vals=" values ("; + $keys=array(); + $vals=array(); $number=false; - foreach($zeile as $data) { - if (!in_array(trim($in_fld[$i]),$kunde_fld)) { - if ($in_fld[$i]=="anrede") { $anrede=addslashes(trim($data)); } - $i++; - continue; - }; - $data=trim($data); + //foreach($zeile as $data) { + + foreach($in_fld as $fld => $pos) { + switch ($fld) { + case "name" : + case "department_1" : + case "department_2" : + case "matchcode" : + case "street" : + case "city" : + case "notes" : + case "sw" : + case "branche" : + case "country" : + case "contact" : + case "homepage" : + case "email" : + case "bank" : $data = addslashes(trim($zeile[$pos])); + if (Translate) translate($data); + case "ustid" : $data = strtr(trim($zeile[$pos])," ",""); + case "bank_code" : $data = trim($zeile[$pos]); + case "account_number": + case "greeting" : + case "taxnumber" : + case "zipcode" : + case "phone" : + case "fax" : $data = trim($zeile[$pos]); + $data = "'$data'"; + if ($data=="''") { + $vals[] = "null"; + } else { + $vals[] = $data; + } + break; + case "business_id" : $vals[] = chkBusiness(trim($zeile[$pos])); + break; + case "salesman_id" : $vals[] = chkSalesman(trim($zeile[$pos])); + break; + case "taxincluded" : $data = strtolower(substr($zeile[$pos],0,1)); + if ($data!="f" && $data!="t") { $vals[] = "'f'"; } + else { $vals[] = "'".$data."'";} + break; + case "taxzone_id" : $data = trim($zeile[$pos])*1; + if ($data>3 && $data<0) $data = 0; + $vals[] = $data; + break; + case "creditlimit" : + case "discount" : + case "terms" : $vals[] = trim($zeile[$pos])*1; + break; + case "customernumber": + case "vendornumber" : $data = trim($zeile[$pos]); + if (empty($data) or !$data) { + $vals[] = getKdId(); + $number = true; + } else { + $vals[] = chkKdId($data); + $number = true; + } + break; + } + }; + if (!in_array("taxzone_id",$in_fld)) { + $in_fld[] = "taxzone_id"; + $vals[] = 0; + } // seit 2.6 ist die DB-Kodierung UTF-8 @holger Ansonsten einmal vorher die DB-Encoding auslesen // Falls die Daten ISO-kodiert kommen entsprechend wandeln // done! @@ -152,78 +246,26 @@ if ($ok) while (!feof($f)){ // die blöde mb_detect... tut leider nicht immer, daher die Möglichkeit der Auswahl // TODO Umlaute am Anfang wurden bei meinem Test nicht übernommen (Österreich). S.a.: // http://forum.de.selfhtml.org/archiv/2007/1/t143904/ - - if (Translate) translate($data); - - //$data=htmlentities($data); - $data=addslashes($data); - if ($in_fld[$i]==$file."number") { // customernumber || vendornumber - if (empty($data) or !$data) { - $data=getKdId(); - $number=true; - } else { - $data=chkKdId($data); - $number=true; - } - } else if ($in_fld[$i]=="taxincluded"){ - $data=strtolower(substr($data,0,1)); - if ($data!="f" && $data!="t") $data="f"; - } else if ($in_fld[$i]=="ustid"){ - $data=strtr($data," ",""); - } /*else if ($in_fld[$i]=="matchcode") { - $matchcode=$data; - $i++; - continue; - if ($data==false or empty($data) or !$data) { - if (in_array($in_fld[$i],array("name"))) { - $data=$matchcode; - } - } - }*/ - - $keys.=$in_fld[$i].","; - if ($data==false or empty($data) or !$data) { - $vals.="null,"; - } else { - if ($in_fld[$i]=="contact"){ - if ($anrede) { - $vals.="'$anrede $data',"; - } else { - $vals.="'$data',"; - } - } else { - $vals.="'".$data."',"; - } - } - $i++; - } - if (!$number) { - $keys.=$file."number,"; - $vals.="'".getKdId()."',"; - } - if ($keys<>"(") { - if ($test) { + if ($test) { if ($first) { - echo "\n"; - echo "\n"; + echo "
".str_replace(",","",substr($keys,1,-1))."
\n\n"; $first=false; }; - $vals=str_replace("',","'\n"; + echo "\n"; //echo "Import $j
\n"; flush(); - } else { - $sql.=$keys."taxzone_id,import)"; - $sql.=$vals."0,$nun)"; - $rc=$db->query($sql); - if (!$rc) echo "Fehler: ".$sql."
"; - } - $j++; } else { - $vals=str_replace("',","'\n"; - flush(); - } + $vals[] = $nun; + $sql = "INSERT INTO $file (".$infld.") values (".implode(",",$vals).")"; + $rc=$db->query($sql); + if ($j % 10 == 0) { echo "."; flush(); }; + if (!$rc) { echo "
Fehler: ".$sql."
"; flush(); }; + } + $j++; $zeile=fgetcsv($f,1200,$trenner); } fclose($f); diff --git a/lxo-import/import_lib.php b/lxo-import/import_lib.php index 36cf30f14..996d21e64 100644 --- a/lxo-import/import_lib.php +++ b/lxo-import/import_lib.php @@ -36,6 +36,8 @@ $address = array( "bank_code" => "Bankleitzahl", "bank" => "Bankname", "branche" => "Branche", + "business_id" => "BranchenID", + "salesman_id" => "VerkäuferID", //"language" => "Sprache (de,en,fr)", "sw" => "Stichwort", "creditlimit" => "Kreditlimit (nnnnnn.nn)"); /*, diff --git a/lxo-import/partsB.php b/lxo-import/partsB.php index 1d280d863..cb9de6763 100644 --- a/lxo-import/partsB.php +++ b/lxo-import/partsB.php @@ -56,7 +56,7 @@ if ($_POST["ok"] || $_GET["cron"]=="1") { //DB und LxO müssen ja nicht auf der gleichen Maschine sein. if($tmpcode<>$db->getClientCode()) { $rc = $db->setClientCode($tmpcode); - } + } // Zeichenkodierung File if ($_POST["encoding"] == "auto") { @@ -83,7 +83,7 @@ if ($_POST["ok"] || $_GET["cron"]=="1") { echo $header; echo "

Die erste Zeile enthält die Feldnamen der Daten in ihrer richtigen Reihenfolge
"; echo "Geben Sie das Trennzeichen der Datenspalten ein. Steuerzeichen können mit ihrem Dezimalwert "; - echo "geführt von einem "#" eingegebn werden (#11).

"; + echo "geführt von einem "#" eingegebn werden (#11).

"; echo "Wird bei "Art" in der Maske "gemischt" gewählt, muss die Spalte "art" vor der Einheit stehen.

"; echo "Der "sellprice" kann um den eingegeben Wert geändert werden.

"; echo "Bei vorhandenen Artikelnummern (in der db), kann entweder ein Update auf den Preis (und Text) durchgeführt werden oder "; @@ -92,7 +92,8 @@ if ($_POST["ok"] || $_GET["cron"]=="1") { echo "Dazu muß entweder in der Maske eine Standardbuchungsgruppe gewählt werden
"; echo "oder es wird ein gültiges Konto in 'income_accno_id' und 'expense_accno_id' eingegeben. "; echo "Das Programm versucht dann eine passende Buchungsgruppe zu finden.
"; - echo "Preisgruppen müssen zunächst angelegt werden. Die Spalten für die Preisgruppen beginnen mit 'pg_' gefolgt vom Preisgruppenname."; + echo "Preisgruppen müssen zunächst angelegt werden. Die Spalten für die Preisgruppen beginnen mit 'pg_' gefolgt vom Preisgruppenname.
"; + echo "Wenn eine Datei users/partshead.csv existiert, wird die erste Zeile aus dieser benutzt um das Format zu bestimmen. Die erste Zeile aus der eigentlichen Importdatei wird dann ignoriert.
"; exit(0); }; @@ -129,7 +130,7 @@ if ($_POST["ok"] || $_GET["cron"]=="1") { $_POST["ware"] = "W"; // Ist ein Artikel $_POST["encoding"] = ""; } else { - + /* no data? */ if (empty($_FILES["Datei"]["name"])) ende ("Kein Datenfile angegeben"); @@ -150,15 +151,15 @@ if ($_POST["ok"] || $_GET["cron"]=="1") { }; } else if (!move_uploaded_file($_FILES["Datei"]["tmp_name"],$dir.$file.".csv")) { ende ("Upload von Datei fehlerhaft.".$_FILES["Datei"]["error"]); - }; + }; } /* check if file is really there */ - if (!file_exists($dir.$file.'.csv') or filesize($dir.$file.'.csv')==0) + if (!file_exists($dir.$file.'.csv') or filesize($dir.$file.'.csv')==0) ende("Datenfile ($file.csv) nicht im Ordner gefunden oder leer"); /* Zu diesem Zeitpunkt wurde der Artikel Importiert */ - if (!$db->chkcol($file)) + if (!$db->chkcol($file)) ende("Importspalte konnte nicht angelegt werden"); /* just print data or insert it, if test is false */ @@ -178,22 +179,22 @@ if ($_POST["ok"] || $_GET["cron"]=="1") {
"; + echo implode('',array_keys($in_fld)); + echo "
",substr($vals,9,-1)); - echo "
".str_replace("null,","null",$vals)."
"; + echo implode('',$vals); + echo "
",substr($vals,9,-1)); - echo "
".str_replace("null,","null",$vals)."
- - @@ -202,6 +203,8 @@ if ($_POST["ok"] || $_GET["cron"]=="1") { + + diff --git a/lxo-import/parts_import.php b/lxo-import/parts_import.php index 0db931230..94f2b6f15 100644 --- a/lxo-import/parts_import.php +++ b/lxo-import/parts_import.php @@ -128,11 +128,13 @@ function updParts($db,$insert,$show,$partnumber,$lastcost,$sellprice,$listprice, return $rc; } -function getMakemodel($db,$check,$hersteller,$model,$partsid,$add=true) { +function getMakemodel($db,$check,$hersteller,$model,$partsid,$lastcost,$add=true) { $sql="select * from makemodel where make = $hersteller and model = '$model' and parts_id = $partsid"; $rs=$db->getAll($sql); if (empty($rs[0]["id"]) && $add) { - $sql="insert into makemodel (parts_id,make,model) values ($partsid,'$hersteller','$model')"; + if (!$lastcost) $lastcost=0.00; + $sql="insert into makemodel (parts_id,make,model,lastcost,lastupdate,sortorder) "; + $sql.="values ($partsid,'$hersteller','$model',$lastcost,now(),1)"; $rc=$db->query($sql); } } @@ -251,6 +253,8 @@ function import_parts($db, $file, $fields, $check, $maske) { $wgtrenner=$maske["wgtrenner"]; $Update=($maske["update"]=="U")?true:false; $UpdText=($maske["TextUpd"]=="1")?true:false; + $vendnr=($maske["vendnr"]=="t")?true:false; + $modnr=($maske["modnr"]=="t")?true:false; //$stdunitW=getStdUnit($db,"dimension"); //$stdunitD=getStdUnit($db,"service"); @@ -293,12 +297,12 @@ function import_parts($db, $file, $fields, $check, $maske) { */ if ($show) { show('',false); - show("partnumber"); show("lastcost"); show("sellprice"); show("listprice"); - show("description");show("notes"); show("ean"); - show("weight"); show("image"); show("partsgroup_id"); - show("bg"); show("income_accno"); show("expense_accno"); - show("inventory_accno"); show("microfiche");show("drawing");show("rop"); - show("assembly");show("makemodel"); show("shop"); show(""); + show("partnumber"); show("lastcost"); show("sellprice"); show("listprice"); + show("description"); show("notes"); show("ean"); + show("weight"); show("image"); show("partsgroup_id"); + show("bg"); show("income_accno"); show("expense_accno"); + show("inventory_accno"); show("microfiche"); show("drawing"); + show("rop"); show("assembly"); show("makemodel"); show("shop"); show(""); show("\n",false); } @@ -342,8 +346,8 @@ function import_parts($db, $file, $fields, $check, $maske) { foreach ($prices as $pkey=>$val) { if (array_key_exists($pkey,$fldpos)) $pricegroup[$val] = str_replace(",", ".", $zeile[$fldpos[$pkey]]); - } - } + } + } if ($quotation<>0) { if ($quottype=="A") { $sellprice += $quotation; } else { $sellprice = $sellprice * $quotation; } @@ -383,32 +387,39 @@ function import_parts($db, $file, $fields, $check, $maske) { $partsgroup_id = getPartsgroupId($db, $pgname, $insert); } + /* Ware oder Dienstleistung */ + if (($maske["ware"]=="G" and strtoupper($zeile[$fldpos["art"]])=="D") or $maske["ware"]=="D") { + $artikel = false; + } else if (($maske["ware"]=="G" and strtoupper($zeile[$fldpos["art"]])=="W") or $maske["ware"]=="W") { + $artikel = true; + } + /* sind Hersteller und Modelnummer hinterlegt wenn ja, erfolgt er insert später */ $makemodel = 'f'; - if (!empty($zeile[$fldpos["makemodel"]]) and !$artikel) { + if (!empty($zeile[$fldpos["makemodel"]]) and $artikel) { $mm = $zeile[$fldpos["makemodel"]]; if (Translate) translate($mm); - $hersteller=suchFirma("vendor",$mm); - $hersteller=$hersteller["cp_cv_id"]; - if (!empty($zeile[$fldpos["model"]])) { + if ($vendnr) { + $hersteller=getFirma($mm,"vendor"); + } else { + $hersteller=suchFirma("vendor",$mm); + $hersteller=$hersteller["cp_cv_id"]; + } + if (!empty($zeile[$fldpos["model"]]) and $hersteller>0) { $mo = $zeile[$fldpos["model"]]; if (Translate) translate($mo); $model = $mo; $makemodel = 't'; - } else { + } else if ($modnr and $hersteller>0) { + $model = ''; + $makemodel = 't'; + } else { unset($hersteller); $makemodel = 'f'; } } - /* Ware oder Dienstleistung */ - if (($maske["ware"]=="G" and strtoupper($zeile[$fldpos["art"]])=="D") or $maske["ware"]=="D") { - $artikel = false; - } else if (($maske["ware"]=="G" and strtoupper($zeile[$fldpos["art"]])=="W") or $maske["ware"]=="W") { - $artikel = true; - } - /* Einheit ermitteln */ if ($zeile[$fldpos["unit"]]=="") { //Keine Einheit mitgegeben @@ -523,10 +534,10 @@ function import_parts($db, $file, $fields, $check, $maske) { "rop"=>$rop,"assembly"=>$assembly, "shop"=>$shop,"makemodel"=>$makemodel),$pricegroup ); - if ($hersteller>0 && $model) { + if ($hersteller>0 ) { // && $model) { $partsid=getPartsid($db,$zeile[$fldpos["partnumber"]]); - if ($partsid) { - getMakemodel($db,$check,$hersteller,$model,$partsid,true); + if ($partsid) { + getMakemodel($db,$check,$hersteller,$model,$partsid,$lastcost,true); } } unset($zeile); diff --git a/lxo-import/partshead.csv b/lxo-import/partshead.csv new file mode 100644 index 000000000..53793b485 --- /dev/null +++ b/lxo-import/partshead.csv @@ -0,0 +1 @@ +partnumber fvId wgr partsgroup ean model ErsatzArt makemodel MarkeText description cat01 cat01Text cat02 cat02Text cat03 cat03Text cat04 cat04Text KzStueck KzAL KzAktion KzSperre pg_1 pg_2 listprice lastcost InfLagME InfLagWE diff --git a/menu.ini b/menu.ini index cf9593808..7ca0fa173 100644 --- a/menu.ini +++ b/menu.ini @@ -159,6 +159,12 @@ module=ar.pl action=search nextsub=ar_transactions +[AR--Reports--Sales Report] +ACCESS=invoice_edit +module=vk.pl +action=search_invoice +nextsub=invoice_transactions + [AR--Reports--Dunnings] ACCESS=dunning_edit module=dn.pl @@ -339,9 +345,15 @@ ACCESS=cash module=rc.pl action=reconciliation +[Cash--Bank collection via SEPA] +module=sepa.pl +action=bank_transfer_add +vc=customer + [Cash--Bank transfer via SEPA] module=sepa.pl action=bank_transfer_add +vc=vendor [Cash--Reports] module=menu.pl @@ -359,9 +371,15 @@ module=rp.pl action=report report=payments +[Cash--Reports--Bank collections via SEPA] +module=sepa.pl +action=bank_transfer_search +vc=customer + [Cash--Reports--Bank transfers via SEPA] module=sepa.pl action=bank_transfer_search +vc=vendor [Reports] @@ -667,6 +685,10 @@ action=list_language module=generictranslations.pl action=edit_greetings +[System--Languages--SEPA strings] +module=generictranslations.pl +action=edit_sepa_strings + [System--Payment Terms] module=menu.pl diff --git a/sql/Pg-upgrade2/sepa_in.sql b/sql/Pg-upgrade2/sepa_in.sql new file mode 100644 index 000000000..6373b8f7e --- /dev/null +++ b/sql/Pg-upgrade2/sepa_in.sql @@ -0,0 +1,12 @@ +-- @tag: sepa_in +-- @description: Erweiterung SEPA für Kontoeinzüge +-- @depends: release_2_6_1 +-- @charset: utf-8 +ALTER TABLE sepa_export ADD COLUMN vc varchar(10); +UPDATE sepa_export SET vc = 'vendor'; + +ALTER TABLE sepa_export_items ALTER COLUMN ap_id DROP NOT NULL; +ALTER TABLE sepa_export_items ADD COLUMN ar_id integer; +ALTER TABLE sepa_export_items ADD FOREIGN KEY (ar_id) REFERENCES ar (id); +ALTER TABLE sepa_export_items RENAME vendor_iban TO vc_iban; +ALTER TABLE sepa_export_items RENAME vendor_bic TO vc_bic; diff --git a/templates/webpages/admin/edit_user.html b/templates/webpages/admin/edit_user.html index 4cd24ca08..161c5d2a9 100644 --- a/templates/webpages/admin/edit_user.html +++ b/templates/webpages/admin/edit_user.html @@ -95,6 +95,11 @@ + + + + +
Trennzeichen - Semikolon - Komma + Semikolon + Komma Tabulator Leerzeichen - - + +
VK-Preis
Nachkomma:
0 - 1 - 2 - 3 - 4 - 5 +
VK-Preis
Nachkomma:
0 + 1 + 2 + 3 + 4 + 5
VK-Preis
Aufschlag:
- % +
VK-Preis
Aufschlag:
+ % Absolut
Vorhandene
Artikelnummer:
Preis update durchführen
mit neuer Nummer einfügen
Textupdateja
Warengruppen
verbinder
Shopartikel
falls nicht übergeben
ja nein
Eintrag in
Makemodel ist
Lieferantennummer Lieferantenname
auch ohne
Model-Nr.
ja nein
ArtWare   Dienstleistung gemischt (Spalte 'art' vorhanden)
[% 'DUNS-Nr' | $T8 %]
[% 'SEPA creditor ID' | $T8 %]
diff --git a/templates/webpages/am/config.html b/templates/webpages/am/config.html index 3d5aba29a..4ed5a07e8 100644 --- a/templates/webpages/am/config.html +++ b/templates/webpages/am/config.html @@ -65,6 +65,10 @@ [% 'Address' | $T8 %] + + [% 'SEPA creditor ID' | $T8 %] + +
diff --git a/templates/webpages/ct/form_header.html b/templates/webpages/ct/form_header.html index a6f2ceb56..e8183f276 100644 --- a/templates/webpages/ct/form_header.html +++ b/templates/webpages/ct/form_header.html @@ -147,6 +147,16 @@ + + + [% 'Username' | $T8 %] + + + + + [% 'Password' | $T8 %] + + @@ -200,15 +210,6 @@ - [%- IF conf_vertreter %] - - - - - - - [%- END %] - [% UNLESS conf_vertreter %] diff --git a/templates/webpages/generictranslations/edit_sepa_strings.html b/templates/webpages/generictranslations/edit_sepa_strings.html new file mode 100644 index 000000000..c6acd8446 --- /dev/null +++ b/templates/webpages/generictranslations/edit_sepa_strings.html @@ -0,0 +1,46 @@ +[%- USE T8 %] +[% USE HTML %] + +

+

[% HTML.escape(title) %]
+

+ + [%- IF message %] +

+ [% HTML.escape(message) %] +

+ [%- END %] + + + +
[% 'Username' | $T8 %][% 'Password' | $T8 %]
[% IF is_customer %][% 'Type of Customer' | $T8 %][% ELSE %][% 'Type of Vendor' | $T8 %][%- END %]
+ + + + + + + [%- FOREACH language = LANGUAGES %] + + + + + [%- END %] + +
 [% 'Remittance information prefix' | $T8 %]
+ [%- IF language.id == 'default' %] + [% 'Default (no language selected)' | $T8 %] + [%- ELSE %] + [%- HTML.escape(language.description) %] + [%- END %] +
+ +

+ + +

+ + + + + diff --git a/templates/webpages/sepa/bank_transfer_add.html b/templates/webpages/sepa/bank_transfer_add.html index 1eb34be40..56d36d042 100644 --- a/templates/webpages/sepa/bank_transfer_add.html +++ b/templates/webpages/sepa/bank_transfer_add.html @@ -1,12 +1,25 @@ [%- USE T8 %] [% USE HTML %][% USE LxERP %] +[% IF vc == 'vendor' %] + [% SET is_vendor = 1 %] + [% SET arap = 'ap' %] + [% SET iris = 'ir' %] +[% ELSE %] + [% SET is_vendor = 0 %] + [% SET arap = 'ar' %] + [% SET iris = 'is' %] +[%- END %]

[% title %]

- [% 'Please select the source bank account for the transfers:' | $T8 %] + [%- IF is_vendor %] + [% 'Please select the source bank account for the transfers:' | $T8 %] + [%- ELSE %] + [% 'Please select the destination bank account for the collections:' | $T8 %] + [%- END %]
[%- INCLUDE generic/multibox.html name = 'bank_account.id', @@ -20,7 +33,7 @@ - + @@ -30,29 +43,29 @@ [%- FOREACH invoice = INVOICES %] - + @@ -60,7 +73,7 @@ - + @@ -69,9 +82,14 @@
[% 'Vendor' | $T8 %][% IF is_vendor %][% 'Vendor' | $T8 %][%- ELSE %][%- LxERP.t8('Customer') %][%- END %] [% 'Invoice' | $T8 %] [% 'Amount' | $T8 %] [% 'Open amount' | $T8 %]
- [%- IF invoice.vendor_bank_info_ok %] + [%- IF invoice.vc_bank_info_ok %] [%- END %] - [%- IF loop.first || (previous_vendorname != invoice.vendorname) %] - - [%- GET HTML.escape(invoice.vendorname); - SET previous_vendorname = invoice.vendorname; - IF !invoice.vendor_bank_info_ok; + [%- IF loop.first || (previous_vcname != invoice.vcname) %] + + [%- GET HTML.escape(invoice.vcname); + SET previous_vcname = invoice.vcname; + IF !invoice.vc_bank_info_ok; GET ' (1)'; - SET show_vendor_bank_info_footnote = '1'; + SET show_vc_bank_info_footnote = '1'; END; -%] [%- END -%] - + [% HTML.escape(invoice.invnumber) %] [% LxERP.format_amount(invoice.invoice_amount, -2) %] [% LxERP.format_amount(invoice.open_amount, -2) %] [% invoice.duedate %]

- [%- IF show_vendor_bank_info_footnote %] + [%- IF show_vc_bank_info_footnote %]

- (1) [%- 'No bank information has been entered in this vendor\'s master data entry. You cannot create bank transfers unless you enter bank information.' | $T8 %] + (1) + [%- IF is_vendor %] + [%- 'No bank information has been entered in this vendor\'s master data entry. You cannot create bank transfers unless you enter bank information.' | $T8 %] + [%- ELSE %] + [%- 'No bank information has been entered in this customer\'s master data entry. You cannot create bank collections unless you enter bank information.' | $T8 %] + [%- END %]

[%- END %] @@ -80,6 +98,7 @@

+
diff --git a/templates/webpages/sepa/bank_transfer_create.html b/templates/webpages/sepa/bank_transfer_create.html index 06bbea880..0a5059a20 100644 --- a/templates/webpages/sepa/bank_transfer_create.html +++ b/templates/webpages/sepa/bank_transfer_create.html @@ -1,5 +1,14 @@ [%- USE T8 %] [% USE HTML %][% USE LxERP %] +[% IF vc == 'vendor' %] + [% SET is_vendor = 1 %] + [% SET arap = 'ap' %] + [% SET iris = 'ir' %] +[% ELSE %] + [% SET is_vendor = 0 %] + [% SET arap = 'ar' %] + [% SET iris = 'is' %] +[%- END %] [%- IF error_message %] @@ -9,7 +18,12 @@

[% title %]

-

1. [% 'Please select the source bank account for the transfers:' | $T8 %] +

1. + [%- IF is_vendor %] + [% 'Please select the source bank account for the transfers:' | $T8 %] + [%- ELSE %] + [% 'Please select the destination bank account for the collections:' | $T8 %] + [%- END %]
[%- INCLUDE generic/multibox.html name = 'bank_account.id', @@ -20,26 +34,31 @@

- 2. [% 'Please Check the bank information for each vendor:' | $T8 %] + 2. + [%- IF is_vendor %] + [% 'Please Check the bank information for each vendor:' | $T8 %] + [%- ELSE %] + [% 'Please Check the bank information for each customer:' | $T8 %] + [%- END %]
- + - [%- FOREACH vbi = VENDOR_BANK_INFO %] + [%- FOREACH vbi = VC_BANK_INFO %] - - - + + + [%- END %]
[% 'Vendor' | $T8 %][%- IF is_vendor %][% 'Vendor' | $T8 %][%- ELSE %][%- LxERP.t8('Customer') %][%- END %] [% 'IBAN' | $T8 %] [% 'BIC' | $T8 %] [% 'Bank' | $T8 %]
- - + + [% HTML.escape(vbi.name) %]
@@ -50,32 +69,32 @@
- + - + [%- FOREACH bank_transfer = BANK_TRANSFERS %] - - + + @@ -97,10 +116,15 @@

- + [%- IF is_vendor %] + + [%- ELSE %] + + [%- END %]

+ diff --git a/templates/webpages/sepa/bank_transfer_created.html b/templates/webpages/sepa/bank_transfer_created.html index d71ae55b8..6740ba1f3 100644 --- a/templates/webpages/sepa/bank_transfer_created.html +++ b/templates/webpages/sepa/bank_transfer_created.html @@ -11,13 +11,13 @@

  • - + [% 'Download SEPA XML export file' | $T8 %]
  • - + [% 'List open SEPA exports' | $T8 %]
  • diff --git a/templates/webpages/sepa/bank_transfer_edit.html b/templates/webpages/sepa/bank_transfer_edit.html index 28b17edf5..a534d1ada 100644 --- a/templates/webpages/sepa/bank_transfer_edit.html +++ b/templates/webpages/sepa/bank_transfer_edit.html @@ -1,6 +1,15 @@ [%- USE T8 %] [% USE HTML %] [% USE LxERP %] +[% IF vc == 'vendor' %] + [% SET is_vendor = 1 %] + [% SET arap = 'ap' %] + [% SET iris = 'ir' %] +[% ELSE %] + [% SET is_vendor = 0 %] + [% SET arap = 'ar' %] + [% SET iris = 'is' %] +[%- END %]

    [% title %]: [% HTML.escape(export.ids.join(', ')) %]

    @@ -15,9 +24,14 @@
[%- END %] - - - + + [%- IF is_vendor %] + + + [%- ELSE %] + + + [%- END %] @@ -52,13 +66,13 @@ [%- END %] - + - - + + @@ -135,6 +149,8 @@ [%- END %] [%- END %] [%- END %] + + diff --git a/templates/webpages/sepa/bank_transfer_list_bottom.html b/templates/webpages/sepa/bank_transfer_list_bottom.html index 79f373f2c..1eab32bfb 100644 --- a/templates/webpages/sepa/bank_transfer_list_bottom.html +++ b/templates/webpages/sepa/bank_transfer_list_bottom.html @@ -4,6 +4,7 @@ [%- IF show_buttons %] +

diff --git a/templates/webpages/sepa/bank_transfer_mark_as_closed_step1.html b/templates/webpages/sepa/bank_transfer_mark_as_closed_step1.html index 4d1a6dcf2..063b4eec4 100644 --- a/templates/webpages/sepa/bank_transfer_mark_as_closed_step1.html +++ b/templates/webpages/sepa/bank_transfer_mark_as_closed_step1.html @@ -6,7 +6,11 @@

- [%- 'Do you really want to close the following SEPA exports? No payment will be recorded for bank transfers that haven\'t been marked as executed yet.' | $T8 %] + [%- IF vc == 'vendor' %] + [%- 'Do you really want to close the following SEPA exports? No payment will be recorded for bank transfers that haven\'t been marked as executed yet.' | $T8 %] + [%- ELSE %] + [%- 'Do you really want to close the following SEPA exports? No payment will be recorded for bank collections that haven\'t been marked as executed yet.' | $T8 %] + [%- END %]

@@ -14,7 +18,7 @@ [%- FOREACH id = OPEN_EXPORT_IDS %] [%- UNLESS loop.first %], [%- END %] - [% HTML.escape(id) %] + [% HTML.escape(id) %] [%- END %]

@@ -24,6 +28,7 @@

+ diff --git a/templates/webpages/sepa/bank_transfer_search.html b/templates/webpages/sepa/bank_transfer_search.html index 306179fe5..bc60d8850 100644 --- a/templates/webpages/sepa/bank_transfer_search.html +++ b/templates/webpages/sepa/bank_transfer_search.html @@ -1,5 +1,5 @@ [%- USE T8 %] -[% USE HTML %] +[% USE HTML %][% USE LxERP %]

[% title %]

@@ -8,8 +8,8 @@

[% 'Vendor' | $T8 %][%- IF is_vendor %][% 'Vendor' | $T8 %][%- ELSE %][%- LxERP.t8('Customer') %][%- END %] [% 'Invoice' | $T8 %] [% 'Amount' | $T8 %] [% 'Open amount' | $T8 %] [% 'Purpose' | $T8 %][% 'Bank transfer amount' | $T8 %][%- IF is_vendor %][% 'Bank transfer amount' | $T8 %][%- ELSE %][%- LxERP.t8('Bank collection amount') %][%- END %] [% 'Execution date' | $T8 %]
- [%- IF loop.first || (previous_vendorname != bank_transfer.vendorname) %] - - [%- GET HTML.escape(bank_transfer.vendorname); - SET previous_vendorname = bank_transfer.vendorname; -%] + [%- IF loop.first || (previous_vcname != bank_transfer.vcname) %] + + [%- GET HTML.escape(bank_transfer.vcname); + SET previous_vcname = bank_transfer.vcname; -%] [%- END -%] - + [% HTML.escape(bank_transfer.invnumber) %] [% 'Invoice' | $T8 %][% 'Vendor' | $T8 %][% 'Source bank account' | $T8 %][% 'Target bank account' | $T8 %][%- IF is_vendor %][% 'Vendor' | $T8 %][%- ELSE %][%- LxERP.t8('Customer') %][%- END %][% 'Source bank account' | $T8 %][% 'Target bank account' | $T8 %][% 'Target bank account' | $T8 %][% 'Source bank account' | $T8 %][% 'Amount' | $T8 %] [% 'Reference' | $T8 %] [% 'Requested execution date' | $T8 %] - [% HTML.escape(item.invnumber) %] + [% HTML.escape(item.invnumber) %] [% HTML.escape(item.vendor_name) %][% HTML.escape(item.vc_name) %] [% HTML.escape(item.our_iban) %] [% HTML.escape(item.our_bic) %][% HTML.escape(item.vendor_iban) %][% HTML.escape(item.vendor_bic) %][% HTML.escape(item.vc_iban) %][% HTML.escape(item.vc_bic) %] [% HTML.escape(LxERP.format_amount(item.amount, 2)) %] [% HTML.escape(item.reference) %] [% HTML.escape(item.requested_execution_date) %]
- - + + @@ -86,6 +86,7 @@

+

diff --git a/templates/webpages/vk/search_invoice.html b/templates/webpages/vk/search_invoice.html new file mode 100644 index 000000000..18ff0fed4 --- /dev/null +++ b/templates/webpages/vk/search_invoice.html @@ -0,0 +1,173 @@ +[%- USE T8 %] + + + + +
[% 'Vendor' | $T8 %][%- IF vc == 'vendor' %][% 'Vendor' | $T8 %][%- ELSE %][%- LxERP.t8('Customer') %][%- END %]
+ + + + + + + + + + + +
[% title %]
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
[% 'Main sorting' | $T8 %] + + + + +
[% 'Customer' | $T8 %] + [%- INCLUDE 'generic/multibox.html' + name = 'customer', + default = oldcustomer, + style = 'width: 250px', + DATA = ALL_VC, + id_sub = 'vc_keys', + label_key = 'name', + select = vc_select, + limit = vclimit, + show_empty = 1, + allow_textbox = 1, + -%] +
[% 'Department' | $T8 %] + [%- INCLUDE 'generic/multibox.html' + name = 'department', + style = 'width: 250px', + DATA = ALL_DEPARTMENTS, + id_key = 'id', + label_key = 'description', + show_empty = 1, + allow_textbox = 0, + -%] +
[% 'Project Number' | $T8 %] + [%- INCLUDE 'generic/multibox.html' + name = 'project_id', + style = "width: 250px", + DATA = ALL_PROJECTS, + id_key = 'id', + label_key = 'projectnumber', + limit = vclimit, + show_empty = 1, + allow_textbox = 0, + -%] +
[% 'Part Number' | $T8 %]
[% 'Part Description' | $T8 %]
[% 'From' | $T8 %] + + + [% 'Bis' | $T8 %] + + +
+
+ + + + + +
[% 'Include in Report' | $T8 %] + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
[% 'Description' | $T8 %][% 'Part Number' | $T8 %][% 'Invnumber' | $T8 %][% 'Invdate' | $T8 %]
[% 'Quantity' | $T8 %][% 'Discount' | $T8 %][% 'Unit' | $T8 %]
[% 'Sales price' | $T8 %][% 'Sales price total' | $T8 %][% 'Purchase price' | $T8 %][% 'Purchase price total' | $T8 %]
[% 'Margetotal' | $T8 %][% 'Margepercent' | $T8 %]
[% 'Subtotal' | $T8 %][% 'Total' | $T8 %][% 'Headers' | $T8 %]
[% 'Decimalplaces' | $T8 %]
+
+

+ +
+ + + + + diff --git a/users/partshead.csv b/users/partshead.csv deleted file mode 100644 index 53793b485..000000000 --- a/users/partshead.csv +++ /dev/null @@ -1 +0,0 @@ -partnumber fvId wgr partsgroup ean model ErsatzArt makemodel MarkeText description cat01 cat01Text cat02 cat02Text cat03 cat03Text cat04 cat04Text KzStueck KzAL KzAktion KzSperre pg_1 pg_2 listprice lastcost InfLagME InfLagWE diff --git a/vk.pl b/vk.pl new file mode 120000 index 000000000..385000d1b --- /dev/null +++ b/vk.pl @@ -0,0 +1 @@ +am.pl \ No newline at end of file