Commit 0306594e authored by Frank Bergmann's avatar Frank Bergmann

-- improvements and extensions

parent 26d139fa
......@@ -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
}
......
......@@ -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">&nbsp;</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>
......
......@@ -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 "
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment