Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
I
intranet-csv-import
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
project-open
intranet-csv-import
Commits
0306594e
Commit
0306594e
authored
Mar 13, 2017
by
Frank Bergmann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
-- improvements and extensions
parent
26d139fa
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
62 additions
and
20 deletions
+62
-20
intranet-csv-import-procs.tcl
tcl/intranet-csv-import-procs.tcl
+20
-6
import-2.adp
www/import-2.adp
+24
-0
import-im_invoice.tcl
www/import-im_invoice.tcl
+18
-14
No files found.
tcl/intranet-csv-import-procs.tcl
View file @
0306594e
...
...
@@ -22,12 +22,12 @@ ad_library {
ad_proc -public im_csv_import_guess_rels
{
}
{}
{
set mapping
{
{
object_type_
1
"Object Type 1
"
no_change
""
}
{
object_
name_1
"Object Name 1"
user_name
""
}
{
object_type_
2
"Object Type 2
"
no_change
""
}
{
object_
name_2
"Object Name 2"
project_parent_nrs
""
}
{
role_id
"Role"
category
"Intranet Biz Object Role"
}
{
percentage
"Percentage"
number
""
}
{
object_type_
one
"Object Type One
"
no_change
""
}
{
object_
id_one
"Object Id One"
user_name
""
}
{
object_type_
two
"Object Type Two
"
no_change
""
}
{
object_
id_two
"Object Id Two"
project_parent_nrs
""
}
{
role_id
"Role"
category
"Intranet Biz Object Role"
}
{
percentage
"Percentage"
number
""
}
}
return
$mapping
}
...
...
@@ -133,39 +133,53 @@ ad_proc -public im_csv_import_guess_im_invoice { } {} {
{
project_id
"Project Nr"
project_parent_nrs
""
}
{
project_id
"Project Nrs"
project_parent_nrs
""
}
{
project_id
"Cost Project Nrs"
project_parent_nrs
""
}
{
project
"Cost Project Nrs"
project_parent_nrs
""
}
{
invoice_nr
"Invoice Nr."
no_change
""
}
{
cost_name
"Name"
no_change
""
}
{
cost_name
"Cost Name"
no_change
""
}
{
cost_nr
"Nr"
no_change
""
}
{
cost_nr
"Cost Nr"
no_change
""
}
{
cost_center_id
"Cost Center"
cost_center
""
}
{
cost_center
"Cost Center"
cost_center
""
}
{
cost_status_id
"Status"
category
"Intranet Cost Status"
}
{
cost_status_id
"Cost Status"
category
"Intranet Cost Status"
}
{
cost_type_id
"Type"
category
"Intranet Cost Type"
}
{
cost_type_id
"Cost Type"
category
"Intranet Cost Type"
}
{
customer_id
"Customer"
company_name
""
}
{
provider_id
"Provider"
company_name
""
}
{
customer
"Customer"
company_name
""
}
{
provider
"Provider"
company_name
""
}
{
effective_date
"Effective Date"
date
""
}
{
amount
"Amount"
number
""
}
{
currency
"Currency"
no_change
""
}
{
payment_days
"Payment Days"
number
""
}
{
paid_amount
"Paid Amount"
number
""
}
{
parent_nrs
""
number
""
}
{
vat
"VAT"
number
""
}
{
tax
"TAX"
number
""
}
{
description
"Description"
no_change
""
}
{
note
"Note"
no_change
""
}
{
vat_type_id
"VAT Type"
category
"Intranet VAT Type"
}
{
company_contact_id
"Customer Contact"
user_name
""
}
{
company_contact
"Customer Contact"
user_name
""
}
{
cause_object_id
"Cause Object"
user_name
""
}
{
payment_method_id
"Payment Method"
category
"Intranet Invoice Payment Method"
}
{
template_id
"Template"
category
"Intranet Cost Template"
}
{
invoice_office_id
"Invoice Office"
office_name
""
}
{
office
"Invoice Office"
office_name
""
}
{
item_name
"Item Name"
no_change
""
}
{
sort_order
"Item Sort Order"
number
""
}
{
item_units
"Item Units"
number
""
}
{
price_per_unit
"Item Price"
number
""
}
{
price_per_unit
"Price Per Unit"
number
""
}
{
item_uom_id
"Item UoM"
category
"Intranet UoM"
}
{
item_uom
"Item UoM"
category
"Intranet UoM"
}
{
item_material_id
"Item Material"
material
""
}
{
item_material
"Item Material"
material
""
}
{
item_type_id
"Item Type Id"
no_change
""
}
{
item_status_id
"Item Status Id"
no_change
""
}
{
task
"Task Id"
project_parent_nrs
""
}
{
task_id
"Task Id"
project_parent_nrs
""
}
}
return
$mapping
}
...
...
www/import-2.adp
View file @
0306594e
...
...
@@ -78,6 +78,30 @@
</if>
<if @object_type@ eq im_invoice>
<table cellpadding="5" cellspacing="5" border="0">
<tr>
<td>
<h2>Settings:</h2>
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td valign="top"><input type="checkbox" name="overwrite_existing_invoice_attributes_p" value="1"> </td>
<td valign="top"><strong>Should already existing invoice attributes be overwritten?</strong><br/>Check to overwrite.</td>
</tr>
</table>
</td>
<!--
<td>
<h2>Please note:</h2>
<ul><li></li></ul>
</td>
-->
</tr>
</table>
</if>
<br/>
<h2>Mapping</h2>
<table>
...
...
www/import-im_invoice.tcl
View file @
0306594e
...
...
@@ -15,6 +15,7 @@ ad_page_contract {
{
import_filename
""
}
{
mapping_name
""
}
{
ns_write_p 1
}
{
overwrite_existing_invoice_attributes_p 0
}
column:array
map:array
parser:array
...
...
@@ -173,7 +174,10 @@ foreach csv_line_fields $values_list_of_lists {
set item_uom_id
""
set price_per_unit
""
set item_material_id
""
set item_type_id
""
set item_status_id
""
set task_id
""
foreach attribute_name
$attribute
_names
{
set
$attribute
_name
""
}
...
...
@@ -243,12 +247,10 @@ foreach csv_line_fields $values_list_of_lists {
if
{
$ns
_write_p
}
{
ns_write
"<li>Before cost_nr: name=
$cost
_name, nr=
$cost
_nr</font>
\n
"
}
# Use the current cost_name in the next line.
# That's useful for invoice_items right after the respective Financial Document
if
{
""
ne
$cost
_name
}
{
set old_cost_name
$cost
_name
}
# -------------------------------------------------------
# Check if the cost already exists
...
...
@@ -260,7 +262,6 @@ foreach csv_line_fields $values_list_of_lists {
if
{
$ns
_write_p
}
{
ns_write
"<li>id=
$cost
_id, name='
$cost
_name', nr='
$cost
_nr'
\n
"
}
# -------------------------------------------------------
# Check if we've got an invoice item
set item_field_count 0
...
...
@@ -310,10 +311,10 @@ foreach csv_line_fields $values_list_of_lists {
db_dml insert_item
"
insert into im_invoice_items (
item_id,
invoice_id, sort_order, item_name, item_units, item_uom_id, price_per_unit, item_material_id, currency
invoice_id, sort_order, item_name, item_units, item_uom_id, price_per_unit, item_material_id,
item_type_id, item_status_id,
currency
) values (
nextval('im_invoice_items_seq'),
:cost_id, :sort_order, :item_name, :item_units, :item_uom_id, :price_per_unit, :item_material_id, :currency
:cost_id, :sort_order, :item_name, :item_units, :item_uom_id, :price_per_unit, :item_material_id, :
item_type_id, :item_status_id, :
currency
)
"
}
else
{
...
...
@@ -328,6 +329,8 @@ foreach csv_line_fields $values_list_of_lists {
item_uom_id = :item_uom_id,
price_per_unit = :price_per_unit,
item_material_id = :item_material_id,
item_type_id = :item_type_id,
item_status_id = :item_status_id,
currency = :currency
where
item_id = :item_id;
...
...
@@ -338,12 +341,10 @@ foreach csv_line_fields $values_list_of_lists {
continue
}
# ------------------------------------------------------------------------
# We have found a line with a normal invoice
(
quote, invoice, purchase order, ...
)
#
# -------------------------------------------------------
# Specific field transformations
...
...
@@ -351,7 +352,7 @@ foreach csv_line_fields $values_list_of_lists {
if
{
""
==
$cost
_name
}
{
if
{
$ns
_write_p
}
{
ns_write
"<li><font color=red>Error: We have found an empty 'Cost Name' in line
$cnt.
<br>
Please correct the CSV file. Every costs needs to have a unique Cost Name.</font>
\n
"
Skipped record.
Please correct the CSV file. Every costs needs to have a unique Cost Name.</font>
\n
"
}
continue
}
...
...
@@ -364,7 +365,7 @@ foreach csv_line_fields $values_list_of_lists {
if
{
""
==
$cost
_type_id
}
{
if
{
$ns
_write_p
}
{
ns_write
"<li><font color=red>Error: We have found an empty 'Cost Type' in line
$cnt.
<br>
Please correct the CSV file.</font>
\n
"
Skipped record.
Please correct the CSV file.</font>
\n
"
}
continue
}
...
...
@@ -385,14 +386,14 @@ foreach csv_line_fields $values_list_of_lists {
if
{
""
==
$provider
_id
}
{
if
{
$ns
_write_p
}
{
ns_write
"<li><font color=red>Error: We have found an empty 'Provider' in line
$cnt.
<br>
Please correct the CSV file.</font>
\n
"
Skipped record.
Please correct the CSV file.</font>
\n
"
}
continue
}
if
{
""
==
$customer
_id
}
{
if
{
$ns
_write_p
}
{
ns_write
"<li><font color=red>Error: We have found an empty 'Customer' in line
$cnt.
<br>
Please correct the CSV file.</font>
\n
"
Skipped record.
Please correct the CSV file.</font>
\n
"
}
continue
}
...
...
@@ -481,10 +482,13 @@ foreach csv_line_fields $values_list_of_lists {
im_audit -object_id
$cost
_id -action after_create
}
else
{
if
{
$ns
_write_p
}
{
ns_write
"<li>Cost already exists: name='
$cost
_name', nr='
$cost
_nr', id='
$cost
_id'
\n
"
}
if
{
$ns
_write_p
}
{
ns_write
"<li>Cost already exists: name='
$cost
_name', nr='
$cost
_nr', id='
$cost
_id'</li>
\n
"
}
if
{
!$overwrite_existing_invoice_attributes_p
}
{
if
{
$ns
_write_p
}
{
ns_write
"<li>You have choosen not to overwrite/update already existing objects. Skipping record.</li>
\n
"
}
continue
}
}
if
{
$ns
_write_p
}
{
ns_write
"<li>Going to update the cost.
\n
"
}
if
{[
catch
{
db_dml update_cost
"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment