::namespace eval ::qw::print { ::proc ::qw::print::debug_puts {Src} { ::if {$::qw::verbose(print)} {::puts "(::qw::print [::clock format [::clock seconds] -format {%H %M %S}]) $Src";} } } ::sargs::var::set ::qw::options ".print.template.user_variables" 64; ::sargs::var::set ::qw::options ".print.template.user_item_variables" 64; ::itcl::class ::qw::print::collection { protected variable _kids ""; protected variable _owner ""; protected variable _is_destroying 0; constructor {args} { ::set _is_destroying 0; } destructor { ::if {[is_being_destroyed]} { ::qw::throw "$this destructor called but object is already being destroyed."; } kidsDestroy; } public method is_being_destroyed {} { ::return $_is_destroying; } public method init {} { ::return $this; } method kid_class {} {::return [::qw::throw "Error: $this [lindex [info level 0] 0] is virtual"];} method kid_type {} {::return [::qw::throw "Error: $this [lindex [info level 0] 0] is virtual"];} public method owner_Set {Src} { ::set _owner $Src; ::return $this; } public method owner_Get {} { ::return $_owner; } method kids {} { ::return $_kids; } method kidAttach {Src} { ::lappend _kids $Src ::return $this; } method kidDetach {Src} { ::set Index [::lsearch -exact $_kids $Src]; ::if {$Index<0} { ::qw::throw "Assert: kid $Src not found in list."; } ::set _kids [::lreplace $_kids $Index $Index]; ::return $this; } method kidsDestroy {} { ::foreach Kid $_kids {kidDestroy $Kid;} ::if {[::llength $_kids]} { ::qw::throw "Kids \"$_kids\" did not detach."; } ::return $this; } method kidDestroy {Src} { ::if {[$Src is_being_destroyed]} { ::qw::throw "$this kidDestroy attempted to destroy $Src but it is already being destroyed."; } ::itcl::delete object $Src; ::return $this; } public method kidFirst {} { ::return [::lindex $_kids 0]; } public method kidNext {Src} { ::set Index [::lsearch -exact $_kids $Src]; ::if {$Index<0} { ::qw::throw "Error: [kid_type] kid $Src not found."; } ::return [::lindex $_kids [::expr $Index+1]]; } public method item {Name} { ::for {::set Kid [kidFirst]} {$Kid ne ""} {::set Kid [kidNext $Kid]} { ::if {[$Kid name_Get] eq $Name} { ::return $Kid; } } ::qw::throw "Error: item $Name not found."; } public method items {} { ::return [::llength $_kids]; } public method names {} { ::set Result ""; ::foreach Kid $_kids { ::lappend Result [$Kid name_Get]; } ::return $Result; } public method exists {Src} { ::if {[::lsearch -exact [names] $Src]>=0} { ::return 1; } ::return 0; } public method factory {args} { ::array set Args $args; ::if {[::info exists Args(-kid_class)]} { ::set Kid_Class $Args(-kid_class); ::unset Args(-kid_class); } else { ::set Kid_Class [kid_class]; } ::for {::set Kid [kidFirst]} {$Kid ne ""} {::set Kid [kidNext $Kid]} { ::if {[$Kid info class] ne $Kid_Class} {::continue;} ::if {[$Kid state] eq "active"} {::continue;} ::return $Kid; } ::set Kid [::eval $Kid_Class ${Kid_Class}::#auto [::array get Args]]; $Kid collection_owner_Set $this; ::return $Kid; } public method destroy {Src} { kidDestroy $Src; ::return $this; } } ::itcl::class ::qw::printers { inherit ::qw::print::collection; private variable _default ""; private variable _selected ""; private variable _flags ""; constructor {args} { ::eval ::qw::print::collection::constructor $args; } { ::eval configure $args; } destructor { } public method default {} { ::return $_default; } public method selected {} { ::return $_selected; } public method init {} { chain; refresh; ::return $this; } public method item {Name} { ::if {[::catch {::set Item [chain $Name]} ErrorMdg]} { ::qw::throw "Printer \"$Name\" not found."; } ::return $Item; } public method printer_exists {Name} { ::for {::set Kid [kidFirst]} {$Kid ne ""} {::set Kid [kidNext $Kid]} { ::if {[::string first $Name [$Kid excelname]]==0} {::return 1;} } ::return 0; } public method item_from_excel_name {Name} { ::for {::set Kid [kidFirst]} {$Kid ne ""} {::set Kid [kidNext $Kid]} { ::if {[::string first $Name [$Kid excelname]]==0} {::return $Kid;} } ::return ""; ::qw::throw "Error: item $Name not found."; } public method handleToName {Handle} { ::foreach Attribute [::printer attr $Handle] { ::if {[::lindex $Attribute 0] eq "device"} { ::return [::lindex $Attribute 1]; } } ::return ""; } public method default_Get {} { ::return $_default; } public method refresh {} { kidsDestroy; ::set _default ""; ::set DefaultName ""; ::set DefaultHandle ""; ::set DefaultHandle [::printer open]; ::if {$DefaultHandle ne ""} { ::set DefaultName [handleToName $DefaultHandle]; } ::if {$::tcl_platform(osVersion)<4.0} { ::qw::throw "Attempted to print on unsupported platform $::tcl_platform(os) version $::tcl_platform(osVersion)."; } ::foreach Printer [::registry values {HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Devices}] { ::set PortInfo [::registry get {HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Devices} $Printer]; ::foreach {Trash Port} [::split $PortInfo ","] {;} ::set PrinterName $Printer; ::if {$Port ne ""} { ::append PrinterName " on $Port"; } ::set Kid [factory -name $Printer -excelname $PrinterName]; ::if {[::string first $DefaultName $Printer]==0} { ::set _default $Kid; } } ::return $this; } method kid_class {} {::return "::qw::printer";} public method select {} { ::if {$_flags eq ""} { ::set Results [::printer dialog "select"]; } else { ::set Results [::printer dialog "select" -flags $_flags] } ::foreach {HDC Result} $Results {;} ::if {!$Result} { ::return ""; } ::set _selected ""; ::set SelectedName [handleToName $HDC]; ::foreach Name [names] { ::if {[::string first $SelectedName $Name]==0} { ::set _selected [item $Name]; $_selected configure -handle $HDC; ::return $_selected; } } ::qw::throw "Could not find printer \"$SelectedName\" in printers \"[names]\"."; } } ::itcl::class ::qw::printer { public method collection_owner_Set {Src} { ::set _owner $Src; $_owner kidAttach $this; ::return $this; } public method collection_owner_Get {} { ::return $_owner; } private variable _owner ""; private variable _attributes ""; protected variable _is_destroying 0; public variable handle ""; public variable excelname ""; public variable name ""; protected variable _state "inactive"; constructor {args} { ::set _is_destroying 0; ::set _state "active"; ::eval configure $args; ::unset -nocomplain _attributes; ::array set _attrubutes {}; } destructor { ::if {[is_being_destroyed]} { ::qw::throw "$this destructor called but object is already being destroyed."; } ::set _is_destroying 1; $_owner kidDetach $this; } public method is_being_destroyed {} { ::return $_is_destroying; } public method state {} { ::return $_state; } public method name {} { ::return $name; } public method name_Get {} { ::return $name; } public method excelname {} {::return $excelname;} public method refresh {} { ::array unset _attributes; ::foreach Item [attributes_Get] { ::foreach {Name Value} $Item {;} ::set _attributes($Name) $Value; } ::return $this; } public method attribute_Set {Name Value} { refresh; ::if {![::info exists _attributes($Name)]} { ::qw::throw "Unknown printer attribute \"$Name\"."; } ::return [printer_command_attr [::sargs ".set" "$Name $Value"]]; } public method attribute_Get {Name} { refresh; ::if {![::info exists _attributes($Name)]} { ::qw::throw "Unknown printer attribute \"$Name\"."; } ::return $_attributes($Name); } public method attributes_Set {Src} { ::return [printer_command_attr [::sargs ".set" $Src]]; } public method attributes_Get {{Src {get}}} { ::return [printer_command_attr [::sargs ".set" $Src]]; } public method printer_command_attr {s_args} { ::set Command "::printer attr -hDC [printer_command_open]"; ::set GetArgs [::sargs::get $s_args ".get"]; ::if {$GetArgs ne ""} {::append Command "-get $GetArgs";} ::set SetArgs [::sargs::get $s_args ".set"]; ::if {$SetArgs ne ""} {::append Command "-set $SetArgs";} ::return [::eval $Command]; } public method printer_command_open {} { ::if {$handle ne ""} {::return $handle;} ::return [::printer open -name $name] } } ::itcl::class ::qw::print { protected variable _owner ""; protected variable _database ""; protected variable _seconds 0; protected variable _process_status "active"; protected variable _options ""; protected variable _is_destroying 0; protected variable _state "inactive"; public variable destination "display" {configure_destination $destination;} public variable filename "" {configure_filename $filename;} public variable progress_window ""; public variable printer "" {configure_printer $printer;} public variable print_job_name ""; public variable print_when "now" {configure_print_when $print_when;} public variable template ""; public variable prompt_settings "" {configure_prompt_settings $prompt_settings;} method configure_prompt_settings {Src} {} method configure_printer {Src} { ::if {$Src eq ""} { ::set printer [$::nv2::print::printers default_Get]; ::return; } ::set printer [$::nv2::print::printers item_from_excel_name $Src]; ::if {$printer eq ""} { ::set printer [$::nv2::print::printers default_Get]; } } method configure_destination {Src} { ::switch -- $Src { "email" - "display" - "preview" - "printer" - "file" {;} default { ::qw::throw "Invalid destination \"$Src\". -destination must be one of \"display\", \"email\", \"file\", \"preview\", or \"printer\"."; } } } method configure_filename {Src} { ::if {$Src ne ""} { ::if {[::file exists $Src]} { ::if {[::file isdirectory $Src]} {::qw::throw "Cannot create file \"$Src\", a directory by that name already exists.";} ::if {![::file writable $Src]} {::qw::throw "Cannot overwrite existing file \"$Src\", permission denied.";} } } } method configure_print_when {Src} { ::switch -- $Src { "now" - "end" - default {::qw::throw "Invalid print_when \"$Src\". -print_when must be one of \"now\" or \"end\".";} } } constructor {args} { ::set _is_destroying 0; ::set _state "active"; } destructor { ::if {[is_being_destroyed]} { ::qw::throw "$this destructor called but object is already being destroyed."; } ::set _is_destroying 1; ::if {$_owner ne ""} { $_owner kidDetach $this; } } public method is_being_destroyed {} { ::return $_is_destroying; } public method init {} { ::return $this; } public method collection_owner_Set {Src} { ::set _owner $Src; $_owner kidAttach $this; ::return $this; } public method collection_owner_Get {} { ::return $_owner; } public method done {} { ::unset -nocomplain progress_window; ::set progress_window ""; ::set _state "inactive"; ::return $this; } public method state {} { ::return $_state; } public method print_show {} { ::return $this; } public method print_preview {} { ::return $this; } public method database_Set {Src} { ::set _database $Src; ::return $this; } public method database_Get {} { ::return $_database; } public method manager {} { ::return [$_database cpp_manager] } public method load {Src} { ::return $this; } public method abort_check {} { ::if {![aborted]} {::return 0;} ::qw::throw ".text {Printing was aborted by user.} .id aborted_by_user"; } public method aborted {} { ::if {$_process_status eq "aborted"} {::return 1;} ::return 0; } public method active {} { ::if {$_process_status eq "active"} {::return 1;} ::return 0; } public method abort {} { ::set _process_status "aborted"; ::return $this; } public method now {} { ::return [::qw::date::from_number clock_second [::clock seconds]]; } public method _DATABASE {args} {::return [::file nativename [[database_Get] cpp_directory]];} public method _COMPUTERNAME {args} {::return $::env(COMPUTERNAME);} public method _USERNAME {args} { ::set User [[database_Get] cpp_user_get]; ::if {$User eq ""} { ::return ""; } ::return [[$User ".name"] odb_get]; } public method _USERDESCRIPTION {args} { ::set User [[database_Get] cpp_user_get]; ::if {$User eq ""} { ::return ""; } ::return [[$User ".description"] odb_get]; ::set Address [[database_Get] cpp_user_address_get]; ::if {$Address eq ""} {::return "";} ::return [[$Address ".description"] odb_get]; } method number_or_blank_if_zero {Src} { ::if {$Src eq ""} {::return "";} ::if {![::string is double $Src]} {::return $Src;} ::if {$Src==0.0} {::return "";} ::return $Src; } } ::itcl::class ::qw::print::windows { inherit ::qw::print; constructor {args} { ::eval ::qw::print::constructor $args; } { } destructor { } public method abort {} { chain; ::return $this; } public method init {} { chain; ::return $this; } public method pagesetup {Name Value} { ::return $this; } public method done {} { chain; } } ::itcl::class ::qw::print::windows::table { inherit ::qw::print::windows; protected variable _excel ""; protected variable _excel_workbooks ""; protected variable _workbook ""; protected variable _excel_sheets ""; protected variable _sheet ""; protected variable _pagesetup ""; protected variable _ranges ""; protected variable _range ""; protected variable _columns ""; protected variable _column ""; protected variable _cells ""; protected variable _cell ""; protected variable _sheet_start_row 0; protected variable _sheet_start_column 0; protected variable _application_database "" protected variable _extra_sheets ""; protected variable _sheets_to_print ""; protected variable _sheets_done 0; protected variable _content_rectangle ""; protected variable _column_names ""; protected variable _column_titles ""; protected variable _column_definition_tree ""; protected variable _start_line 0; protected variable _end_line 0; protected variable _selection_pair_list ""; protected variable _items 0; protected variable _pagesetup_structure ""; protected variable _row_values ""; protected variable _table_row "0"; protected variable _sheet_row 0; protected variable _sheet_column 0; protected variable _column_type_list ""; public variable settings ""; public method content_rectangle {} { ::return $_content_rectangle; } protected variable _phony_total_row 0; protected variable _print_line_numbers_column_index -1; ;#//nv2.29.0 public variable window "" {configure_window $window;} public variable printrange "" {configure_printrange $printrange;} public variable date_format "dd month yyyy"; public variable currency_format $::qw::number::formats(dollar_minus_parentheses) {configure_currency_format $currency_format;} public variable columntitles ""; public variable prompt_window "" {configure_prompt_window $prompt_window;} method configure_currency_format {Src} { ::if {![::info exists ::qw::number::formats($Src)]} { ::qw::throw "Invalid -currency_format $Src"; } } method configure_window {Src} { database_Set [$Src odb_database]; ::if {![$Src odb_is_a [[database_Get] "/OBJECT/SYSTEM/WINDOW/SCROLLED/TABLE"]]} { ::qw::throw "-window is not a table."; } } method configure_prompt_window {Src} { } method configure_printrange {Src} { ::if {$Src ne "block"&&$Src ne "all"} { ::qw::throw "Invalid -printrange option \"$Src\". -range must be \"all\" or \"block\"."; } } constructor {args} { ::eval ::qw::print::windows::constructor $args; } { pagesetup_defaults_set; } destructor { ::if {$_excel ne ""} { [::qw::get_com_applications] destroy $_excel; ::set _excel ""; } } public method init {} { ::set StopWatch [::itcl::local ::QW::STOPWATCH #auto]; chain; ::if {$_excel eq ""} { ::qw::try { ::set _excel [[::qw::get_com_applications] factory -application "Excel"]; } catch Exception { ::set _excel ""; ::qw::throw $Exception; } } else { $_excel activate; } ::set _excel_workbooks [$_excel workbooks]; ::qw::try { ::switch [::sargs::get $_pagesetup_structure ".workbook_sheet_control"] { "new_none" { ::if {[[$_excel workbooks] selected] eq ""} { workbook_select [workbook_new]; ::if {$_sheets_done==0} { ::set Sheets [$_workbook sheets]; ::for {::set Sheet [$Sheets kidFirst]} {$Sheet ne ""} {::set Sheet [$Sheets kidNext $Sheet];} { ::lappend _extra_sheets $Sheet; } } ::set _sheets_to_print ""; init_next_sheet; ;#// ...::table::postings overrides to do nothing, it is controlling sheets ::return $this; } workbook_select [[$_excel workbooks] selected]; ::if {[[[[$_excel workbooks] selected] sheets] selected] eq ""} { ::qw::throw [::sargs \ .text "No sheet is active. (Most likely, Excel is broken.)" \ .help_id 0 \ ]; } sheet_select [[[[$_excel workbooks] selected] sheets] selected]; position_to_end_of_sheet; ::return $this; } "" - "new_workbook" { workbook_select [workbook_new]; ::if {$_sheets_done==0} { ::set Sheets [$_workbook sheets]; ::for {::set Sheet [$Sheets kidFirst]} {$Sheet ne ""} {::set Sheet [$Sheets kidNext $Sheet];} { ::lappend _extra_sheets $Sheet; } } ::set _sheets_to_print ""; init_next_sheet; ;#// ...::table::postings overrides to do nothing, it is controlling sheets ::return $this; } "new_sheet" { ::if {[[$_excel workbooks] selected] eq ""} { workbook_select [workbook_new]; ::if {$_sheets_done==0} { ::set Sheets [$_workbook sheets]; ::for {::set Sheet [$Sheets kidFirst]} {$Sheet ne ""} {::set Sheet [$Sheets kidNext $Sheet];} { ::lappend _extra_sheets $Sheet; } } ::set _sheets_to_print ""; init_next_sheet; ;#// ...::table::postings overrides to do nothing, it is controlling sheets ::return $this; } ::qw::try { workbook_select [[$_excel workbooks] selected]; init_next_sheet; ;#// ...::table::postings overrides to do nothing, it is controlling sheets ::return $this; } catch Exception { ::qw::throw $Exception; } } "new_page" { workbook_select [[$_excel workbooks] selected]; sheet_select [[[[$_excel workbooks] selected] sheets] selected]; position_to_end_of_sheet; page_break_insert; } } } catch Exception { ::if {$_excel ne ""} { [::qw::get_com_applications] destroy $_excel; ::set _excel ""; ::set _sheet ""; } ::qw::throw $Exception; } ::return $this; } public method position_to_end_of_sheet {} { ::set Cells [$_sheet cells]; ::set Cell [$Cells factory]; ::set TotalRows 1; ::set Blanks 0; ::while {$TotalRows<65536} { $Cell point_Set ".x 0 .y $TotalRows"; ::set Value [$Cell value_Get]; ::if {$Value eq ""} { ::incr Blanks; ::if {$Blanks>=10} { ::set TotalRows [::expr {$TotalRows-$Blanks}]; ::break; } } else { ::set Blanks 0; } ::incr TotalRows; } ::incr TotalRows 1; ::incr TotalRows 1; ::set _sheet_row $TotalRows; ::set _sheet_column 0; } public method init_next_sheet {} { sheet_select [sheet_new]; ;#//::qw::print::windows::table::doit default behaviour is to always sheet_new - NOT anymore ::if {[$window observer_database] ne ""} { ::set Name [[[[$window observer_database] odb_master] ".name"] odb_get]; ::if {$Name eq ""} { ::set Name [::string map {/ ""} [[[$window observer_database] odb_master] odb_id_readable]]; ::switch -glob -- [[[$window observer_database] odb_master] odb_path] { "/OBJECT/NEWVIEWS/SYSTEM/EMPLOYEE/CANADA/*" { } } } $_sheet name_Set $Name; ;#// name_Set manages 31 char max, duplicates of "NAME" have "NAME (2)" etc. } ::return $this; } public method workbook_items {} { ::return [[$_excel Workbooks] Count]; } public method workbook_names {} { ::set Result "" ::foreach Item [::sargs::subs .structure [::sargs::get $_control ".workbooks"]] { ::lappend Result $Item; } ::return $Result; } public method workbook_new {{Filename ""}} { ::if {$Filename eq ""} { ::return [$_excel_workbooks factory]; } ::qw::try { ::return [$_excel_workbooks factory -filename $Filename]; } catch Exception { ::qw::throw [::sargs \ .text "Could not open file $Filename, $Exception" \ .help_id 907020050517120300 \ ]; } } public method workbook_select {Src} { ::set _workbook [$_excel_workbooks select $Src]; $_workbook activate; ::set _excel_sheets [$_workbook sheets]; ::set Sheet [$_excel_sheets selected]; ::if {$Sheet eq ""} { ::set Sheet [$_excel_sheets kidFirst [::sargs ".kid_create" 1]]; } sheet_select $Sheet; ::return $_workbook; } public method sheet_names {} { ::set Selected [::sargs::get $_control ".workbooks.selected"]; ::if {$Selected eq ""} { ::qw::throw "Attempted to get sheet names with no workbook selected"; } ::set Result "" ::foreach Item [::sargs::subs .structure [::sargs::get $_control ".workbooks$Selected.sheets"]] { ::lappend Result $Item; } ::return $Result; } public method sheet_items {} { ::set Selected [::sargs::get $_control ".workbooks.selected"]; ::if {$Selected eq ""} { ::qw::throw "Attempted to get sheet item count no workbook selected"; } ::return [::sargs::get $_control ".workbooks$Selected.sheets.items"]; } public method sheet_new {} { ::return [$_excel_sheets factory]; } public method sheet_deselect {} { ::if {$_sheet eq ""} {::return;} ::set Selected [::sargs::get $_control ".workbooks.selected"]; ::if {$Selected eq ""} { ::qw::throw "Attempted to deselect a sheet with no workbook selected"; } ::foreach Sheet [::sargs::subs .structure [::sargs::get $_control ".workbooks$Selected.sheets"]] { ::if {[::sargs::get $_control ".workbooks$Selected.sheets$Sheet.handle"] eq $_sheet} { ::sargs::var::set _control ".workbooks$Selected.sheets/$Sheet.row" $_sheet_row; ::sargs::var::set _control ".workbooks$Selected.sheets/$Sheet.column" $_sheet_column; ::sargs::var::set _control ".workbooks$Selected.sheets.selected" ""; ::set _sheet ""; ::return; } } ::qw::throw "Could not deselect sheet $_sheet, sheet not found."; } public method sheet_select {Src} { ::if {$_sheet eq $Src} {::return $_sheet;} ::if {$_sheet ne ""} { ::set Clientdata [$_sheet clientdata]; ::sargs::var::set Clientdata ".current_row" $_sheet_row; ::sargs::var::set Clientdata ".current_column" $_sheet_column; $_sheet clientdata $Clientdata } ::set _sheet [$_excel_sheets select $Src]; $_sheet activate; ::set Clientdata [$Src clientdata]; ::set _sheet_row [::sargs::get $Clientdata ".current_row"]; ::set _sheet_column [::sargs::get $Clientdata ".current_column"]; ::set _pagesetup [$_sheet pagesetup]; ::set _columns [$_sheet columns]; ::set _rows [$_sheet rows]; ::set _cells [$_sheet cells]; ::set _ranges [$_sheet ranges]; ::set _column [$_columns kidFirst [::sargs ".kid_create" 1]]; ::set _row [$_rows kidFirst [::sargs ".kid_create" 1]]; ::set _cell [$_cells kidFirst [::sargs ".kid_create" 1]]; ::set _range [$_ranges kidFirst [::sargs ".kid_create" 1]]; $_range rectangle_Set {.size {.x 1 .y 1} .position {.x 1 .y 1}}; ::return $_sheet; } public method sheet_destroy {Src} { } public method abort {} { $_workbook mark_file_saved; chain; ::return $this; } public method printer_Set {Src} { ::if {$Src eq ""} { ::return; } $_excel active_printer_Set [$Src excelname]; ::return $this; } public method printer_Get {} { ::set PrinterName [$_excel active_printer_Get]; ::return [$::nv2::print::printers item_from_excel_name $PrinterName]; } public method set_print_range {Src} { $_sheet print_range_Set $Src; ::return $this; } public method get_print_range {} { ::return [$_sheet print_range_Get]; } public method can_print {} { ::if {[$_excel active_printer_Get] eq ""} {::return 0;} ::return 1; } public method page_break_insert {args} { ::set Row [::lindex $args 0]; ::if {$Row eq ""} {::set Row $_sheet_row;} $_sheet page_break_insert $Row; } public method print {} { ::while {$_sheets_to_print ne ""} { abort_check; ::set Sheet [::lindex $_sheets_to_print 0]; ::set _sheets_to_print [::lreplace $_sheets_to_print 0 0]; $Sheet print; } ::return $this; } public method print_show {} { abort_check; $_workbook activate; $_excel visible_Set 1; ::return $this; } public method print_preview {} { abort_check; $_sheet print_preview; ::return $this; } public method activate_top_left {} { $_range rectangle_Set {.position {.x 0 .y 0} .size {.x 1 .y 1}}; ::while {[$_range merged]} {$_range yIncrement 1;} $_range select; } public method done {} { mark_file_saved; ::switch -- $destination { "display" {print_show;} "preview" {print_preview;} "printer" { print; file_save; ;#// the file has no name and just closing seems to work file_close; } "file" { ::if {[::file extension $filename] ne ".pdf"} { file_save; } file_close; } } [::qw::get_com_applications] destroy $_excel; ::set _excel ""; ::set _sheet ""; chain; } public method column_width_characters {Column Width} { abort_check; ::return [column_width_characters_Set $Column $Width]; } public method column_width_characters_Get {Column} { abort_check; $_column column_Set $Column; ::return [$_column width_characters_Get]; } public method column_width_characters_Set {Column Width} { abort_check; $_column column_Set $Column; $_column width_characters_Set $Width; ::return $this; } public method column_width_points {Column Width} { abort_check; $_column column_Set $Column; $_column width_points_Set $Width; ::return $this; } public method row_height_Set {Row Height} { abort_check; [$_row row_Set $Row] height_Set $Height; ::return $this } public method range_justify {Range Justify} { ::return [range_horizontal_justify $Range $Justify]; abort_check; ::if {$Justify eq "left"} {::set Justify "general";} [$_range rectangle_Set $Range] alignment_horizontal_Set $Justify; ::return $this; } public method range_format {Range Format} { abort_check; $_range rectangle_Set $Range; $_range format_Set $Format; ::return $this; } public method range_border_Set {Range s_args} { abort_check; [$_range rectangle_Set $Range] border_Set $s_args; ::return $this; } public method range_value_Set {Rectangle Value} { abort_check; [$_range rectangle_Set $Rectangle] value_Set $Value; ::return $this; } public method range_types_Set {Src} { $_range value_type_list $Src; } public method cell_value_Set {Point Value} { abort_check; [$_cell point_Set $Point] value_Set $Value; ::return $this; } public method file_save {} { abort_check; $_excel display_alerts 0; $_workbook file_save; } public method file_close {} { $_workbook mark_file_saved; $_workbook close; } public method mark_file_saved {} { abort_check; $_workbook mark_file_saved; } public method pagesetup {Name Value} { $_pagesetup $Name $Value; ::return $this; } public method range_font_Set {Rectangle args} { abort_check; $_range rectangle_Set $Rectangle; ::eval $_range font_Set $args; ::return $this; } public method cell_font_Set {Point Value} { abort_check; [$_cell point_Set $Point] font_Set $Value; ::return $this; } public method range_merge {Rectangle Src} { [$_range rectangle_Set $Rectangle] merge $Src; ::return $this; } public method range_horizontal_justify {Rectangle Src} { ::if {$Src eq ""} { ::set Src "left"; } [$_range rectangle_Set $Rectangle] horizontal_justify $Src; ::return $this; } public method range_vertical_justify {Rectangle Src} { [$_range rectangle_Set $Rectangle] vertical_justify $Src; ::return $this; } public method title_rows {s_args} { pagesetup printtitlerows $s_args; } public method page_setup {args} { ::if {[::llength $args]==0} { ::return $_pagesetup_structure; } ::if {[::llength $args]==1} { ::set _pagesetup_structure [::lindex $args 0]; ::return; } ::if {[::expr [::llength $args]%2]} {::qw::throw "Expected an even number of name/value args.";} ::foreach {Path Value} $args { ::if {![::sargs::exists $_pagesetup_structure $Path]} { ::if {[::string first ".document_title" $Path]<0} { ::qw::throw "Invalid pagesetup path \"$Path\"."; } } ::sargs::var::set _pagesetup_structure $Path $Value; } } public method doit {} { ::if {$window eq ""} {::qw::throw "-window has not been configured.";} ::if {$prompt_window eq ""} { ::qw::throw "-prompt_window has not been configured."; } ::if {$printrange eq ""} { ::qw::throw "-printrange has not been configured."; } ::if {$destination eq "file"&&$filename eq ""} { ::qw::throw "-destination is \"file\", but -filename has not been set."; } ::set StopWatch [::itcl::local ::QW::STOPWATCH #auto]; ::set _column_names [[$window ".column_names"] odb_get]; ::set _column_titles [[$window ".client"] dataInterfaceRowTitle]; ::set _column_definition_tree [$window columnDefinitionTree]; ::set _print_line_numbers_column_index -1; ::if {[::sargs::get $_pagesetup_structure ".print_line_numbers"] eq "no"} { ::set Index [::lsearch -exact $_column_names "/line"]; ::if {$Index>=0} { ::set _column_names [::lreplace $_column_names $Index $Index]; ;#// lremove ::set _column_titles [::lreplace $_column_titles $Index $Index]; ;#// lremove ::set _print_line_numbers_column_index $Index; } } ::if {$printrange eq "block"} { ::if {[$window block_start_line] eq ""} { ::set _items 0; } else { ::if {[[$window ".observer_index_direction"] odb_get] eq "forward"} { ::set _start_line [$window dataInterface_tableRow [$window block_start_line]]; ::set _end_line [$window dataInterface_tableRow [$window block_end_line]]; } else { ::set _end_line [$window dataInterface_tableRow [$window block_start_line]]; ::set _start_line [$window dataInterface_tableRow [$window block_end_line]]; } ::set _items [::expr 1+$_end_line-$_start_line]; } ::set _items [$prompt_window block_items]; } else { ::set _items [$window observer_rows]; ::set _start_line 1; ::set _end_line $_items; } ::set OldSheet $_sheet; init; ;#// creates a new sheet ::if {$destination eq "printer"&&$OldSheet ne ""&&$print_when eq "now"} { [$OldSheet owner_Get] kidDestroy $OldSheet ".destroy_peer 1"; } ::foreach Sheet $_extra_sheets { $Sheet visible 0; } ::set _extra_sheets ""; ::if {$print_job_name ne ""} { $_sheet name_Set $print_job_name; } ::if {$destination eq "file"} { ::set filename [::file nativename $filename]; ::set State [$_excel display_alerts]; $_excel display_alerts 0; $_workbook name_Set $filename; $_excel display_alerts $State; } pagesetup_initialize; ::set RectangleFilled $_content_rectangle; ::sargs::var::set RectangleFilled ".position.y" $_sheet_row ".size.y" 0; ::sargs::var::set RectangleFilled ".size.y" $_items; ::if {$_items} { print_rows; } pagesetup_finalize; ::sargs::var::set RectangleFilled ".size.y" [::expr {[::sargs::get $RectangleFilled ".size.y"]+[::sargs::get $RectangleFilled ".position.y"]}]; ::sargs::var::set RectangleFilled ".position.y" 0; $_range rectangle_Set $RectangleFilled; $_range autofit; ::lappend _sheets_to_print $_sheet; ::incr _sheets_done; ::switch -- $destination { "file" { ::set filename [::file nativename $filename]; ::set State [$_excel display_alerts]; $_excel display_alerts 0; ::set Slist ""; ::if {[$window observer_database] eq ""} { ::lappend Slist %_name "noname"; ::lappend Slist %_description "nodescription"; } else { ::switch -glob [[[$window observer_database] odb_master] odb_path] { /OBJECT/NEWVIEWS/SYSTEM/EMPLOYEE* { ::set Tname [[[[$window observer_database] odb_master] .employee_id] odb_get]; ::set Tdescription [[[[$window observer_database] odb_master] .employee_name.print_as] odb_get]; } default { ::set Tname [[[[$window observer_database] odb_master] .name] odb_get]; ::set Tdescription [[[[$window observer_database] odb_master] .description] odb_get]; } } ::lappend Slist %_name "[::string map {" " _ , _ . _} $Tname]"; ::lappend Slist %_description "[::string map {" " _ , _ . _} $Tdescription]"; } ::lappend Slist %_clock [::qw::date::from_number clock_second [::clock seconds]]; ::set filename [::string map $Slist $filename]; $_workbook name_Set $filename; $_excel display_alerts $State; ::if {[::file extension $filename] eq ".pdf"} { ::if {[$_excel version_Get]>=12.0} { $_sheet handle_method "ExportAsFixedFormat" "0" "$filename"; } } } "printer" { ::if {$print_when eq "now"} { ::if {$printer eq ""} { ::set printer [$::nv2::print::printers default_Get]; } printer_Set $printer; print; } } } } method pagesetup_initialize {} { load_template_settings; pagesetup_document_title_set; pagesetup_column_titles_set; pagesetup_column_widths_set; pagesetup_column_types_set; pagesetup_margins_set; pagesetup_header_and_footer_set; pagesetup_page_layout_set; ::set _content_rectangle [::list .position [::list .x $_sheet_start_column .y $_sheet_row] .size [::list .x [::llength $_column_titles] .y $_items]]; pagesetup_column_formats_set; pagesetup_column_justifications_set; } public method pagesetup_page_layout_set {} { ::set Orientation [::sargs::get $_pagesetup_structure ".orientation"]; pagesetup orientation $Orientation; ::set Scaling [::sargs::get $_pagesetup_structure ".scaling"]; ::if {$Scaling ne ""&&$Scaling!=0} { pagesetup scaling $Scaling; ::return; } ::set Fit [::sargs::get $_pagesetup_structure ".fit_to_pages_wide"]; ::if {$Fit ne ""&&$Fit!=0} { pagesetup scaling 0; pagesetup fittopageswide $Fit; pagesetup fittopagestall 512; } } public method pagesetup_header_and_footer_set {} { ::foreach End {header footer} { ::foreach Position {left center right} { ::set Text [::sargs::get $_pagesetup_structure ".page_$End.$Position"]; ::if {$Text ne ""} {pagesetup $Position$End $Text;} } } } public method pagesetup_margins_set {} { ::foreach Side {top right bottom left header footer} { ::if {![::sargs::exists $_pagesetup_structure ".margin/$Side"]} { ::continue; } ::set Margin [::sargs::get $_pagesetup_structure ".margin/$Side"]; ::if {$Margin>=0} { pagesetup ${Side}margin $Margin; } } } public method pagesetup_column_types_set {} { ::set _column_type_list ""; ::foreach ColumnName $_column_names { ::if {[::string first "/OBJECT/SYSTEM/WINDOW/SCROLLED/TABLE/NOTES" [$window odb_path]]!=0} { ::set GetScript [::sargs::get $_column_definition_tree "$ColumnName.script/command/get"]; ::if {[::sargs::get $_column_definition_tree "$ColumnName.rb_name"] eq ".contact_duration"} { ::lappend _column_type_list ""; ::continue; } ::if {[::string first "::qw::time::formats" $GetScript]>=0} { ::lappend _column_type_list ""; ::continue; } ::if {[::string first "::qw::date::format" $GetScript]>=0} { ::lappend _column_type_list "date"; ::continue; } } ::if {[::string first "/formula_" $ColumnName]==0} { ::lappend _column_type_list "formula"; ::continue; } ::if {[::string first "/range_amount_" $ColumnName]==0} { ::lappend _column_type_list "amount"; ::continue; } ::lappend _column_type_list ""; } } public method pagesetup_column_formats_set {} { ::set Column $_sheet_start_column; ::set Index 0; ::set Rectangle $_content_rectangle; ::sargs::var::set Rectangle ".size.x" 1; ::foreach Format [column_formats] { ::switch [::lindex $_column_type_list $Index] { "date" { ::set Format $date_format; } default { ::if {[::string first "dollar" [::subst $Format]]>=0} { ::set Format $currency_format; } } } ::sargs::var::set Rectangle ".position.x" $Column; range_format $Rectangle $Format; ::incr Column; ::incr Index; } } public method column_formats {} { ::set Result ""; ::foreach ColumnName $_column_names { ::lappend Result [::string tolower [::subst [::sargs::get $_column_definition_tree $ColumnName.format]]]; } ::return $Result; } public method pagesetup_column_justifications_set {} { ::set Column $_sheet_start_column; ::set Rectangle $_content_rectangle; ::sargs::var::set Rectangle ".size.x" 1; ::foreach Justification [column_justifications] { ::sargs::var::set Rectangle ".position.x" $Column; range_horizontal_justify $Rectangle $Justification; ::incr Column; } } public method column_justifications {} { ::set Result ""; ::foreach ColumnName $_column_names { ::lappend Result [::string tolower [::sargs::get $_column_definition_tree "$ColumnName.justify"]]; } ::return $Result; } public method pagesetup_column_widths_get {} { ::set Result ""; ::for {::set j 0;} {$j<[::llength $_column_names]} {::incr j;} { ::lappend Result [column_width_characters_Get $j]; } ::return $Result; } public method pagesetup_column_widths_set {} { ::set Column $_sheet_start_column; ::foreach Width [column_widths] { column_width_characters_Set $Column $Width; ::incr Column; } } public method column_widths {} { ::set Result ""; ::set Average [::expr {[[$window ".client.options.font"] average_character_width_pixels]*-1.0}]; ::foreach ColumnName $_column_names { ::set Width [::sargs::get $_column_definition_tree "$ColumnName.width"]; ::if {$Width eq ""} { } ::set Width 20; ::lappend Result $Width; } ::return $Result; } public method pagesetup_column_titles_set {} { ::if {[::sargs::get $_pagesetup_structure ".print_titles"] ne "yes"} { ::return; } ::set Column $_sheet_start_column; ::if {$columntitles ne ""} { ::set Titles $columntitles; } else { ::set Titles $_column_titles; } ::foreach ColumnTitle $Titles { ::if {$ColumnTitle ne ""} { cell_value_Set ".x $Column .y $_sheet_row" $ColumnTitle; } ::incr Column; } ::set Font [::sargs::get $_pagesetup_structure ".column_titles.font"]; ::set Command ""; ::foreach Path {size weight family slant underline overstrike} { ::set Attribute [::sargs::get $Font .$Path]; ::if {$Attribute ne ""} { ::if {$Command eq ""} { ::set Command "range_font_Set \{[::list .size [::list .x [::llength $_column_titles] .y 1] .position [::list .x $_sheet_start_column .y $_sheet_row]]\}"; } ::lappend Command "-$Path"; ::lappend Command $Attribute; } } ::if {$Command ne ""} { ::eval $Command; } ::set BorderPosition [::sargs::get $_pagesetup_structure ".column_titles.border.position"]; ::set BorderStyle [::sargs::get $_pagesetup_structure ".column_titles.border.style"]; ::if {$BorderPosition ne ""||$BorderStyle ne ""} { ::if {$BorderPosition eq ""} { ::qw::throw ".column_titles.border.position must be set if .column_titles.border.style is set."; } ::if {$BorderStyle eq ""} { ::qw::throw ".column_titles.border.style must be set if .column_titles.border.position is set."; } range_border_Set [::list .size [::list .x [::llength $_column_titles] .y 1] .position [::list .x $_sheet_start_column .y $_sheet_row]] [::list .$BorderPosition [::list .style $BorderStyle]]; } title_rows [::sargs ".start" $_sheet_row ".end" $_sheet_row]; ::incr _sheet_row; } method pagesetup_document_title_set {} { ::set SheetColumn $_sheet_start_column; ::set DocumentTitle [::sargs::get $_pagesetup_structure ".document_title"]; ::set Limit [pagesetup_document_title_rows]; ::if {$Limit eq ""||!$Limit} { ::return; } ::for {::set TitleSub 1;} {$TitleSub<=$Limit} {::incr TitleSub;} { ::set Text [::sargs::get $DocumentTitle "/$TitleSub.text"]; ::if {$Text eq ""} { ::continue; } cell_value_Set ".x $SheetColumn .y $_sheet_row" $Text; ::set Font [::sargs::get $DocumentTitle "/$TitleSub.font"]; ::set Command ""; ::foreach Path {size weight family slant underline overstrike} { ::set Attribute [::sargs::get $Font .$Path]; ::if {$Attribute ne ""} { ::if {$Command eq ""} {::set Command "range_font_Set \{[::list .size [::list .x 1 .y 1] .position [::list .x $SheetColumn .y $_sheet_row]]\}";} ::lappend Command "-$Path";::lappend Command $Attribute; } } ::if {$Command ne ""} {::eval $Command;} ::set Alignment [::sargs::get $DocumentTitle "/$TitleSub.alignment"]; ::if {$Alignment ne ""} { range_horizontal_justify [::list .size [::list .x 1 .y 1] .position [::list .x $SheetColumn .y $_sheet_row]] $Alignment; } range_merge [::list .size [::list .x [::llength $_column_titles] .y 1] .position [::list .x $SheetColumn .y $_sheet_row]] 1; ::incr _sheet_row; ::if {$TitleSub<=3||$TitleSub==$Limit} { ::incr _sheet_row; } } } method pagesetup_document_title_rows {} { ::return [::sargs::get $_pagesetup_structure ".document_title.items"]; } public method load_template_settings {} { ::if {$template eq ""} { ::return; } ::qw::try { ::set Handle [::open $template]; } catch Exception { ::qw::throw [::sargs \ .text "Could not open template file $template, $Exception" \ .help_id 907020050517120300 \ ]; } ::close $Handle; ::set Workbooks [$_excel workbooks]; ::qw::try { ::set Workbook [$Workbooks factory -filename [::file nativename $template]]; } catch Exception { ::qw::throw [::sargs \ .text "Could not open template file $template, $Exception" \ .help_id 907020050517120300 \ ]; ::return; } ::set PageSetup [page_setup]; ::set Sheets [$Workbook "sheets"]; ::set Sheet1 [$Sheets item [::lindex [$Sheets names] 0]]; ::set Sheet1Ranges [$Sheet1 ranges]; ::for {::set RangeItem [$Sheet1Ranges kidFirst]} {$RangeItem ne ""} {::set RangeItem [$Sheet1Ranges kidNext $RangeItem]} { ::set RangeName [::string toupper [$RangeItem name_Get]]; ::switch -- $RangeName { "DOCUMENT" - "TITLE1" - "TITLE2" - "TITLE3" - "COLUMNTITLE" - "COLUMNTITLES" - "CONTENT" { ::array set Properties [$RangeItem properties ".font 1 .border 1"]; } default {::continue;} } ::set RawFontInfo $Properties(-font); ::set FontInfo ""; ::foreach {Attribute Value} $RawFontInfo { ::sargs::var::set FontInfo .[::string range $Attribute 1 end] $Value; } ::switch -- $RangeName { "TITLE1" {page_setup ".document_title/1.font" $FontInfo;} "TITLE2" {page_setup ".document_title/2.font" $FontInfo;} "TITLE3" {page_setup ".document_title/3.font" $FontInfo;} "CONTENT" {page_setup ".content.font" $FontInfo;} "COLUMNTITLES" {page_setup ".column_titles.font" $FontInfo;} } } ::foreach {Property Value} [[$Sheet1 pagesetup] settingsget] { ::sargs::var::set _pagesetup_structure ".template_page_setup.$Property" $Value; } $Workbook mark_file_saved; $Workbook close; $Workbooks destroy $Workbook; } method pagesetup_defaults_set {} { page_setup { .document_title { .items 0 /1 { .text "" .font { .size 16 .weight "bold" .family "Arial" .slant "roman" .underline 1 .overstrike 0 } .alignment "" } /2 { .text "" .font { .size 14 .weight "bold" .family "Arial" .slant "roman" .underline 0 .overstrike 0 } .alignment "" } /3 { .text "" .font { .size 12 .weight "normal" .family "Arial" .slant "roman" .underline 1 .overstrike 0 } .alignment "" } } .title { /rows { .start -1 .end -1 } /columns { .start -1 .end -1 } } .print_titles "yes" .print_line_numbers "yes" .column_titles { .font { .size "10" .weight "bold" .family "Arial" .slant "roman" .underline 0 .overstrike 0 } .border { .position "" .style "" } } .content { .font { .size "10" .weight "normal" .family "Arial" .slant "roman" .underline 0 .overstrike 0 } .border { .position "" .style "" } } .margin { /top -1 /right -1 /bottom -1 /left -1 /header -1 /footer -1 } .page_header { .left "" .center "" .right "" } .page_footer { .left "" .center "" .right "" } .orientation portrait .scaling 100 .fit_to_pages_wide 0 } } method pagesetup_finalize {} { pagesetup_column_formats_set; pagesetup_column_justifications_set; set_print_range [::list .position [::list .x 0 .y 0] .size [::list .x [::llength $_column_names] .y $_sheet_row]]; pagesetup_content_font_set; apply_template_settings; activate_top_left; mark_file_saved; } method apply_template_settings {} { ::if {$template eq ""} { ::return; } ::foreach Property [::sargs::names .structure [::sargs::get $_pagesetup_structure ".template_page_setup"]] { ::set Value [::sargs::get $_pagesetup_structure .template_page_setup$Property]; ::switch -- $Property { ".printgridlines" - ".topmargin" - ".bottommargin" - ".leftmargin" - ".rightmargin" - ".footermargin" - ".headermargin" - ".centerhorizontally" - ".centervertically" { [$_sheet pagesetup] settingsset [::string trimleft $Property "."] $Value; } ".leftheader" {} ".centerheader" {} ".rightheader" {} ".leftfooter" {} ".centerfooter" {} ".rightfooter" {} ".order" {} ".blackandwhite" {} ".draft" {} ".firstpagenumber" {} ".fittopagestall" {} ".fittopageswide" {} ".orientation" {} ".papersize" {} ".printarea" {} ".printcomments" {} ".printheadings" {} ".printnotes" {} ".printtitlecolumns" {} ".printtitlerows" {} ".zoom" {} } } } method pagesetup_content_font_set {} { ::set Font [::sargs::get $_pagesetup_structure ".content.font"]; ::set Command ""; ::foreach Path {size weight family slant underline overstrike} { ::set Attribute [::sargs::get $Font .$Path]; ::if {$Attribute ne ""} { ::if {$Command eq ""} {::set Command "range_font_Set \{$_content_rectangle\}";} ::lappend Command "-$Path";::lappend Command $Attribute; } } ::if {$Command ne ""} {::eval $Command;} } public method load_row_values {} { ::set _row_values [[$window ".client"] dataInterface_cache_row [$window dataInterface_fileRow $_table_row] 1 foreground]; ;#//nv2.29.0 - comment above says not create, but we do? ::if {[::sargs::get $_pagesetup_structure ".print_line_numbers"] eq "no"} { ::set Index $_print_line_numbers_column_index; ::if {$Index>=0} { ::set _row_values [::lreplace $_row_values $Index $Index]; ;#// lremove } } } public method print_row_values {} { range_value_Set [::list .position [::list .x $_sheet_start_column .y $_sheet_row] .size [::list .x [::llength $_row_values] .y 1]] [::join $_row_values \t]; ::if {$_phony_total_row} { ::set Font [::sargs::get $_pagesetup_structure ".content.font"]; ::sargs::var::set Font ".weight" "bold"; ::set Command ""; ::foreach Path {size weight family slant underline overstrike} { ::set Attribute [::sargs::get $Font .$Path]; ::if {$Attribute ne ""} { ::if {$Command eq ""} { ::set Command "range_font_Set \{[::list .size [::list .x [::llength $_column_titles] .y 1] .position [::list .x $_sheet_start_column .y $_sheet_row]]\}"; } ::lappend Command "-$Path"; ::lappend Command $Attribute; } } ::if {$Command ne ""} { ::eval $Command; } } ::incr _sheet_row; ::set Height [::sargs::get $_content_rectangle ".size.y"]; ::incr Height; ::sargs::var::set _content_rectangle ".size.y" $Height; } public method print_rows {{s_args ""}} { ::set Limit $_items; ;#// visual inspection proved they were (are) the same - see nv2.27.0 (bug fix) - progress_window in print ::set _application_database [$window odb_database application]; ::set RedProgress 1; ::if {$RedProgress} { ::set Progress [::itcl::local ::QW::PROGRESS::OPERATION #auto \ .database_id [$_application_database cpp_id] \ .file [$_application_database cpp_database_path] \ .user [$_application_database cpp_user_name] \ .limit $Limit \ .operation "Printing Table" \ .status "[$_application_database cpp_directory] printing table." \ .interrupt_enabled 1 \ ]; ::update; } else { ::set _database_path [$_application_database cpp_database_path]; ::set _database_id [$_application_database cpp_database_id_get]; ::set ClockStart [::clock clicks -milliseconds]; ::set OperationId ""; ::set ProgressMinimum 1000; ::set ProgressResolution 19; ::set ProgressLimit $Limit; ::if {$ProgressLimit>=$ProgressMinimum} { ::set OperationId [::qw::progress_blue::operation_create \ .limit $ProgressLimit \ .resolution $ProgressResolution \ .file $_database_path \ .database_id $_database_id \ .state working \ .description "Printing" \ .status "$_database_path printing table rows." \ ]; } } range_types_Set $_column_type_list; ::set Target [$prompt_window reference_list_target]; ::set SelectionPairList [$Target selection_pair_list_get]; ::if {$SelectionPairList eq "" \ ||$printrange eq "all" \ } { ::for {::set _table_row $_start_line;} {$_table_row<=$_end_line} {::incr _table_row;} { load_row_values; print_row_values; ::if {$RedProgress} { ::if {![::qw::command_exists $Progress]} { ::qw::throw [::sargs \ .text "Print aborted." \ .help_id 0 \ .priority ignore \ ]; } $Progress increment; } else { ::if {$OperationId ne ""} { ::qw::progress_blue::operation_increment $s_args .operation_id $OperationId; ::if {[::qw::progress_blue::operation_is_aborted .operation_id $OperationId]} { ::qw::progress_blue::operation_configure .operation_id $OperationId .state aborted; ::qw::progress_blue::operation_configure .operation_id $OperationId .state aborted; ::return [::sargs .return_code aborted]; } } } } ::return; } ::if {[[$window ".observer_index_direction"] odb_get] ne "forward"} { ::set BackwardList ""; ::foreach Pair $SelectionPairList { ::set BackwardList [::linsert $BackwardList 0 $Pair]; } ::set SelectionPairList $BackwardList; } ::foreach Pair $SelectionPairList { ::if {[[$window ".observer_index_direction"] odb_get] eq "forward"} { ::set _start_line [$window dataInterface_tableRow [::lindex $Pair 0]]; ::set _end_line [$window dataInterface_tableRow [::lindex $Pair 1]]; } else { ::set _end_line [$window dataInterface_tableRow [::lindex $Pair 0]]; ::set _start_line [$window dataInterface_tableRow [::lindex $Pair 1]]; } ::for {::set _table_row $_start_line;} {$_table_row<=$_end_line} {::incr _table_row;} { load_row_values; print_row_values; ::if {$RedProgress} { ::if {![::qw::command_exists $Progress]} { ::qw::throw [::sargs \ .text "Print aborted." \ .help_id 0 \ .priority ignore \ ]; } $Progress increment; } else { ::if {$OperationId ne ""} { ::qw::progress_blue::operation_increment $s_args .operation_id $OperationId; ::if {[::qw::progress_blue::operation_is_aborted .operation_id $OperationId]} { ::qw::progress_blue::operation_configure .operation_id $OperationId .state aborted; ::qw::progress_blue::operation_configure .operation_id $OperationId .state aborted; ::return [::sargs .return_code aborted]; } } } } } } method content_font_set {s_args} { ::set Rectangle [::sargs::get $s_args ".rectangle"]; ::set Font [::sargs::get $_pagesetup_structure ".content.font"]; ::set Command ""; ::foreach Path {size weight family slant underline overstrike} { ::set Attribute [::sargs::get $Font .$Path]; ::if {$Attribute ne ""} { ::if {$Command eq ""} {::set Command [::list range_font_Set $Rectangle];} ::lappend Command "-$Path";::lappend Command $Attribute; } } ::if {$Command ne ""} {::eval $Command;} } public method column_formats_set {s_args} { ::set Rectangle [::sargs::get $s_args ".rectangle"] ::set Column [::sargs::get $Rectangle ".position.x"] ::set Index 0; ::sargs::var::set Rectangle ".size.x" 1; ::foreach Format [column_formats] { ::switch [::lindex $_column_type_list $Index] { "date" { ::set Format $date_format; } default { ::if {[::string first "dollar" [::subst $Format]]>=0} { ::set Format $currency_format; } } } ::sargs::var::set Rectangle ".position.x" $Column; range_format $Rectangle $Format; ::incr Column; ::incr Index; } } public method column_justifications_set {s_args} { ::set Rectangle [::sargs::get $s_args ".rectangle"] ::set Column [::sargs::get $Rectangle ".position.x"] ::sargs::var::set Rectangle ".size.x" 1; ::foreach Justification [column_justifications] { ::sargs::var::set Rectangle ".position.x" $Column; range_horizontal_justify $Rectangle $Justification; ::incr Column; } } public method sheet_column_widths_set {s_args} { ::set Rectangle [::sargs::get $s_args ".rectangle"] ::set Column [::sargs::get $Rectangle ".position.x"] ::foreach Width [column_widths] { column_width_characters_Set $Column $Width; ::incr Column; } } public method column_titles_set {s_args} { ::if {[::sargs::get $_pagesetup_structure ".print_titles"] ne "yes"} {::return;} ::set Column $_sheet_start_column; ::if {$columntitles ne ""} { ::set Titles $columntitles; } else { ::set Titles $_column_titles; } ::foreach ColumnTitle $Titles { ::if {$ColumnTitle ne ""} {cell_value_Set ".x $Column .y $_sheet_row" $ColumnTitle;} ::incr Column; } ::set Rectangle [::sargs ".position.x" $_sheet_start_column ".position.y" $_sheet_row ".size.x" [::llength $_column_titles] ".size.y" 1]; column_justifications_set [::sargs ".rectangle" $Rectangle]; ::set Font [::sargs::get $_pagesetup_structure ".column_titles.font"]; ::set Command ""; ::foreach Path {size weight family slant underline overstrike} { ::set Attribute [::sargs::get $Font .$Path]; ::if {$Attribute ne ""} { ::if {$Command eq ""} {::set Command [::list range_font_Set $Rectangle];} ::lappend Command "-$Path";::lappend Command $Attribute; } } ::if {$Command ne ""} {::eval $Command;} ::set BorderPosition [::sargs::get $_pagesetup_structure ".column_titles.border.position"]; ::set BorderStyle [::sargs::get $_pagesetup_structure ".column_titles.border.style"]; ::if {$BorderPosition ne ""||$BorderStyle ne ""} { ::if {$BorderPosition eq ""} {::qw::throw ".column_titles.border.position must be set if .column_titles.border.style is set.";} ::if {$BorderStyle eq ""} {::qw::throw ".column_titles.border.style must be set if .column_titles.border.position is set.";} range_border_Set $Rectangle [::list .$BorderPosition [::list .style $BorderStyle]]; } title_rows [::sargs ".start" $_sheet_row ".end" $_sheet_row]; ::incr _sheet_row; } public method document_title_set {s_args} { ::set SheetColumn $_sheet_start_column; ::set DocumentTitle [::sargs::get $_pagesetup_structure ".document_title"]; ::set Limit [pagesetup_document_title_rows]; ::if {!$Limit} {::return;} ::for {::set TitleSub 1;} {$TitleSub<=$Limit} {::incr TitleSub;} { ::set Text [::sargs::get $DocumentTitle "/$TitleSub.text"]; ::if {$Text eq ""} { ::continue; } cell_value_Set ".x $SheetColumn .y $_sheet_row" $Text; ::set Font [::sargs::get $DocumentTitle "/$TitleSub.font"]; ::set Command ""; ::set Rectangle [::sargs ".size.x" 1 ".size.y" 1 ".position.x" $SheetColumn ".position.y" $_sheet_row]; ::foreach Path {size weight family slant underline overstrike} { ::set Attribute [::sargs::get $Font .$Path]; ::if {$Attribute ne ""} { ::if {$Command eq ""} {::set Command [::list range_font_Set $Rectangle];} ::lappend Command "-$Path";::lappend Command $Attribute; } } ::if {$Command ne ""} {::eval $Command;} ::set Alignment [::sargs::get $DocumentTitle "/$TitleSub.alignment"]; ::if {$Alignment ne ""} { range_horizontal_justify $Rectangle $Alignment; } range_merge [::list .size [::list .x [::llength $_column_titles] .y 1] .position [::list .x $SheetColumn .y $_sheet_row]] 1; ::incr _sheet_row; ::incr _sheet_row; } } } ::itcl::class ::qw::print::windows::table::plain { inherit ::qw::print::windows::table; constructor {args} { ::eval ::qw::print::windows::table::constructor $args; } { } destructor { } } ::itcl::class ::qw::print::windows::table::freeform { inherit ::qw::print::windows::table; public variable data "" {} public variable windowdefinition "" {} method configure_window {Src} { chain $Src; } constructor {args} { ::eval ::qw::print::windows::table::constructor $args; } { } destructor { } public method init {} { chain; ::return $this; } public method doit {} { ::if {$destination eq "file"&&$filename eq ""} { ::qw::throw "-destination is \"file\", but -filename has not been set."; } ::set _column_names [::sargs::get $windowdefinition ".column_names"]; ::set _column_titles [::sargs::get $windowdefinition ".column_titles"]; ::set _column_definition_tree [::sargs::get $windowdefinition ".column_definition_tree"]; ::set _titles [::sargs::get $windowdefinition ".column_titles"]; ::set _items [::llength [::sargs::subs .structure $data]]; ::set _start_line 0; ::set _end_line [::expr $_items-1]; ::set OldSheet $_sheet; init; ;#// creates a new sheet ::if {$destination eq "printer"&&$OldSheet ne ""&&$print_when eq "now"} { [$OldSheet owner_Get] kidDestroy $OldSheet ".destroy_peer 1"; } ::foreach Sheet $_extra_sheets { $Sheet visible 0; } ::set _extra_sheets ""; ::if {$print_job_name ne ""} { $_sheet name_Set $print_job_name; } ::if {$destination eq "file"} { ::set filename [::file nativename $filename]; ::set State [$_excel display_alerts]; $_excel display_alerts 0; $_workbook name_Set $filename; $_excel display_alerts $State; } pagesetup_initialize; ::set RectangleFilled $_content_rectangle; ::sargs::var::set RectangleFilled ".position.y" $_sheet_row ".size.y" 0; ::sargs::var::set RectangleFilled ".size.y" $_items; ::if {$_items} { print_rows; } pagesetup_finalize; ::sargs::var::set RectangleFilled ".size.y" [::expr {[::sargs::get $RectangleFilled ".size.y"]+[::sargs::get $RectangleFilled ".position.y"]}]; ::sargs::var::set RectangleFilled ".position.y" 0; $_range rectangle_Set $RectangleFilled; $_range autofit; ::lappend _sheets_to_print $_sheet; ::incr _sheets_done; ::switch -- $destination { "file" { ::set filename [::file nativename $filename]; ::set State [$_excel display_alerts]; $_excel display_alerts 0; $_workbook name_Set $filename; $_excel display_alerts $State; ::if {[::file extension $filename] eq ".pdf"} { ::if {[$_excel version_Get]>=12.0} { $_sheet handle_method "ExportAsFixedFormat" "0" "$filename"; } } } "printer" { ::if {$print_when eq "now"} { ::if {$printer eq ""} { ::set printer [$::nv2::print::printers default_Get]; } printer_Set $printer; print; } } } } public method pagesetup_column_types_set {} { ::set _column_type_list ""; ::foreach ColumnName $_column_names { ::set Type [::sargs::get $_column_definition_tree "$ColumnName.type"]; ::lappend _column_type_list $Type; } } public method load_row_values {} { ::set _row_values ""; ::foreach Name $_column_names { ::lappend _row_values [::sargs::get $data "/$_table_row.values$Name"]; } } public method print_row_values {} { ::set SkipChain 0; ::if {[::sargs::get $data "/$_table_row.line_type"] eq "text_line" \ &&[::sargs::get $data "/$_table_row.underline"] ne "" \ } { ::set SkipChain 1; } ::if {!$SkipChain} { chain; } } public method print_rows {{s_args ""}} { ::set RedProgress 1; range_types_Set $_column_type_list; ::set _application_database [$window odb_database application]; ::if {$RedProgress} { ::set PrintProgress [::itcl::local ::QW::PROGRESS::OPERATION #auto \ .database_id [$_application_database cpp_id] \ .file [$_application_database cpp_database_path] \ .user [$_application_database cpp_user_name] \ .limit [::expr {($_end_line-$_start_line)+1}] \ .operation "Printing Report" \ .status "[$_application_database cpp_directory] Printing Report." \ .interrupt_enabled 1 \ ]; } else { ::set _database_path [$_application_database cpp_database_path]; ::set _database_id [$_application_database cpp_database_id_get]; ::set ClockStart [::clock clicks -milliseconds]; ::set OperationId ""; ::set ProgressMinimum 10; ::set ProgressResolution 3; ::set ProgressLimit [::expr {($_end_line-$_start_line)+1}]; ::if {$ProgressLimit>=$ProgressMinimum} { ::set OperationId [::qw::progress_blue::operation_create \ .limit $ProgressLimit \ .resolution $ProgressResolution \ .file $_database_path \ .database_id $_database_id \ .state working \ .description "Printing" \ .status "$_database_path printing table rows." \ ]; } } ::for {::set _table_row $_start_line;} {$_table_row<=$_end_line} {::incr _table_row;} { ::if {$RedProgress} { ::if {![::qw::command_exists $PrintProgress]} { ::qw::throw [::sargs \ .text "Print aborted." \ .help_id 0 \ .priority ignore \ ]; } $PrintProgress increment; } else { ::if {$OperationId ne ""} { ::qw::progress_blue::operation_increment $s_args .operation_id $OperationId; ::if {[::qw::progress_blue::operation_is_aborted .operation_id $OperationId]} { ::qw::progress_blue::operation_configure .operation_id $OperationId .state aborted; ::return [::sargs .return_code aborted]; } } } load_row_values; print_row_values; print_row_underlines; } } public method print_row_underlines {} { ::set Underline [::sargs::get $data "/[::expr {$_table_row+1}].underline"]; ::if {$Underline eq ""} { ::return; } ::for {::set Column 0;} {$Column<[::llength $_column_type_list]} {::incr Column;} { ::set Type [::lindex $_column_type_list $Column]; ::if {$Type ne "amount"} { ::continue; } ::set Range [::list .position [::list .x $Column .y [::expr {$_sheet_row-1}]] .size [::list .x 1 .y 1]]; ::if {$Underline eq "S"} { range_border_Set $Range {.bottom {.style single}}; } else { range_border_Set $Range {.bottom {.style double}}; } } } } ::itcl::class ::qw::print::windows::table::account { inherit ::qw::print::windows::table; public variable print_zero_accounts "yes" {configure_print_zero_accounts $print_zero_accounts;} protected variable _underlines ""; method configure_print_zero_accounts {Src} { ::if {![::string is boolean $print_zero_accounts]} {::qw::throw "Invalid print_zero_accounts boolean \"$print_zero_accounts\".";} } method configure_window {Src} { chain $Src; ::if {![$Src odb_is_a [[database_Get] "/OBJECT/SYSTEM/WINDOW/SCROLLED/TABLE/NEWVIEWS/ACCOUNT"]]} { ::qw::throw "-window is not an accounts table."; } } constructor {args} { ::eval ::qw::print::windows::table::constructor $args; } { } destructor { } public method init {} { chain; ::return $this; } public method doit {} { chain; } public method load_row_values {} { chain; ::set Data ""; ::set _underlines ""; ::foreach Value $_row_values { ::if {$Value eq ""} { ::lappend Data ""; ::lappend _underlines ""; ::continue; } ::if {[::string map {= {}} $Value] eq ""} { ::lappend Data ""; ::lappend _underlines "D"; ::continue; } ::if {[::string map {- {}} $Value] eq ""} { ::lappend Data ""; ::lappend _underlines "S"; ::continue; } ::lappend Data $Value; ::lappend _underlines ""; } ::set _row_values $Data; } public method is_zero_balance_account {} { ::set Column 0; ::set Numbers ""; ::for {::set Column 0;} {$Column<[::llength $_column_type_list]} {::incr Column;} { ::set Type [::lindex $_column_type_list $Column]; ::switch -- $Type { "formula" - "amount" { ::set Value [::lindex $_row_values $Column]; ::if {$Value eq ""} { ::continue; } ::qw::try { ::set Value [::qw::number::scan $Value]; } catch Dummy { ::continue; } ::lappend Numbers $Value; } } } ::if {$Numbers eq ""} {::return 0;} ::foreach Number $Numbers { ::if {$Number!=0.0} {::return 0;} } ::return 1; } public method print_row_values {} { ::if {$print_zero_accounts||!$print_zero_accounts&&![is_zero_balance_account]} { ::set SkipChain 0; ::set Reference [[$window observer_database] odb_seek_count [$window dataInterface_fileRow $_table_row]]; ::if {$Reference ne ""} { ::if {[[[$Reference odb_master] .line_type] odb_get] eq "text_line"} { ::if {[[[$Reference odb_master] .underline] odb_get] ne ""} { ::set SkipChain 1; } } } ::if {!$SkipChain} { chain; } } ::set Row [::expr $_sheet_row-1]; ::for {::set Column 0;} {$Column<[::llength $_underlines]} {::incr Column;} { ::set Underline [::lindex $_underlines $Column]; ::if {$Underline eq ""} { ::continue; } ::set Range [::list .position [::list .x $Column .y $Row] .size [::list .x 1 .y 1]]; ::if {$Underline eq "S"} { range_border_Set $Range {.bottom {.style single}}; } else { range_border_Set $Range {.bottom {.style double}}; } } } } ::itcl::class ::qw::print::windows::table::postings { inherit ::qw::print::windows::table; protected variable _postings_table_initialize_odb_level ""; protected variable _columnDefinitionTree ""; protected variable _column_names_user_selected ""; protected variable _postings_table_column_setup ""; protected variable _distribution_table_column_setup ""; protected variable _distribution_table ""; protected variable _print_range ""; protected variable _opening_balances ""; protected variable _zero_point_balances ""; protected variable _postings_master_desktop_window ""; protected variable _postings_explorer_window ""; protected variable _postings_table_window ""; protected variable _amount_and_quantity_totals ""; ;#// structure, real numbers for summing are identified by searching get scripts for number formatting! protected variable _postings_data ""; protected variable _empty_row_values ""; public variable print_distributions "no" {configure_print_distributions $print_distributions;} public variable account_list ""; method configure_print_distributions {Src} { ::if {![::string is boolean $print_distributions]} { ::qw::throw "Invalid print_distributions boolean \"$print_distributions\"."; } } method configure_window {Src} { ::if {![$Src odb_is_a [[$Src odb_database] "/OBJECT/SYSTEM/WINDOW/SCROLLED/DESKTOP/OBJECT/MASTER/NEWVIEWS/ACCOUNT"]]} { ::qw::throw "-window is not a /OBJECT/SYSTEM/WINDOW/SCROLLED/DESKTOP/OBJECT/MASTER/NEWVIEWS/ACCOUNT."; } ::set _postings_master_desktop_window $Src; ::set _postings_explorer_window [[[[$_postings_master_desktop_window ".owner.kids"] odb_primary] odb_first] odb_master]; ::if {![$_postings_explorer_window odb_is_a [[$Src odb_database] "/OBJECT/SYSTEM/WINDOW/EXPLORER/MASTER/POSTINGS"]]} { ::qw::throw [::sargs \ .text "Could not find postings explorer in account desktop." \ .help_id 271820050404143220 \ ]; } ::set _postings_table_window [$_postings_explorer_window tree]; ::set _application_database [$Src odb_database application]; chain $_postings_table_window; } constructor {args} { ::eval ::qw::print::windows::table::constructor $args; } { } public method init {} { chain; ::return $this; } public method init_next_sheet {} { ::return $this; } destructor { } public method doit {} { ::switch -- $destination { "file" { ::if {$filename eq ""} { ::qw::throw "-destination is \"file\", but -filename has not been set."; } } "pdf" { ::if {$filename eq ""} { ::qw::throw "-destination is \"pdf\", but -filename has not been set."; } ::sargs::var::set settings ".account_separator" "page"; ;#// options: none, page, sheet } } ::if {$window eq ""} { ::qw::throw "-window has not been configured."; } ::set window $_postings_table_window; ::set ColumnTitleSettings { .font { .size "" .weight bold .family "" .slant roman .underline 0 .overstrike 0 } .border { .position "bottom" .style "single" } }; ::set PageSetupStructure [page_setup]; ::sargs::var::set PageSetupStructure ".column_titles" $ColumnTitleSettings; ::sargs::var::set PageSetupStructure ".orientation" [::sargs::get $settings ".orientation"]; ::sargs::var::set PageSetupStructure ".fit_to_pages_wide" [::sargs::get $settings ".fit_to_pages_wide"]; ::sargs::var::set PageSetupStructure ".scaling" [::sargs::get $settings ".scaling"]; ::set CompanyName [[[$_application_database "/OBJECT/NEWVIEWS/ACCOUNT"] ".address.company"] odb_get]; ::if {$CompanyName ne ""} { ::sargs::var::set PageSetupStructure ".page_footer.left" "&L$CompanyName"; } else { ::set Directory [::file nativename [$_application_database cpp_directory]]; ::sargs::var::set PageSetupStructure ".page_footer.left" "&L$Directory"; } ::sargs::var::set PageSetupStructure ".page_footer.center" "&C&D &T"; ::sargs::var::set PageSetupStructure ".page_footer.right" "&R&P of &N"; page_setup $PageSetupStructure; postings_table_initialize; init; ::set Workbook [workbook_current]; ::if {$Workbook eq ""} { ::set Workbook [workbook_new]; } workbook_select $Workbook; ::if {$destination eq "file"} { ::set filename [::file nativename $filename]; ::set State [$_excel display_alerts]; $_excel display_alerts 0; $_workbook name_Set $filename; $_excel display_alerts $State; } ::set ProgressLimit [::llength $account_list]; ::set ProgressMinimum 1; ::set Progress ""; ::if {$ProgressLimit>=$ProgressMinimum} { ::set Progress [::itcl::local ::QW::PROGRESS::OPERATION #auto \ .database_id [$_application_database cpp_id] \ .file [$_application_database cpp_database_path] \ .user [$_application_database cpp_user_name] \ .limit $ProgressLimit \ .operation "Printing Ledgers/Transactions" \ .status "[$_application_database cpp_database_path] printing ledgers/transactions." \ ]; } ::set ListIndex 0; ::foreach Account $account_list { ::set S_Args [::sargs \ .account $Account \ .list_index $ListIndex \ ]; print_account_start $S_Args; print_account_titles $S_Args; print_account_ledger $S_Args; print_account_end $S_Args; ::incr ListIndex; ::if {$Progress ne ""} { $Progress increment; } } ::switch -- $destination { "display" { } "file" { ::set filename [::file nativename $filename]; ::set State [$_excel display_alerts]; $_excel display_alerts 0; $_workbook name_Set $filename; $_excel display_alerts $State; } "printer" { ::if {$print_when eq "now"} { ::if {$printer eq ""} { ::set printer [$::nv2::print::printers default_Get]; } printer_Set $printer; print; } } "pdf" { ::set FileName [::file rootname $filename]; ::set FileName "$FileName.pdf"; ::set Result [[sheet_current] create_pdf_file [::sargs ".filename" $FileName]]; } } } public method done {} { ::set Result ""; ::switch -- $destination { "file" { ::switch -- [::string tolower [::file extension $filename]] { ".pdf" { ::set Result [[sheet_current] create_pdf_file [::sargs ".filename" $filename]]; } ".xls" - ".xlsx" - ".xlt" - ".xltx" - default { ::set filename [::file nativename $filename]; ::set State [$_excel display_alerts]; $_excel display_alerts 0; $_workbook name_Set $filename; $_excel display_alerts $State; file_save; file_close; ::set Result $filename; } } } "printer" { ::if {$print_when eq "now"} { ::if {$printer eq ""} { ::set printer [$::nv2::print::printers default_Get]; } printer_Set $printer; print; file_save; file_close; } } "display" { hide_extra_sheets; mark_file_saved; print_show; } "preview" { hide_extra_sheets; mark_file_saved; print_preview; } } [::qw::get_com_applications] destroy $_excel; ::set _excel ""; ::set _sheet ""; ::unset -nocomplain progress_window; ::set progress_window ""; ::set _state "inactive"; ::return $Result; } public method print_account_start {s_args} { ::set ListIndex [::sargs::get $s_args ".list_index"]; ::set Account [::sargs::get $s_args ".account"]; ::if {$ListIndex==0} { ::set Sheet [sheet_new]; sheet_select $Sheet; sheet_initialize; sheet_name [[$Account ".name"] odb_get]; ::lappend _sheets_to_print $Sheet; ::return; } ::switch -- [::sargs::get $settings .account_separator] { "page" { page_break_insert; } "sheet" { ::set Sheet [sheet_new]; sheet_select $Sheet; sheet_initialize; sheet_name [[$Account ".name"] odb_get]; ::lappend _sheets_to_print $Sheet; } "none" - default {} } } public method print_account_end {s_args} { ::switch -- [::sargs::get $settings .account_separator] { "page" {} "sheet" { sheet_finalize; } "none" - default { print_blank_rows 1; } } } public method print_account_titles {s_args} { ::set Account [::sargs::get $s_args ".account"]; ::set AccountPath [::QW::GUI::NEWVIEWS::odb_path_help_format [::sargs .object $Account .format short_lower_case_folder]]; ::set AccountName [[$Account ".name"] odb_get]; ::set AccountDescription [[$Account ".description"] odb_get]; ::set ReportPath ""; ::set ReportName ""; ::set ReportDescription ""; ::set ReportRef [[$Account ".report"] odb_get]; ::if {$ReportRef ne ""} { ::set Report [$ReportRef odb_master]; ::set ReportPath [::QW::GUI::NEWVIEWS::odb_path_help_format [::sargs .object $Report .format short_lower_case_folder]]; ::set ReportName [[$Report ".name"] odb_get]; ::set ReportDescription [[$Report ".description"] odb_get]; } ::set RangeBegin [::sargs::get $settings ".range_begin"] ::set RangeEnd [::sargs::get $settings ".range_end"] ::set Format $::qw::date::formats(month dd, yyyy); ::if {$RangeBegin ne ""} {::set RangeBegin [::qw::date::format $RangeBegin $Format];} ::if {$RangeEnd ne ""} {::set RangeEnd [::qw::date::format $RangeEnd $Format];} ::set View [::sargs::get $settings ".view"]; ::set Tag [::sargs::get $settings ".tag"]; ::set AccountTitle [::sargs::get $settings .account_title_1]; ::for {::set j 2;} {$j<=4} {::incr j;} { ::if {[::sargs::get $settings .account_title_$j] ne ""} { ::append AccountTitle \n[::sargs::get $settings .account_title_$j]; } } ::set Today [::clock format [::clock seconds] -format "%Y%m%d"]; ::set User [[$Account odb_database] cpp_user_get]; ::if {$User ne ""} { ::set Format [[$User .options.date.format] odb_get]; ::if {$Format ne ""} { ::set Today [::qw::date::format $Today $::qw::date::formats($Format)]; } } ::set AccountTitle [::string map [::list \ %_today $Today \ %_path $AccountPath \ %_report_path $ReportPath \ %_name $AccountName \ %_description $AccountDescription \ %_report_name $ReportName \ %_report_description $ReportDescription \ %_begin $RangeBegin \ %_end $RangeEnd \ %_view $View \ %_tag $Tag \ ] $AccountTitle]; print_titles [::sargs ".title_lines" $AccountTitle]; } public method print_titles {s_args} { ::set TitleLines [::sargs::get $s_args ".title_lines"]; ::set TitleLines [::string map [::list {\n} \n] $TitleLines]; ::set TitleLineCount [::llength [::split $TitleLines \n]]; page_setup \ .document_title.items $TitleLineCount \ .title/rows.start $TitleLineCount \ .title/rows.end $TitleLineCount \ ; ::set FontSize 16; ::set Underline 1; ::for {::set i 0;::set j 1;} {$i<$TitleLineCount} {::incr i;::incr j;} { ::set Title [::string trim [::lindex [::split $TitleLines \n] $i]]; ::set Alignment "left"; ::if {[::string index $Title 0] eq "|"} { ::set Title [::string range $Title 1 end]; ::set Alignment "center"; ::if {[::string index $Title 0] eq "|"} { ::set Title [::string range $Title 1 end]; ::set Alignment "right"; } } page_setup .document_title/$j.text $Title; page_setup .document_title/$j.alignment $Alignment; page_setup .document_title/$j.font.size $FontSize; page_setup \ .document_title/$j.font.weight bold \ .document_title/$j.font.family Arial \ .document_title/$j.font.slant roman \ .document_title/$j.font.underline $Underline \ .document_title/$j.font.overstrike 0 \ ; ::set Underline 0; ::if {$FontSize>10 && $Title ne ""} {::incr FontSize -2;} } pagesetup_document_title_set; column_titles_set "dummy_s_args"; } public method print_blank_rows {{Src "1"}} { row_values $_empty_row_values; ::for {::set i 0;} {$i<$Src} {::incr i;} { print_row_values; } ::return $this; } public method load_postings_data_respecting_prtaccts_flags {s_args} { ::set Account [::sargs::get $s_args .account]; ::set Flist {.prtaccts_flags} ::foreach Field $Flist { ::sargs::var::set Svalues $Field [::sargs::get $settings $Field]; ::sargs::var::set settings $Field [::sargs::get $s_args $Field]; } postings_table_configure $Account; ::set Result [load_postings_data $Account]; ::foreach Field $Flist { ::sargs::var::set settings $Field [::sargs::get $Svalues $Field]; } ::return $Result; } public method print_account_ledger {s_args} { ::set Account [::sargs::get $s_args ".account"]; ::sargs::var::set _content_rectangle ".size.y" 0 ".position.y" $_sheet_row; postings_table_configure $Account; ::set _postings_data [load_postings_data $Account]; ::if {0} { ::if {[$Account normal_balance_get] eq "debit"} { ::set HitList "0110 0101 1010 1001"; ;#//i.e. xdr xcr odr ocr } else { ::set HitList "0101 0110 1001 1010"; ;#//i.e. xcr xdr ocr odr } ::array set HitDescList {}; ::set HitDescList(0) "Reconciled Increases"; ::set HitDescList(1) "Reconciled Decreases"; ::set HitDescList(2) "Unreconciled Increases"; ::set HitDescList(3) "Unreconciled Decreases"; ::set DestSub 0; ::set EntireResult ""; ::set Pass -1; ::foreach Hit $HitList { ::set Ldata [load_postings_data_respecting_prtaccts_flags [::sargs .account $Account .prtaccts_flags $Hit]]; ::if {![::sargs::exists $EntireResult /0]} { ::sargs::var::set EntireResult /0 [::sargs::get $Ldata /0]; ;#// the first opening balance - it's what we use } ::sargs::var::set EntireResult /[::incr DestSub].values/description ""; ;#// blank line ::sargs::var::set EntireResult /[::incr DestSub].values/description $HitDescList([::incr Pass]); ::set LdataSubs [::sargs::subs .structure $Ldata]; ::foreach SourceSub [::lrange $LdataSubs 1 end-1] { ::sargs::var::set EntireResult /[::incr DestSub] [::sargs::get $Ldata $SourceSub]; } ::sargs::var::set Totals /$Hit [::sargs::get $EntireResult /$DestSub]; ;#//i.e. the last row copied ::foreach Cname $_column_names { ::sargs::var::set _amount_and_quantity_totals "$Cname.value" 0.0; } } ::set EntireResult [load_postings_data_rb_fix $EntireResult]; ::set _postings_data $EntireResult; } ::set Limit [::llength [::sargs::subs .structure $_postings_data]]; ::if {$Limit} { ::set RectangleFilled $_content_rectangle; ::sargs::var::set RectangleFilled ".position.y" $_sheet_row ".size.y" 0; ::sargs::var::set RectangleFilled ".size.y" $Limit; ::set S_Args [::sargs ".rectangle" $RectangleFilled]; content_font_set $S_Args; column_justifications_set $S_Args; column_formats_set $S_Args; print_rows $s_args; row_values_font_set $S_Args; ::sargs::var::set RectangleFilled ".size.y" [::expr {[::sargs::get $RectangleFilled ".size.y"]+[::sargs::get $RectangleFilled ".position.y"]}]; ::sargs::var::set RectangleFilled ".position.y" 0; $_range rectangle_Set $RectangleFilled; $_range autofit; } } public method row_values_font_set {s_args} { ::set Rectangle [::sargs::get $s_args ".rectangle"] ::set Row [::sargs::get $Rectangle ".position.y"]; ::sargs::var::set Rectangle ".size.y" 1; ::sargs::var::set Rectangle ".size.x" [::llength $_column_titles]; ::sargs::var::set Rectangle ".position.x" $_sheet_start_column; ::set Subs [::sargs::subs .structure $_postings_data]; ::foreach Sub $Subs { ::set Font [::sargs::get $_postings_data "$Sub.font"]; ::if {$Font eq ""} { ::incr Row; ::continue; } ::set Command ""; ::foreach Path {size weight family slant underline overstrike} { ::set Attribute [::sargs::get $Font .$Path]; ::if {$Attribute ne ""} { ::lappend Command "-$Path";::lappend Command $Attribute; } } ::if {$Command ne ""} { ::sargs::var::set Rectangle ".position.y" $Row; ::set Command [::linsert $Command 0 "range_font_Set" $Rectangle]; ::eval $Command; } ::incr Row; } } public method print_row_values {} { ::set Rectangle [::list .position [::list .x $_sheet_start_column .y $_sheet_row] .size [::list .x [::llength $_row_values] .y 1]]; range_value_Set $Rectangle [::join [row_values] \t]; ::incr _sheet_row; ::set Height [::sargs::get $_content_rectangle ".size.y"]; ::incr Height; ::sargs::var::set _content_rectangle ".size.y" $Height; ::return $Rectangle; } public method row_values {{Src "get"}} { ::if {$Src eq "get"} {::return $_row_values;} ::set _row_values $Src; ::return $this; } public method print_rows {{s_args ""}} { ::set Account [::sargs::get $s_args .account]; ::set Account [::QW::GUI::NEWVIEWS::odb_path_help_format [::sargs .object $Account .format short_lower_case_folder]]; ::set Limit [::llength [::sargs::subs .structure $_postings_data]]; ::set Progress [::itcl::local ::QW::PROGRESS::OPERATION #auto \ .database_id [$_application_database cpp_id] \ .file [$_application_database cpp_directory] \ .user [[$_application_database "/OBJECT"] odb_user_name] \ .limit $Limit \ .operation "Printing $Account" \ .status "[$_application_database cpp_directory] $Account" \ ]; range_types_Set $_column_type_list; ::set Subs [::sargs::subs .structure $_postings_data]; ::foreach Sub $Subs { ::set _row_values ""; ::foreach Name $_column_names_user_selected { ::lappend _row_values [::sargs::get $_postings_data "$Sub.values$Name"]; } ::set Rectangle [print_row_values]; $Progress increment; } } method load_postings_data_is_hit {Reference} { ::set IsHitFlags [::sargs::get $settings ".prtaccts_flags"]; ::switch -- $IsHitFlags { 0101 {::return [::expr {[load_postings_data_is_credit $Reference]&&[load_postings_data_is_closed $Reference]}];} 0110 {::return [::expr {[load_postings_data_is_debit $Reference]&&[load_postings_data_is_closed $Reference]}];} 1001 {::return [::expr {[load_postings_data_is_credit $Reference]&&[load_postings_data_is_open $Reference]}];} 1010 {::return [::expr {[load_postings_data_is_debit $Reference]&&[load_postings_data_is_open $Reference]}];} } ::return 1; } method load_postings_data_is_debit {Reference} { ::if {[[$Reference odb_master] is_boomerang]} { ::return 0; } ::set Amount [[[$Reference odb_outer] ".amount"] odb_get]; ::if {$Amount>0.0} {::return 1;} ::if {$Amount<0.0} {::return 0;} ::if {[[$Reference odb_outer] odb_super_find_by_id "/debit"] ne ""} {::return 1;} ::if {[[$Reference odb_outer] odb_super_find_by_id "/credit"] ne ""} {::return 0;} ::qw::bug "314120030922142541" "Could not find a debit or credit posting." } method load_postings_data_is_credit {Reference} { ::if {[[$Reference odb_master] is_boomerang]} { ::return 0; } ::set Amount [[[$Reference odb_outer] ".amount"] odb_get]; ::if {$Amount<0.0} {::return 1;} ::if {$Amount>0.0} {::return 0;} ::if {[[$Reference odb_outer] odb_super_find_by_id "/credit"] ne ""} {::return 1;} ::if {[[$Reference odb_outer] odb_super_find_by_id "/debit"] ne ""} {::return 0;} ::qw::bug "314120030922142709" "Could not find a debit or credit posting." } method load_postings_data_is_open {Reference} { ::return [::expr {[[[$Reference odb_outer] ".reconcile"] odb_get] eq ""}]; } method load_postings_data_is_closed {Reference} { ::return [::expr {[[[$Reference odb_outer] ".reconcile"] odb_get] ne ""}]; } method load_postings_data_rb_fix {Sorted} { ::set Format $currency_format; ::set SortedSubs [::sargs::subs .structure $Sorted]; ::set RBquantity [qw_structure_formatted_real_get $Sorted "[::lindex $SortedSubs 0].values/quantity"]; ::set RBamount [qw_structure_formatted_real_get $Sorted "[::lindex $SortedSubs 0].values/amount"]; ::foreach Sub [::lrange $SortedSubs 1 end] { ::if {[::sargs::get $Sorted "$Sub.values/running_balance_quantity"] ne ""} { ::set Quantity [qw_structure_formatted_real_get $Sorted "$Sub.values/quantity"]; ::qw::number::var::add RBquantity $Quantity; ::sargs::var::set Sorted "$Sub.values/running_balance_quantity" [::qw::number::format $RBquantity $::qw::number::formats($Format)]; } ::if {[::sargs::get $Sorted "$Sub.values/running_balance_amount"] ne ""} { ::set Amount [qw_structure_formatted_real_get $Sorted "$Sub.values/amount"]; ::qw::number::var::add RBamount $Amount; ::sargs::var::set Sorted "$Sub.values/running_balance_amount" [::qw::number::format $RBamount $::qw::number::formats($Format)]; } } ::return $Sorted; } public method load_postings_data {Account} { ::set ::qw::control(clock_clicks_total) 0; ::set ::qw::control(clock_clicks) 0; ::set TotalClicks [::clock clicks -milliseconds]; ::set Items 0; ::set Items [$_postings_table_window observer_rows]; ::set StartLine 1; ::set EndLine $Items; ::set Progress [::itcl::local ::QW::PROGRESS::OPERATION #auto \ .database_id [$_application_database cpp_id] \ .file [$_application_database cpp_directory] \ .user [[$_application_database "/OBJECT"] odb_user_name] \ .limit $Items \ .operation "Loading" \ .status "Loading postings from account [[$Account .name] odb_get]" \ ]; ::set Sub 0; ::set Result ""; ::set Oprint 1; ::set PrintType [::sargs::get [[$prompt_window .clientdata] qw_get] .newviews.print_type]; ::if {$PrintType eq "_requisition"} { ::set Cnames [::sargs::get $prompt_settings .column_names]; ::set Obalances [::sargs::select_all .structure [::sargs::get $_opening_balances .values]]; ::set Isect [::qw::intersect3 $Cnames $Obalances]; ::set OallZero 1; ::foreach Cname [::lindex $Isect 1] { ::if {[::sargs::real_get $_opening_balances .values$Cname]!=0.0} { ::set OallZero 0; ::break; } } ::if {$OallZero} { ::set Oprint 0; } } ::if {$_opening_balances ne ""} { ::if {$Oprint} { ::sargs::var::set Result "/$Sub" $_opening_balances; ::incr Sub; } } ::if {[[$Account ".normal_representation"] odb_get] eq "opening"} { ::return $Result; } ::set ColumnNames $_column_names; ::set PrintDistributions [::sargs::get $settings ".print_distributions"]; ::if {$::qw::control(print_account_ledgers_historic_aging)} { ::if {[::sargs::boolean_get $settings .historic_aging]} { ::set ReconcileRange [::qw::odb::factory range]; ::qw::finally [::list $ReconcileRange cpp_destroy]; $ReconcileRange cpp_configure -index [$Account ".postings.index/reconcile"]; ::set ReconcileTag [::sargs::get [[$_postings_table_window observer_database] cpp_cget -begin] .tag]; ::set Rindex [$Account ".postings.index/reconcile"]; ::set RangeEndDate [::string range [::sargs::get [[$_postings_table_window observer_database] cpp_cget -end] .date] 0 7]; } } ::for {::set TableRow $StartLine} {$TableRow<=$EndLine} {::incr TableRow} { ::set SeekItem [::expr $TableRow-1]; ::set Reference [[$_postings_table_window observer_database] odb_seek_count $SeekItem]; ::if {![load_postings_data_is_hit $Reference]} { $Progress increment; ::continue; ;#// skip this ledger item } ::if {![::sargs::boolean_get $settings .print_boomerangs] \ &&[[$Reference odb_master] is_boomerang] \ } { ::set Reconcile [[[$Reference odb_outer] .reconcile] odb_get]; ::switch -exact -- [$Reference odb_path_from_master] { .posting/debit.account {::set Xreconcile [[[$Reference odb_master] .posting/credit.reconcile] odb_get];} .posting/credit.account {::set Xreconcile [[[$Reference odb_master] .posting/debit.reconcile] odb_get];} } ::if {$Reconcile eq ""&&$Xreconcile eq "" \ ||$Reconcile ne ""&&$Xreconcile ne "" \ } { $Progress increment; ::continue; ;#// skip this boomerang } } ::if {$::qw::control(print_account_ledgers_historic_aging)} { ::if {[::sargs::boolean_get $settings .historic_aging]} { ::set Rvalue [[[$Reference odb_outer] .reconcile] odb_get]; ::if {$Rvalue ne ""} { ::set TrulyClosed [$Account is_posting_truly_closed_low_level [::sargs .reference $Reference .tag $ReconcileTag .end_date $RangeEndDate]]; ::if {$TrulyClosed} { $Progress increment; ::continue; ;#// skip this ledger item } } } } ::set DistributionItems 0; ::if {$PrintDistributions eq "yes"} { ::if {$Reference ne ""} { ::set Transaction [$Reference odb_master]; ::set DistributionItems [[$Transaction ".odb_deriveds"] odb_items]; } } ::set RowValues [[$_postings_table_window ".client"] dataInterface_cache_row [$_postings_table_window dataInterface_fileRow $TableRow] 0 foreground]; ::set Column 0; ::foreach ColumnName $ColumnNames { ::set IsTotalled [::sargs::exists $_amount_and_quantity_totals $ColumnName]; ::if {$IsTotalled} { ::set Total [::sargs::get $_amount_and_quantity_totals "$ColumnName.value"]; ::set Total [::qw::number::add $Total [remove_amount_formatting [::lindex $RowValues $Column]]]; ::sargs::var::set _amount_and_quantity_totals "$ColumnName.value" $Total; } ::switch -glob -- $ColumnName { "/running_balance*" { ::if {$::qw::control(print_account_ledgers_historic_aging)} {} ::if {[::sargs::boolean_get $settings .historic_aging]} { ::set Tcname [::string map {running_balance_ ""} $ColumnName]; ::set Rbal [::sargs::get $_amount_and_quantity_totals "$Tcname.value"]; } else { ::set Rbal [remove_amount_formatting [::lindex $RowValues $Column]]; ::if {[::string first "/open" [::sargs::get $settings .index_path]]<0} { ::set Rbal [::qw::number::add $Rbal [::sargs::get $_opening_balances ".values$ColumnName"]]; } } ::set AmtFormat $currency_format; ::sargs::var::set Result "/$Sub.values$ColumnName" [::qw::number::format $Rbal $::qw::number::formats($AmtFormat)]; } "/posting/*name" - "/posting/*help" - "/posting/*description" { ::set FileRow [$_postings_table_window dataInterface_fileRow $TableRow]; ::set MyAccount [[$_postings_table_window ".client"] dataInterfaceCell $FileRow $Reference $Reference "/account"]; ::set DetailAccount [[$_postings_table_window ".client"] dataInterfaceCell $FileRow $Reference $Reference "/posting/charge/account"]; ::if {$DetailAccount eq $MyAccount} { ::sargs::var::set Result "/$Sub.values$ColumnName" ""; } else { ::sargs::var::set Result "/$Sub.values$ColumnName" [::lindex $RowValues $Column]; } } "/posting/*rate" { ::if {$DistributionItems} { ::sargs::var::set Result "/$Sub.values$ColumnName" ""; } else { ::sargs::var::set Result "/$Sub.values$ColumnName" [::lindex $RowValues $Column]; } } "/account*" { ::sargs::var::set Result "/$Sub.values$ColumnName" [::lindex $RowValues $Column]; } default { ::sargs::var::set Result "/$Sub.values$ColumnName" [::lindex $RowValues $Column]; } } ::if {$DistributionItems} { } ::incr Column; } ::if {$DistributionItems} { ::set Default [::sargs::get [page_setup] ".content.font"]; ::sargs::var::set Default ".weight" "bold"; ::sargs::var::set Result "/$Sub.font" $Default; ::sargs::var::set Result "/$Sub.header" "yes"; } ::if {!$DistributionItems&&[::sargs::get $Result "/$Sub.values/cross_account/odb_address"] eq ""} { ::sargs::var::set Result "/$Sub.header" "yes"; ;#// or .text_line (whatever) } ::if {!$DistributionItems&&[::sargs::get $Result "/$Sub.values/cross_account/odb_address"] eq [::sargs::get $Result "/$Sub.values/account/odb_address"]} { ::sargs::var::set Result "/$Sub.header" "yes"; ;#// or .boomerang (whatever) } ::sargs::var::set Result "/$Sub.reference" $Reference; ::set HeaderSub $Sub; ::set HeaderValues $RowValues; ::incr Sub ::if {$DistributionItems} { ::if {$::qw::control(load_postings_data_odb_level_distribution_values)} { ::sargs::var::set Sargs .context_account $Account; ::sargs::var::set Sargs .reference $Reference; ::sargs::var::set Sargs .settings [::sargs::set $settings .column_names $_column_names]; ::sargs::var::set Sargs .postings_table_initialize_odb_level $_postings_table_initialize_odb_level; ::set Dlist [$_postings_table_window load_postings_data_odb_level_distribution_values $Sargs]; ::foreach RowValues $Dlist { ::set Column 0; ::foreach ColumnName $ColumnNames { ::set IsTotalled [::sargs::exists $_amount_and_quantity_totals $ColumnName]; ::if {[::string first "/running_balance" $ColumnName]==0 \ ||[::lindex $RowValues $Column] eq [::lindex $HeaderValues $Column]&&[::string first "/posting" $ColumnName]<0 \ } { ::sargs::var::set Result "/$Sub.values$ColumnName" ""; } else { ::sargs::var::set Result "/$Sub.values$ColumnName" [::lindex $RowValues $Column]; } ::if {[::sargs::get $settings ".print_distributions_sort_by"] eq "account" \ } { ::sargs::var::set Result "/$Sub.values$ColumnName" [::lindex $RowValues $Column]; ::switch -glob -- $ColumnName { "/journal*" - "/account*" { ::sargs::var::set Result "/$Sub.values$ColumnName" [::lindex $HeaderValues $Column]; } } } ::incr Column; } ::if {[::sargs::get $Result "/$Sub.values/posting/charge/account/odb_address"] eq ""} { ::sargs::var::set Result "/$Sub.header" "yes"; ;#// or .text_line (whatever) } ::if {[::sargs::get $Result "/$Sub.values/posting/charge/account/odb_address"] eq [::sargs::get $Result "/$Sub.values/cross_account/odb_address"]} { ::sargs::var::set Result "/$Sub.header" "yes"; ;#// or .boomerang (whatever) } ::sargs::var::set Result "/$Sub.type" "distribution"; ::sargs::var::set Result "/$Sub.header_sub" $HeaderSub; ::incr Sub; } } else { ::set Clicks [::clock clicks -milliseconds]; [$_postings_table_window ".restore_state"] odb_set "restored"; $_postings_table_window activeCell $TableRow,0 0; ;#// i.e. breadcrum 0 ::if {$::qw::control(signal_pick_kids_after_time_delay)} { [$_postings_table_window ".pick.kids"] signalWrite; } ::set ::qw::control(clock_clicks) [::expr {$::qw::control(clock_clicks)+[::clock clicks -milliseconds]-$Clicks}]; ::set PostingDesktop [[[[$_postings_explorer_window ".clipper.kids"] .index/z] odb_first] odb_master]; ::set PostingDesktop [$_postings_explorer_window desktop]; ::set TransactionDesktop [[[[$PostingDesktop ".clipper.kids"] .index/z] odb_first] odb_master]; ::set DistributionTable ""; ::foreach Ref [[$TransactionDesktop ".clipper.kids.index/z"] odb_references] { ::if {[[$Ref odb_master] odb_is_a [[[$Ref odb_master] odb_database] "/OBJECT/SYSTEM/WINDOW/SCROLLED/TABLE/NEWVIEWS/SYSTEM/TRANSACTION"]]} { ::set DistributionTable [$Ref odb_master]; ::break; } } ::if {$DistributionTable eq ""} { ::qw::bug "Could not find distribution table in [$TransactionDesktop odb_path]"; } ::set DistributionRows [$DistributionTable observer_rows]; ::set ColumnDefinitions [[$DistributionTable ".column_definitions"] qw_get]; ::set ColumnDefinitions [::sargs::var::+= ColumnDefinitions $_postings_table_column_setup]; ::set ColumnDefinitions [::sargs::var::+= ColumnDefinitions $_distribution_table_column_setup]; [$DistributionTable ".column_definitions"] odb_set $ColumnDefinitions; [$DistributionTable ".column_names"] odb_set $ColumnNames; ::set HeaderValues $RowValues; ::for {::set DistributionTableRow 1} {$DistributionTableRow<=$DistributionRows} {::incr DistributionTableRow} { ::set RowValues [[$DistributionTable ".client"] dataInterface_cache_row [$DistributionTable dataInterface_fileRow $DistributionTableRow] 0 foreground]; ::set Column 0; ::foreach ColumnName $ColumnNames { ::set IsTotalled [::sargs::exists $_amount_and_quantity_totals $ColumnName]; ::if {$IsTotalled} { ::set Total [::sargs::get $_amount_and_quantity_totals "$ColumnName.value"]; ::set Total [::qw::number::add $Total [remove_amount_formatting [::lindex $RowValues $Column]]]; ::sargs::var::set _amount_and_quantity_totals "$ColumnName.value" $Total; } ::if {[::string first "/running_balance" $ColumnName]==0 \ ||[::lindex $RowValues $Column] eq [::lindex $HeaderValues $Column]&&[::string first "/posting" $ColumnName]<0 \ } { ::sargs::var::set Result "/$Sub.values$ColumnName" ""; } else { ::sargs::var::set Result "/$Sub.values$ColumnName" [::lindex $RowValues $Column]; } ::if {[::sargs::get $settings ".print_distributions_sort_by"] ne "date" \ &&[::sargs::get $settings ".print_distributions_summarize"] ne "yes" \ } { ::sargs::var::set Result "/$Sub.values$ColumnName" [::lindex $RowValues $Column]; } ::switch -glob -- $ColumnName { "/account*" { ::sargs::var::set Result "/$Sub.values$ColumnName" [::lindex $HeaderValues $Column]; } } ::incr Column; } ::if {[::sargs::get $Result "/$Sub.values/posting/charge/account/odb_address"] eq ""} { ::sargs::var::set Result "/$Sub.header" "yes"; ;#// or .text_line (whatever) } ::if {[::sargs::get $Result "/$Sub.values/posting/charge/account/odb_address"] eq [::sargs::get $Result "/$Sub.values/cross_account/odb_address"]} { ::sargs::var::set Result "/$Sub.header" "yes"; ;#// or .boomerang (whatever) } ::sargs::var::set Result "/$Sub.type" "distribution"; ::sargs::var::set Result "/$Sub.header_sub" $HeaderSub; ::incr Sub } } } ;#// end of ::if {$DistributionItems} $Progress increment; } ::set Format $currency_format; ::sargs::var::set Result "/$Sub.values/description" "Totals"; ::foreach Colname [::sargs::select_all .structure $_amount_and_quantity_totals] { ::if {[::string first "." $Colname]>0} { ::continue; } ::set Sumval [::sargs::get $_amount_and_quantity_totals "$Colname.value"]; ::if {$::qw::control(print_account_ledgers_historic_aging)} {} ::if {$Sumval!=0.0||[::string first "/amount_age_" $Colname]!=0} { ::sargs::var::set Result "/$Sub.values$Colname" [::qw::number::format $Sumval $::qw::number::formats($Format)]; } } ::if {$Oprint} { ::incr Sub; ::sargs::var::set Result "/$Sub.values/description" "Ending Balances"; ::foreach Colname [::sargs::subs .structure $_amount_and_quantity_totals] { ::set Sumval [::sargs::get $_amount_and_quantity_totals "$Colname.value"]; ::qw::number::var::add Sumval [::sargs::get $_opening_balances ".values$Colname"]; ::if {$::qw::control(print_account_ledgers_historic_aging)} {} ::if {$Sumval!=0.0||[::string first "/amount_age_" $Colname]!=0} { ::sargs::var::set Result "/$Sub.values$Colname" [::qw::number::format $Sumval $::qw::number::formats($Format)]; } } } ::incr Sub; ::if {[::sargs::boolean_get $settings .print_distributions] &&[::sargs::get $settings .print_distributions_sort_by] eq "account" \ } { ::return [print_distributions_cross_account_analysis $Result]; } ::if {[::sargs::boolean_get $settings .historic_aging]} { ::set Result [with_rb_for_historic_aging $Result]; } ::set IsHitFlags [::sargs::get $settings ".prtaccts_flags"]; ::switch -- $IsHitFlags { 0101 - 0110 - 1001 - 1010 {::return [load_postings_data_rb_fix $Result];} } ::return $Result; } public method print_distributions_cross_account_analysis {Result} { ::if {[::sargs::boolean_get $settings .print_distributions_flows_analysis]} { ::set Result [simple_item_to_detail_item_move $Result]; } ::set Sorted [detail_items_sorted_by_posting_charge_account_detail $Result]; ::if {[::sargs::boolean_get $settings .print_distributions_flows_analysis]} { ::set Sorted [header_items_prune $Sorted]; } ::if {[::sargs::boolean_get $settings .print_distributions_summarize]} { ::set Sorted [detail_items_sorted_by_posting_charge_account_summary $Sorted]; } ::set Sorted [detail_items_sorted_by_posting_charge_account_line_items_extend $Sorted]; ::if {[::sargs::boolean_get $settings .print_distributions_flows_analysis]} { ::set Sorted [flow_analysis_format $Sorted]; } ::set Sorted [with_rb $Sorted]; ::return $Sorted; } public method simple_item_to_detail_item_move {Result} { ::set Subs [::sargs::subs .structure $Result]; ::set SubsLimit 100; ::set Progress ""; ::if {[::llength $Subs]>$SubsLimit} { ::set Progress [::itcl::local ::QW::PROGRESS::OPERATION #auto \ .database_id [$_application_database cpp_id] \ .file [$_application_database cpp_directory] \ .user [[$_application_database "/OBJECT"] odb_user_name] \ .limit [::llength $Subs] \ .operation "Indentifying Cross Accounts" \ .status "Organizing posting data for cross account analysis" \ ]; } ::foreach Sub [::sargs::subs .structure $Result] { ::if {$Progress ne ""} { $Progress increment; } ::if {[::sargs::get $Result $Sub.values/cross_account/odb_address] ne ""} { ::foreach Path { account/odb_address account/odb_path_help account/name account/description } { ::sargs::var::set Result $Sub.values/posting/charge/$Path [::sargs::get $Result $Sub.values/cross_$Path]; ::sargs::var::set Result $Sub.values/cross_$Path ""; } ::foreach Path { quantity rate amount } { ::sargs::var::set Result $Sub.values/posting/charge/$Path [::sargs::get $Result $Sub.values/$Path]; ::sargs::var::set Result $Sub.values/$Path ""; } } } ::return $Result; } public method header_items_prune {Sorted} { ::set RootObject [$_postings_master_desktop_window observer_database]; ::set RootPath [$RootObject odb_path_help]; ::set Subs [::sargs::subs .structure $Sorted]; ::set SubsLimit 100; ::set Progress ""; ::if {[::llength $Subs]>$SubsLimit} { ::set Progress [::itcl::local ::QW::PROGRESS::OPERATION #auto \ .database_id [$_application_database cpp_id] \ .file [$_application_database cpp_directory] \ .user [[$_application_database "/OBJECT"] odb_user_name] \ .limit [::llength $Subs] \ .operation "Pruning Inter-account Transfers" \ .status "Pruning transfers that distort (magnify) increases and decreases" \ ]; } ::foreach Sub $Subs { ::if {$Progress ne ""} { $Progress increment; } ::if {[::sargs::get $Sorted $Sub.header] eq "yes"} { ::sargs::var::unset Sorted $Sub; ::continue; } ::set Account [::sargs::get $Sorted $Sub.values/account/odb_address]; ::if {$Account ne ""} { ::set Alist [[$Account .postings] odb_closure]; ::if {[::lsearch $Alist [$RootObject .postings]]<0} { ::qw::throw "...we are broken... upward closure of Account====[$Account odb_path_help] not consistent with downward closure of RootPath==$RootPath"; } ::set Xaccount [::sargs::get $Sorted $Sub.values/posting/charge/account/odb_address]; ::if {$Xaccount ne ""} { ::set Xlist [[$Xaccount .postings] odb_closure]; ::if {[::lsearch $Alist [$RootObject .postings]]>=0&&[::lsearch $Xlist [$RootObject .postings]]>=0} { ::sargs::var::unset Sorted $Sub; ::continue; } ::foreach Tax {tax1 tax2 cgs inventory} { ::set Taccount [::sargs::get $Sorted $Sub.values/posting/${Tax}/account/odb_address]; ::if {$Taccount eq ""} { ::continue; } ::set Tlist [[$Taccount .postings] odb_closure]; ::if {[::lsearch $Alist [$RootObject .postings]]>=0&&[::lsearch $Tlist [$RootObject .postings]]>=0} { ::sargs::var::set Sorted $Sub.values/posting/${Tax}/amount ""; ::continue; } ::if {[::string first "tax" $Tax]==0} { ::continue; } ::if {$Account eq [::sargs::get $Sorted $Sub.values/posting/tax1/account/odb_address] \ ||$Account eq [::sargs::get $Sorted $Sub.values/posting/tax2/account/odb_address] \ } { ::sargs::var::set Sorted $Sub.values/posting/${Tax}/amount ""; } ::if {$Account eq [::sargs::get $Sorted $Sub.values/posting/cgs/account/odb_address]} { ::sargs::var::set Sorted $Sub.values/posting/inventory/amount ""; } ::if {$Account eq [::sargs::get $Sorted $Sub.values/posting/inventory/account/odb_address]} { ::sargs::var::set Sorted $Sub.values/posting/cgs/amount ""; } ::if {$Tax eq "cgs"} { ::if {[::sargs::get $Sorted $Sub.values/posting/inventory/account/odb_address] ne ""} { ::set Ilist [[[::sargs::get $Sorted $Sub.values/posting/inventory/account/odb_address] .postings] odb_closure]; ::if {[::lsearch $Alist [$RootObject .postings]]>=0&&[::lsearch $Ilist [$RootObject .postings]]>=0} { ::foreach ColumnName $_column_names { ::set IsTotalled [::sargs::exists $_amount_and_quantity_totals $ColumnName]; ::if {$IsTotalled&&[::string first "cgs" $ColumnName]>=0} { ::set Value [qw_structure_formatted_real_get $Sorted $Sub.values$ColumnName]; ::sargs::var::set Sorted $Sub.values$ColumnName [::qw::number::format [::qw::number::negative $Value] $::qw::number::formats($currency_format)]; } } } } } } } } ::if {[::sargs::get $Sorted $Sub.type] ne "distribution"} { ::foreach Tax {tax1 tax2} { ::set Tpath [::sargs::get $Sorted $Sub.values/posting/${Tax}/account/odb_address]; ::if {$Tpath eq ""} { ::continue; } ::sargs::var::set Sorted $Sub.values/posting/${Tax}/amount ""; } } } ::return $Sorted; } public method flow_analysis_format {Sorted} { ::set Format $currency_format; ::set Result ""; ::set Subs [::sargs::subs .structure $Sorted]; ::sargs::var::set Result [::lindex $Subs 0] [::sargs::get $Sorted [::lindex $Subs 0]]; ;#// copy opening_balances ::set Font [::sargs::get [page_setup] ".content.font"]; ::sargs::var::set Font ".weight" "bold"; ::set Ipairs ""; ::set Dpairs ""; ::foreach Item [::lrange $Subs 3 end] { ::set Xamount [qw_structure_formatted_real_get $Sorted $Item.values/posting/charge/amount]; ::switch [::sargs::get $settings ".print_distributions_flows_sort_by"] { name { ::set Xvalue [::sargs::get $Sorted $Item.values/posting/charge/account/name]; } description { ::set Xvalue [::sargs::get $Sorted $Item.values/posting/charge/account/description]; } path { ::set Xvalue [::sargs::get $Sorted $Item.values/posting/charge/account/odb_path_help]; } "" - amount_descending { ::set Xvalue $Xamount; } } ::if {$Xamount<0} { ::lappend Dpairs [::list $Item $Xvalue]; } else { ::lappend Ipairs [::list $Item $Xvalue]; } } ::switch [::sargs::get $settings ".print_distributions_flows_sort_by"] { name - description - path { ::set Ipairs [::lsort -dictionary -index 1 $Ipairs]; ::set Dpairs [::lsort -dictionary -index 1 $Dpairs]; } "" - amount_descending { ::set Ipairs [::lsort -real -index 1 -decreasing $Ipairs]; ::set Dpairs [::lsort -real -index 1 -increasing $Dpairs]; } } ::set ColumnNames $_column_names; ::set Pairs $Ipairs; ::if {[::llength $Pairs]>0} { ::sargs::var::set Result /increases_title.values/description "INCREASES"; ::sargs::var::set Result /increases_title.font $Font; ::set Sumsub ""; ::foreach Pair $Pairs { ::sargs::var::set Result [::lindex $Pair 0] [::sargs::get $Sorted [::lindex $Pair 0]]; ::foreach Colname $ColumnNames { ::if {[::sargs::exists $_amount_and_quantity_totals $Colname]} { ::set Sum [::sargs::real_get $Sumsub $Colname]; ::set Delta [qw_structure_formatted_real_get $Sorted "[::lindex $Pair 0].values$Colname"]; ::sargs::var::set Sumsub $Colname [::qw::number::add $Sum $Delta]; } } } ::sargs::var::set Result /increases_total.values/description "Total"; ::sargs::var::set Result /increases_total.font $Font; ::foreach Colname $ColumnNames { ::if {[::sargs::exists $_amount_and_quantity_totals $Colname]&&[::sargs::real_get $Sumsub $Colname]!=0.0} { ::set Total [::qw::number::format [::sargs::real_get $Sumsub $Colname] $::qw::number::formats($Format)]; ::sargs::var::set Result /increases_total.values$Colname $Total; } } } ::set Pairs $Dpairs; ::if {[::llength $Pairs]>0} { ::sargs::var::set Result /decreases_title.values/description "DECREASES"; ::sargs::var::set Result /decreases_title.font $Font; ::set Sumsub ""; ::foreach Pair $Pairs { ::sargs::var::set Result [::lindex $Pair 0] [::sargs::get $Sorted [::lindex $Pair 0]]; ::foreach Colname $ColumnNames { ::if {[::sargs::exists $_amount_and_quantity_totals $Colname]} { ::set Sum [::sargs::real_get $Sumsub $Colname]; ::set Delta [qw_structure_formatted_real_get $Sorted "[::lindex $Pair 0].values$Colname"]; ::sargs::var::set Sumsub $Colname [::qw::number::add $Sum $Delta]; } } } ::sargs::var::set Result /decreases_total.values/description "Total"; ::sargs::var::set Result /decreases_total.font $Font; ::foreach Colname $ColumnNames { ::if {[::sargs::exists $_amount_and_quantity_totals $Colname]&&[::sargs::real_get $Sumsub $Colname]!=0.0} { ::set Total [::qw::number::format [::sargs::real_get $Sumsub $Colname] $::qw::number::formats($Format)]; ::sargs::var::set Result /decreases_total.values$Colname $Total; } } } ::sargs::var::set Result /net_total.values/description "Net Change"; ::foreach Colname $ColumnNames { ::if {[::sargs::exists $_amount_and_quantity_totals $Colname]} { ::set Increase [qw_structure_formatted_real_get $Result /increases_total.values$Colname]; ::set Decrease [qw_structure_formatted_real_get $Result /decreases_total.values$Colname]; ::set Net [::qw::number::add $Increase $Decrease]; ::if {$Net!=0.0} { ::set Net [::qw::number::format $Net $::qw::number::formats($Format)]; ::sargs::var::set Result /net_total.values$Colname $Net; } } } ::sargs::var::set Result /closing_total.values/description "Ending Balance"; ::foreach Colname $ColumnNames { ::if {[::sargs::exists $_amount_and_quantity_totals $Colname]} { ::if {[::sargs::exists $Sorted [::lindex $Subs 0].values$Colname]} { ::set Opening [qw_structure_formatted_real_get $Sorted [::lindex $Subs 0].values$Colname]; ::set Change [qw_structure_formatted_real_get $Result /net_total.values$Colname]; ::set Closing [::qw::number::add $Opening $Change]; ::if {$Closing!=0.0} { ::set Closing [::qw::number::format $Closing $::qw::number::formats($Format)]; ::sargs::var::set Result /closing_total.values$Colname $Closing; } } } } ::return $Result; } public method detail_items_sorted_by_posting_charge_account_detail {Result} { ::set Subs [::sargs::subs .structure $Result]; ::set SubsLimit 100; ::set Progress ""; ::if {[::llength $Subs]>$SubsLimit} { ::set Progress [::itcl::local ::QW::PROGRESS::OPERATION #auto \ .database_id [$_application_database cpp_id] \ .file [$_application_database cpp_directory] \ .user [[$_application_database "/OBJECT"] odb_user_name] \ .limit [::llength $Subs] \ .operation "Sorting by Cross Account" \ .status "Sorting postings by detail item charge account" \ ]; } ::set RowPairs ""; ::foreach Sub [::sargs::subs .structure $Result] { ::set Xaccount [::sargs::get $Result $Sub.values/posting/charge/account/odb_path_help]; ::lappend RowPairs [::list $Sub $Xaccount]; } ::set RowPairs [::lsort -dictionary -index 1 $RowPairs]; ::set Sorted ""; ::foreach Pair $RowPairs { ::sargs::var::set Sorted [::lindex $Pair 0] [::sargs::get $Result [::lindex $Pair 0]]; ::if {$Progress ne ""} { $Progress increment; } } ::return $Sorted; } public method detail_items_sorted_by_posting_charge_account_summary {Sorted} { ::set SortedSubs [::sargs::subs .structure $Sorted]; ::set SubsLimit 100; ::set Progress ""; ::if {[::llength $SortedSubs]>$SubsLimit} { ::set Progress [::itcl::local ::QW::PROGRESS::OPERATION #auto \ .database_id [$_application_database cpp_id] \ .file [$_application_database cpp_directory] \ .user [[$_application_database "/OBJECT"] odb_user_name] \ .limit [::llength $SortedSubs] \ .operation "Summing by Cross Account" \ .status "Summing postings by detail item charge account" \ ]; } ::set Format $currency_format; ::set ColumnNames $_column_names; ::set ::qw::control(clock_clicks) 0; ::set ::qw::control(clock_clicks_ronbo) 0; ::set TotalClicks [::clock clicks -milliseconds]; ::array set XAarray {}; ::array set XFarray {}; ::set Spaths [::sargs::select_all .structure $Sorted]; ::foreach Path $Spaths { ::if {[::string first /posting/charge/account/odb_path_help $Path]<0} { ::continue; } ::set Xaccount [::sargs::get $Sorted $Path]; ::set Sub [::string range $Path 0 [::expr {[::string first . $Path]-1}]]; ::if {[::info exists XAarray($Xaccount)]} { ::set XAarray($Xaccount) [::concat $XAarray($Xaccount) $Sub]; } else { ::set XAarray($Xaccount) $Sub; } } ::foreach Xfolder [::sargs::get $settings ".print_distributions_summarize_folder_list"] { ::foreach Path $Spaths { ::if {[::string first /posting/charge/account/odb_path_help $Path]<0} { ::continue; } ::set Xaccount [::sargs::get $Sorted $Path]; ::if {[::string first $Xfolder $Xaccount]<0&&![::string match $Xfolder $Xaccount]} { ::continue; } ::set Sub [::string range $Path 0 [::expr {[::string first . $Path]-1}]]; ::if {[::info exists XFarray($Xfolder)]} { ::set XFarray($Xfolder) [::concat $XFarray($Xfolder) $Sub]; } else { ::set XFarray($Xfolder) $Sub; } } } ::foreach Sub $SortedSubs { ::if {$Progress ne ""} { $Progress increment; } ::if {![::sargs::exists $Sorted $Sub]} { ::continue; } ::set Xaccount [::sargs::get $Sorted $Sub.values/posting/charge/account/odb_path_help]; ::if {$Xaccount eq ""} { ::continue; } ::set Clicks [::clock clicks -milliseconds]; ;#//pgq,debug217 ::set Paths $XAarray($Xaccount); ::set ::qw::control(clock_clicks) [::expr {$::qw::control(clock_clicks)+[::clock clicks -milliseconds]-$Clicks}]; ::foreach Xfolder [::sargs::get $settings ".print_distributions_summarize_folder_list"] { ::if {[::string first $Xfolder $Xaccount]==0||[::string match $Xfolder $Xaccount]} { ::set Xpaths $XFarray($Xfolder); ::set Path [::lindex $Xpaths 0]; ::set Sub $Path; ::if {[::llength $Paths]<[::llength $Xpaths]} { ::sargs::var::set Sorted "$Sub.values/posting/charge/account/odb_path_help" $Xfolder; ::if {[::string first * $Xfolder]>=0||[::string first ? $Xfolder]>=0} { ::set Xfolder [::string range $Xfolder 0 [::expr {[::string last / $Xfolder]-1}]]; } ::set Fname [::string toupper [::string range $Xfolder [::expr {[::string last / $Xfolder]+1}] end]]; ::set Fpath [::string toupper [::string range $Xfolder 0 [::expr {[::string last / $Xfolder]-1}]]]; ::sargs::var::set Sargs ".name" $Fname; ::sargs::var::set Sargs ".odb_base_odb_path_help" "/ACCOUNT$Fpath"; ::sargs::var::set Sargs ".index" [[$_postings_table_window odb_database application] "/OBJECT/NEWVIEWS/ACCOUNT.odb_deriveds.index/name_closure"]; ::set Account [[[$_postings_table_window odb_database application] "/OBJECT/NEWVIEWS"] object_get_by_name_and_base_path_help_fast $Sargs]; ::if {$Account ne ""} { ::sargs::var::set Sorted "$Sub.values/posting/charge/account/description" [[$Account .description] odb_get]; ::sargs::var::set Sorted "$Sub.folder" 1; } } ::set Paths $Xpaths; } } ::sargs::var::set Sorted "$Sub.values/reference" [::llength $Paths]; ;#// too confusing when mixed with single item's reference ::if {[::llength $Paths]==1} { ::continue; } ::set Clicks [::clock clicks -milliseconds]; ::foreach Path [::lrange $Paths 1 end] { ::set Dsub $Path; ::foreach ColumnName $ColumnNames { ::set IsTotalled [::sargs::exists $_amount_and_quantity_totals $ColumnName]; ::set SubD [::sargs::get $Sorted "$Sub.values$ColumnName"]; ::set DsubD [::sargs::get $Sorted "$Dsub.values$ColumnName"]; ::switch -glob -- $ColumnName { *odb_address { } /reference { } /posting/charge/account/name - /posting/charge/account/odb_path_help - /posting/charge/account/description { ::if {$SubD ne $DsubD&&![::sargs::boolean_get $Sorted "$Sub.folder"]} { ::sargs::var::set Sorted "$Sub.values$ColumnName" ""; } } /running_balance* { } default { ::if {$SubD ne $DsubD&&!$IsTotalled} { ::if {[::string first "/rate" $ColumnName]<0&&[::string first "/profit_margin" $ColumnName]<0} { ::sargs::var::set Sorted "$Sub.values$ColumnName" ""; } } } } ::if {!$IsTotalled} { ::continue; } ::set Total [qw_structure_formatted_real_get $Sorted "$Sub.values$ColumnName"]; ::switch $ColumnName { /posting/charge/rate { } /posting/charge/quantity { ::set Total [::qw::number::add $Total [qw_structure_formatted_real_get $Sorted "$Dsub.values$ColumnName"]]; ::if {$Total!=0.0} { ::set AverageRate [::qw::number::divide [qw_structure_formatted_real_get $Sorted "$Sub.values/posting/charge/amount"] $Total]; ::sargs::var::set Sorted "$Sub.values/posting/charge/rate" $AverageRate; } else { ::sargs::var::set Sorted "$Sub.values/posting/charge/rate" ""; } } /posting/charge/amount { ::set Total [::qw::number::add $Total [qw_structure_formatted_real_get $Sorted "$Dsub.values$ColumnName"]]; ::set Quantity [qw_structure_formatted_real_get $Sorted "$Sub.values/posting/charge/quantity"]; ::if {$Quantity!=0.0} { ::set AverageRate [::qw::number::divide $Total $Quantity]; ::sargs::var::set Sorted "$Sub.values/posting/charge/rate" $AverageRate; } else { ::sargs::var::set Sorted "$Sub.values/posting/charge/rate" ""; } } /posting/cgs/rate { } /posting/cgs/quantity { ::set Total [::qw::number::add $Total [qw_structure_formatted_real_get $Sorted "$Dsub.values$ColumnName"]]; ::if {$Total!=0.0} { ::set AverageRate [::qw::number::divide [qw_structure_formatted_real_get $Sorted "$Sub.values/posting/cgs/amount"] $Total]; ::sargs::var::set Sorted "$Sub.values/posting/cgs/rate" $AverageRate; } else { ::sargs::var::set Sorted "$Sub.values/posting/cgs/rate" ""; } } /posting/cgs/amount { ::set Total [::qw::number::add $Total [qw_structure_formatted_real_get $Sorted "$Dsub.values$ColumnName"]]; ::set Quantity [qw_structure_formatted_real_get $Sorted "$Sub.values/posting/cgs/quantity"]; ::if {$Quantity!=0.0} { ::set AverageRate [::qw::number::divide $Total $Quantity]; ::sargs::var::set Sorted "$Sub.values/posting/cgs/rate" $AverageRate; } else { ::sargs::var::set Sorted "$Sub.values/posting/cgs/rate" ""; } } /profit_margin { } /profit_amount { ::set Total [::qw::number::add $Total [qw_structure_formatted_real_get $Sorted "$Dsub.values$ColumnName"]]; ::set SaleAmount [qw_structure_formatted_real_get $Sorted "$Sub.values/posting/charge/amount"]; ::if {$SaleAmount!=0.0} { ::set ProfitMargin [::qw::number::multiply [::qw::number::divide $Total $SaleAmount] 100.0]; ::sargs::var::set Sorted "$Sub.values/profit_margin" $ProfitMargin; } else { ::sargs::var::set Sorted "$Sub.values/profit_margin" ""; } } default { ::set Total [::qw::number::add $Total [qw_structure_formatted_real_get $Sorted "$Dsub.values$ColumnName"]]; } } ;#//::switch $ColumnName ::sargs::var::set Sorted "$Sub.values$ColumnName" [::qw::number::format $Total $::qw::number::formats($Format)]; } ;#//::foreach ColumnName ::sargs::var::unset Sorted $Dsub; } ;#//::foreach Path (i.e. Dsub - the detail sub) ::set ::qw::control(clock_clicks_ronbo) [::expr {$::qw::control(clock_clicks_ronbo)+[::clock clicks -milliseconds]-$Clicks}]; } ;#//::foreach Sub $SortedSubs ::return $Sorted; } public method detail_items_sorted_by_posting_charge_account_line_items_extend {Sorted} { ::set Format $currency_format; ::set SortedSubs [::sargs::subs .structure $Sorted]; ::foreach Sub $SortedSubs { ::set Xaccount [::sargs::get $Sorted $Sub.values/posting/charge/account/odb_path_help]; ::if {$Xaccount eq ""} { ::continue; } ::set Total 0.0; ::foreach Field {charge tax1 tax2 cgs inventory} { ::set Amount [qw_structure_formatted_real_get $Sorted "$Sub.values/posting/${Field}/amount"]; ::qw::number::var::add Total $Amount; } ::if {$Total!=0.0} { ::sargs::var::set Sorted "$Sub.values/amount" [::qw::number::format $Total $::qw::number::formats($Format)]; } } ::return $Sorted; } public method with_rb {Sorted} { ::set Format $currency_format; ::set SortedSubs [::sargs::subs .structure $Sorted]; ::set RBquantity [qw_structure_formatted_real_get $Sorted "[::lindex $SortedSubs 0].values/quantity"]; ::set RBamount [qw_structure_formatted_real_get $Sorted "[::lindex $SortedSubs 0].values/amount"]; ::foreach Sub [::lrange $SortedSubs 1 end] { ::set Allzero 1; ::foreach Colname $_column_names { ::set IsTotalled [::sargs::exists $_amount_and_quantity_totals $Colname]; ::if {$IsTotalled||[::string first /rate $Colname]>=0} { ::set Amount [qw_structure_formatted_real_get $Sorted $Sub.values$Colname]; ::if {$Amount==0.0} { ::sargs::var::set Sorted $Sub.values$Colname ""; } else { ::set Allzero 0; } } } ::set Xaccount [::sargs::get $Sorted $Sub.values/posting/charge/account/odb_address]; ::if {$Xaccount eq ""} { ::continue; } else { ::if {$Allzero} { ::sargs::var::unset Sorted $Sub; ::continue; } } ::set Quantity [qw_structure_formatted_real_get $Sorted "$Sub.values/posting/charge/quantity"]; ::qw::number::var::add RBquantity $Quantity; ::sargs::var::set Sorted "$Sub.values/running_balance_quantity" [::qw::number::format $RBquantity $::qw::number::formats($Format)]; ::set Amount [qw_structure_formatted_real_get $Sorted "$Sub.values/amount"]; ::qw::number::var::add RBamount $Amount; ::sargs::var::set Sorted "$Sub.values/running_balance_amount" [::qw::number::format $RBamount $::qw::number::formats($Format)]; } ::return $Sorted; } public method null_all_zeros {Sorted} { ::set SortedSubs [::sargs::subs .structure $Sorted]; ::foreach Sub [::lrange $SortedSubs 1 end-2] { ::foreach Colname $_column_names { ::set IsTotalled [::sargs::exists $_amount_and_quantity_totals $Colname]; ::if {$IsTotalled||[::string first /rate $Colname]>=0} { ::set Amount [qw_structure_formatted_real_get $Sorted $Sub.values$Colname]; ::if {$Amount==0.0} { ::sargs::var::set Sorted $Sub.values$Colname ""; } } } } ::return $Sorted; } public method with_rb_for_historic_aging {Sorted} { ::set Format $currency_format; ::set SortedSubs [::sargs::subs .structure $Sorted]; ::set RBquantity [qw_structure_formatted_real_get $Sorted "[::lindex $SortedSubs 0].values/quantity"]; ::set RBamount [qw_structure_formatted_real_get $Sorted "[::lindex $SortedSubs 0].values/amount"]; ::foreach Sub [::lrange $SortedSubs 1 end-2] { ::foreach Colname $_column_names { ::set IsTotalled [::sargs::exists $_amount_and_quantity_totals $Colname]; ::if {$IsTotalled||[::string first /rate $Colname]>=0} { ::set Amount [qw_structure_formatted_real_get $Sorted $Sub.values$Colname]; ::if {$Amount==0.0} { ::sargs::var::set Sorted $Sub.values$Colname ""; } } } ::set Quantity [qw_structure_formatted_real_get $Sorted "$Sub.values/quantity"]; ::qw::number::var::add RBquantity $Quantity; ::sargs::var::set Sorted "$Sub.values/running_balance_quantity" [::qw::number::format $RBquantity $::qw::number::formats($Format)]; ::set Amount [qw_structure_formatted_real_get $Sorted "$Sub.values/amount"]; ::qw::number::var::add RBamount $Amount; ::sargs::var::set Sorted "$Sub.values/running_balance_amount" [::qw::number::format $RBamount $::qw::number::formats($Format)]; } ::return $Sorted; } public method qw_structure_formatted_real_get {Structure Path} { ::set Result [remove_amount_formatting [::sargs::get $Structure $Path]]; ::if {$Result eq ""} { ::return 0.0; } ::return $Result; } public method remove_amount_formatting {Src} { ::set Result [::regsub -all {[^0-9.]} $Src ""]; ::if {[::regexp {\(|-} $Src]} { ::set Result [::qw::number::negative $Result]; } ::return $Result; } public method postings_table_configure {Account} { ::set NormalBalance [$Account normal_balance_get]; $_postings_master_desktop_window observer_database $Account; ::if {$::qw::control(signal_pick_kids_after_time_delay)} { [$_postings_master_desktop_window ".pick.kids"] signalWrite; } $_postings_master_desktop_window odb_commit; ::set _print_range "all"; ::set OpeningBalanceDate [::sargs::get $settings ".periodic_begin_date"]; ::if {$OpeningBalanceDate eq ""} { ::set OpeningBalanceDate [::qw::date::extend_begin "1905"]; ::set RangeBeginDate $OpeningBalanceDate; ::set RangeEndDate [::qw::date::extend_end "2035"]; } else { ::set RangeBeginDate [::qw::date::extend_begin [::string range [::sargs::get $settings ".range_begin"] 0 7]]; ::set RangeEndDate [::qw::date::extend_end [::string range [::sargs::get $settings ".range_end"] 0 7]]; } ::set Tag [::string trim [::sargs::get $settings ".tag"]]; ::if {$Tag eq ""} { ::set Tag "financial"; } ::set _opening_balances ""; ::set Range [::qw::odb::factory range]; ::set PriorEndDate [::qw::date::extend_end [::string range [::qw::date::add $RangeBeginDate "day" -1] 0 7]]; $Range cpp_configure -index [[$Account odb_master] ".postings.index/date"] -begin ".tag $Tag" -end ".tag $Tag .date $PriorEndDate"; ::if {$::qw::control(print_account_ledgers_historic_aging)} {} ::switch [::sargs::get $settings .index_path] { ".postings.index/date/open" { $Range cpp_configure -index [[$Account odb_master] ".postings.index/date"] -begin ".tag $Tag" -end ".tag $Tag .date $PriorEndDate"; } default { $Range cpp_configure -index [[$Account odb_master] [::sargs::get $settings .index_path]] -begin ".tag $Tag" -end ".tag $Tag .date $PriorEndDate"; ::if {[::sargs::boolean_get $settings .historic_aging]} { } } } ::set OpeningQty [[$Range odb_master] history_file_odb_total [::sargs .range $Range .rb_name .quantity .priority foreground]]; ::set OpeningAmt [[$Range odb_master] history_file_odb_total [::sargs .range $Range .rb_name .amount .priority foreground]]; ::if {[::sargs::boolean_get $settings .closed_is_hit] eq "no"} { ::set OpenRbType [::sargs::get $settings .include_closed_balance]; ::switch -- $OpenRbType { "exclude" {::set OpenRbType "zero";} "include" {::set OpenRbType "all_closed";} } ::if {$OpenRbType eq ""||$OpenRbType eq "zero"} { ::set OpeningQty 0.0; ::set OpeningAmt 0.0; } else { ::set Index [$Range cpp_cget -index]; ::set TempRange [::qw::odb::factory range]; ::qw::finally [::list $TempRange cpp_destroy]; ::set TempBegin [$Range cpp_cget -begin]; ::set TempEnd [$Range cpp_cget -end]; ::switch -- $OpenRbType { "open" {::set Index [::string map "/date /date/open" $Index];} "closed" {::set Index [::string map "/date /date/closed" $Index];} "ledger" {} "all_closed" { ::set Index [::string map "/date /date/closed" $Index]; ::if {[::sargs::exists $TempBegin .date]} { ::sargs::var::unset TempBegin .date; } ::if {[::sargs::exists $TempEnd .date]} { ::sargs::var::unset TempEnd .date; } } } $TempRange cpp_configure \ -index $Index \ -begin $TempBegin \ -end $TempEnd \ ; ::set OpeningQty [[$TempRange odb_master] history_file_odb_total [::sargs .range $TempRange .rb_name .quantity .priority foreground]]; ::set OpeningAmt [[$TempRange odb_master] history_file_odb_total [::sargs .range $TempRange .rb_name .amount .priority foreground]]; } } ::if {[[$Account ".normal_representation"] odb_get] eq "periodic" \ &&[::sargs::boolean_get $settings ".respect_normal_representation"] \ } { ::if {$OpeningBalanceDate eq ""} { ::set PriorEndDate [::qw::date::extend_end [::string range [::qw::date::add "19050101" "day" -1] 0 7]]; $Range cpp_configure -end ".tag $Tag .date $PriorEndDate"; } else { ::set PriorEndDate [::qw::date::extend_end [::string range [::qw::date::add $OpeningBalanceDate "day" -1] 0 7]]; $Range cpp_configure -end ".tag $Tag .date $PriorEndDate"; } ::qw::number::var::subtract OpeningQty [[$Range odb_master] history_file_odb_total [::sargs .range $Range .rb_name .quantity .priority foreground]]; ::qw::number::var::subtract OpeningAmt [[$Range odb_master] history_file_odb_total [::sargs .range $Range .rb_name .amount .priority foreground]]; } $Range cpp_destroy; ::foreach {Oname Obal} "quantity $OpeningQty amount $OpeningAmt" { ::set Debit ""; ::set Credit ""; ::if {$NormalBalance eq "debit"} { ::if {$Obal>=0.0} { ::set Debit $Obal; } else { ::set Credit [::qw::number::abs $Obal]; } } else { ::if {$Obal<=0.0} { ::set Credit [::qw::number::abs $Obal]; } else { ::set Debit $Obal; } ::qw::number::var::negative Obal; } ::sargs::var::set _opening_balances ".values/$Oname" $Obal; ::sargs::var::set _opening_balances ".values/${Oname}_debit" $Debit; ::sargs::var::set _opening_balances ".values/${Oname}_credit" $Credit; ::sargs::var::set _opening_balances ".values/running_balance_${Oname}" $Obal; } ::set FormattedDate [::qw::date::format $RangeBeginDate $::qw::date::formats($date_format)]; ::set TitleText "Opening Balance"; ::if {$RangeBeginDate eq ""} { ::append TitleText " at $FormattedDate"; } ::sargs::var::set _opening_balances ".values/description" "$TitleText"; [$_postings_table_window ".column_names"] odb_set $_column_names; [$_postings_table_window ".observer_range_begin"] odb_set ".tag $Tag .date $RangeBeginDate"; [$_postings_table_window ".observer_range_end"] odb_set ".tag $Tag .date $RangeEndDate"; ::set _amount_and_quantity_totals ""; ::set ColumnDefinitions [[$_postings_table_window ".column_definitions"] odb_get]; ::foreach ColumnName $_column_names { ::set GetScript [::sargs::get $ColumnDefinitions "$ColumnName.script/command/get"]; ::if {[::string first "::qw::number::format" $GetScript]>=0&&[::string first "rate" $ColumnName]<0&&[::string first "profit_margin" $ColumnName]<0} { ::sargs::var::set _amount_and_quantity_totals "$ColumnName.value" 0.0; ::sargs::var::set _amount_and_quantity_totals "$ColumnName.format" [::sargs::get $ColumnDefinitions "$ColumnName.format"] } } $_postings_master_desktop_window odb_commit; } public method postings_table_initialize {} { ::set IndexPath [::sargs::get $settings .index_path]; [$_postings_table_window ".observer_index"] odb_set [::string map {.postings {}} $IndexPath]; ::set ColumnNames [::sargs::get $settings ".column_names"]; ::set ColumnDefinitions [[$_postings_table_window ".column_definitions"] odb_get]; ::set ColumnSetup ""; ::if {[::lsearch -exact $ColumnNames "/account/report/name"]>=0} { ::sargs::var::set ColumnSetup "/account/report/name.script/title" "Report"; } ::if {[::lsearch -exact $ColumnNames "/account/report/description"]>=0} { ::sargs::var::set ColumnSetup "/account/report/description.script/title" "Report Description"; } ::sargs::var::set ColumnSetup "/running_balance_quantity.script/title" "Qty Balance"; ::sargs::var::set ColumnSetup "/running_balance_amount.script/title" "Amt Balance"; ::if {[::lsearch -exact $ColumnNames "/journal/description"]>=0} { ::sargs::var::set ColumnSetup "/journal/description.script/title" "Journal Description"; } ::if {$::qw::control(comprehensive_postings_table)} {} ::set Database [$_postings_table_window odb_database]; ::append Postings "/posting/debit/charge /charge"; ;#// for overloaded version we just want any posting column profile, which will be patched ::append Postings " /posting/debit/tax1 /tax1"; ::append Postings " /posting/debit/tax2 /tax2"; ::append Postings " /posting/debit/cgs /cgs"; ::append Postings " /posting/credit/inventory /inventory"; ::set RefDefs [[$Database "/OBJECT/SYSTEM/WINDOW/SCROLLED/TABLE/NEWVIEWS/POSTINGSUBS"] columnDefinitionTree]; ::sargs::var::set NewDefs "/posting" $RefDefs; ::sargs::var::set NewDefs "/posting/debit" $RefDefs; ::sargs::var::set NewDefs "/posting/credit" $RefDefs; ::foreach {Path Sub} $Postings { ::sargs::var::set NewDefs $Path $RefDefs; } ::foreach Class "/TRANSACTION" { ::sargs::var::set PostingDef "/posting" [::sargs::get [[$Database "/OBJECT/SYSTEM/WINDOW/SCROLLED/TABLE/NEWVIEWS/SYSTEM$Class.column_definitions"] qw_get] "/posting"]; ::sargs::var::+= NewDefs $PostingDef; } ::set Postings ""; ::append Postings "/posting/charge /posting/debit/charge /charge"; ::foreach {Path BorrowPath Sub} $Postings { ::sargs::var::set NewDefs "$Path" [::sargs::get $NewDefs $BorrowPath]; ::sargs::var::set _distribution_table_column_setup "$Path" [::sargs::get $NewDefs $BorrowPath]; ::set Script { ::switch -glob -- [[%_object odb_master] odb_path] { "/OBJECT/NEWVIEWS/SYSTEM/TRANSACTION/SALES*" {::return [%_object "/credit%_sub"];} "/OBJECT/NEWVIEWS/SYSTEM/TRANSACTION/PURCHASE*" {::return [%_object "/debit%_sub"];} "/OBJECT/NEWVIEWS/SYSTEM/TRANSACTION/BANK/DEPOSIT*" {::return [%_object "/credit"];} "/OBJECT/NEWVIEWS/SYSTEM/TRANSACTION/BANK/PAYMENT*" {::return [%_object "/debit"];} "/OBJECT/NEWVIEWS/SYSTEM/TRANSACTION/GENERAL*" { ::set Account [[[%_object odb_master] ".posting/debit.account"] qw_get]; ::if {$Account ne ""} { ::return [%_object "/debit"]; } ::return [%_object "/credit"]; } "/OBJECT/NEWVIEWS/SYSTEM/TRANSACTION/PAYROLL*" {::return [%_object "/debit"];} } ::return ""; } ::set Script [::string map "%_sub $Sub" $Script]; ::sargs::var::set NewDefs "$Path.script/command/get" $Script; ::sargs::var::set _distribution_table_column_setup "$Path.script/command/get" $Script; ::if {[::sargs::boolean_get $settings .print_distributions_flows_analysis]} { ::foreach Value "quantity amount" { ::sargs::var::set NewDefs "$Path/amount.script/command/get" [::sargs::get $ColumnDefinitions "/amount.script/command/get"]; ::set Script { ::set Amount [[%_object ".%_value"] odb_get]; ::set Observer [[%_this odb_master] observer_database]; ::if {$Observer ne ""} { ::if {[[$Observer odb_master] normal_balance_get] eq "credit"} {::qw::number::var::negative Amount;} } ::return [::qw::number::format $Amount $::qw::number::formats(%_format)]; } ::set Script [::string map "%_value $Value" $Script]; ::sargs::var::set NewDefs "$Path/$Value.script/command/get" $Script; ::sargs::var::set _distribution_table_column_setup "$Path/$Value.script/command/get" $Script; } } } ::set Postings ""; ::append Postings " /posting/tax1 /posting/debit/tax1 /tax1"; ::append Postings " /posting/tax2 /posting/debit/tax2 /tax2"; ::foreach {Path BorrowPath Sub} $Postings { ::sargs::var::set NewDefs "$Path" [::sargs::get $NewDefs $BorrowPath]; ::sargs::var::set _distribution_table_column_setup "$Path" [::sargs::get $NewDefs $BorrowPath]; ::set Script { ::switch -glob -- [[%_object odb_master] odb_path] { "/OBJECT/NEWVIEWS/SYSTEM/TRANSACTION/SALES*" {::return [%_object "/credit%_sub"];} "/OBJECT/NEWVIEWS/SYSTEM/TRANSACTION/PURCHASE*" {::return [%_object "/debit%_sub"];} "/OBJECT/NEWVIEWS/SYSTEM/TRANSACTION/BANK/PAYMENT*" {::return "";} "/OBJECT/NEWVIEWS/SYSTEM/TRANSACTION/BANK/DEPOSIT*" {::return "";} "/OBJECT/NEWVIEWS/SYSTEM/TRANSACTION/GENERAL*" {::return "";} "/OBJECT/NEWVIEWS/SYSTEM/TRANSACTION/PAYROLL*" {::return "";} } ::return ""; } ::set Script [::string map "%_sub $Sub" $Script]; ::sargs::var::set NewDefs "$Path.script/command/get" $Script; ::sargs::var::set _distribution_table_column_setup "$Path.script/command/get" $Script; ::if {[::sargs::boolean_get $settings .print_distributions_flows_analysis]} { ::foreach Value "amount" { ::sargs::var::set NewDefs "$Path/amount.script/command/get" [::sargs::get $ColumnDefinitions "/amount.script/command/get"]; ::set Script { ::set Amount [[%_object ".%_value"] odb_get]; ::set Observer [[%_this odb_master] observer_database]; ::if {$Observer ne ""} { ::if {[[$Observer odb_master] normal_balance_get] eq "credit"} {::qw::number::var::negative Amount;} } ::return [::qw::number::format $Amount $::qw::number::formats(%_format)]; } ::set Script [::string map "%_value $Value" $Script]; ::sargs::var::set NewDefs "$Path/$Value.script/command/get" $Script; ::sargs::var::set _distribution_table_column_setup "$Path/$Value.script/command/get" $Script; } } } ::set Postings ""; ::append Postings " /posting/cgs /posting/debit/cgs /cgs"; ::foreach {Path BorrowPath Sub} $Postings { ::sargs::var::set NewDefs "$Path" [::sargs::get $NewDefs $BorrowPath]; ::sargs::var::set _distribution_table_column_setup "$Path" [::sargs::get $NewDefs $BorrowPath]; ::set Script { ::switch -glob -- [[%_object odb_master] odb_path] { "/OBJECT/NEWVIEWS/SYSTEM/TRANSACTION/SALES*" {::return [%_object "/debit%_sub"];} "/OBJECT/NEWVIEWS/SYSTEM/TRANSACTION/PURCHASE*" - "/OBJECT/NEWVIEWS/SYSTEM/TRANSACTION/BANK/PAYMENT*" - "/OBJECT/NEWVIEWS/SYSTEM/TRANSACTION/BANK/DEPOSIT*" - "/OBJECT/NEWVIEWS/SYSTEM/TRANSACTION/GENERAL*" - "/OBJECT/NEWVIEWS/SYSTEM/TRANSACTION/PAYROLL*" {::return "";} } ::return ""; } ::set Script [::string map "%_sub $Sub" $Script]; ::sargs::var::set NewDefs "$Path.script/command/get" $Script; ::sargs::var::set _distribution_table_column_setup "$Path.script/command/get" $Script; ::if {[::sargs::boolean_get $settings .print_distributions_flows_analysis]} { ::foreach Value "quantity amount" { ::sargs::var::set NewDefs "$Path/amount.script/command/get" [::sargs::get $ColumnDefinitions "/amount.script/command/get"]; ::set Script { ::set Amount [[%_object ".%_value"] odb_get]; ::set Observer [[%_this odb_master] observer_database]; ::if {$Observer ne ""} { ::if {[[$Observer odb_master] normal_balance_get] eq "debit"} {::qw::number::var::negative Amount;} ;#// AR works, Current Assets doesn't } ::return [::qw::number::format $Amount $::qw::number::formats(%_format)]; } ::set Script [::string map "%_value $Value" $Script]; ::sargs::var::set NewDefs "$Path/$Value.script/command/get" $Script; ::sargs::var::set _distribution_table_column_setup "$Path/$Value.script/command/get" $Script; } } } ::set Postings ""; ::append Postings " /posting/inventory /posting/credit/inventory /inventory"; ::foreach {Path BorrowPath Sub} $Postings { ::sargs::var::set NewDefs "$Path" [::sargs::get $NewDefs $BorrowPath]; ::sargs::var::set _distribution_table_column_setup "$Path" [::sargs::get $NewDefs $BorrowPath]; ::set Script { ::switch -glob -- [[%_object odb_master] odb_path] { "/OBJECT/NEWVIEWS/SYSTEM/TRANSACTION/SALES*" {::return [%_object "/credit%_sub"];} "/OBJECT/NEWVIEWS/SYSTEM/TRANSACTION/PURCHASE*" - "/OBJECT/NEWVIEWS/SYSTEM/TRANSACTION/BANK/PAYMENT*" - "/OBJECT/NEWVIEWS/SYSTEM/TRANSACTION/BANK/DEPOSIT*" - "/OBJECT/NEWVIEWS/SYSTEM/TRANSACTION/GENERAL*" - "/OBJECT/NEWVIEWS/SYSTEM/TRANSACTION/PAYROLL*" {::return "";} } ::return ""; } ::set Script [::string map "%_sub $Sub" $Script]; ::sargs::var::set NewDefs "$Path.script/command/get" $Script; ::sargs::var::set _distribution_table_column_setup "$Path.script/command/get" $Script; ::if {[::sargs::boolean_get $settings .print_distributions_flows_analysis]} { ::foreach Value "quantity amount" { ::sargs::var::set NewDefs "$Path/amount.script/command/get" [::sargs::get $ColumnDefinitions "/amount.script/command/get"]; ::set Script { ::set Amount [[%_object ".%_value"] odb_get]; ::set Observer [[%_this odb_master] observer_database]; ::if {$Observer ne ""} { ::if {[[$Observer odb_master] normal_balance_get] eq "debit"} {::qw::number::var::negative Amount;} } ::return [::qw::number::format $Amount $::qw::number::formats(%_format)]; } ::set Script [::string map "%_value $Value" $Script]; ::sargs::var::set NewDefs "$Path/$Value.script/command/get" $Script; ::sargs::var::set _distribution_table_column_setup "$Path/$Value.script/command/get" $Script; } } } ::sargs::var::set _distribution_table_column_setup \ "/posting/charge/account/odb_path_help.format" "short_lower_case_folder" \ ; ::sargs::var::set _distribution_table_column_setup \ "/posting/tax1/account/odb_path_help.format" "short_lower_case_folder" \ "/posting/tax2/account/odb_path_help.format" "short_lower_case_folder" \ "/posting/cgs/account/odb_path_help.format" "short_lower_case_folder" \ "/posting/inventory/account/odb_path_help.format" "short_lower_case_folder" \ ; ::sargs::var::+= ColumnSetup $NewDefs; ::set _postings_table_column_setup ""; ::sargs::var::set _postings_table_column_setup \ "/account/odb_path_help.format" "short_lower_case_folder" \ "/journal/odb_path_help.format" "short_lower_case_folder" \ "/cross_account/odb_path_help.format" "short_lower_case_folder" \ "/account/report/odb_path_help.format" "short_lower_case_folder" \ "/posting/charge/quantity.script/title" "Detail Qty" \ "/posting/charge/rate.script/title" "Detail Rate" \ "/posting/charge/amount.script/title" "Detail Amt" \ "/posting/charge/account/name.script/title" "Detail\nAccount Name" \ "/posting/charge/account/description.script/title" "Detail Account Description" \ "/posting/charge/account/odb_path_help.script/title" "Detail\nAccount Path" \ "/posting/charge/account/odb_path_help.format" "short_lower_case_folder" \ ; ::sargs::var::set _postings_table_column_setup \ "/posting/tax1/account/odb_path_help.format" "short_lower_case_folder" \ "/posting/tax2/account/odb_path_help.format" "short_lower_case_folder" \ "/posting/cgs/account/odb_path_help.format" "short_lower_case_folder" \ "/posting/inventory/account/odb_path_help.format" "short_lower_case_folder" \ ; ::sargs::var::set _postings_table_column_setup \ "/posting/cgs/quantity.script/title" "CGS Qty" \ "/posting/cgs/rate.script/title" "CGS Rate" \ "/posting/cgs/amount.script/title" "CGS Amt" \ "/posting/cgs/account/name.script/title" "CGS\nAccount Name" \ "/posting/cgs/account/description.script/title" "CGS Account Description" \ "/posting/cgs/account/odb_path_help.script/title" "CGS\nAccount Path" \ ; ::sargs::var::set _postings_table_column_setup \ "/posting/inventory/quantity.script/title" "Inventory Qty" \ "/posting/inventory/rate.script/title" "Inventory Rate" \ "/posting/inventory/amount.script/title" "Inventory Amt" \ "/posting/inventory/account/name.script/title" "Inventory\nAccount Name" \ "/posting/inventory/account/description.script/title" "Inventory Account Description" \ "/posting/inventory/account/odb_path_help.script/title" "Inventory\nAccount Path" \ ; ::set Tax1TitleScript {[ ::set Journal [[$this odb_database application] "/OBJECT/NEWVIEWS/JOURNAL/SALES"]; ::set Title [[$Journal ".trade_tax/1.description"] odb_get]; ::if {$Title ne ""} {::return $Title;} ::set Journal [[$this odb_database application] "/OBJECT/NEWVIEWS/JOURNAL/PURCHASE"]; ::set Title [[$Journal ".trade_tax/1.description"] odb_get]; ::if {$Title ne ""} {::return $Title;} ::return "Tax1"; ]} ::set Tax2TitleScript {[ ::set Journal [[$this odb_database application] "/OBJECT/NEWVIEWS/JOURNAL/SALES"]; ::set Title [[$Journal ".trade_tax/2.description"] odb_get]; ::if {$Title ne ""} {::return $Title;} ::set Journal [[$this odb_database application] "/OBJECT/NEWVIEWS/JOURNAL/PURCHASE"]; ::set Title [[$Journal ".trade_tax/2.description"] odb_get]; ::if {$Title ne ""} {::return $Title;} ::return "Tax2"; ]} ::sargs::var::set _postings_table_column_setup \ "/posting/tax1/amount.script/title" $Tax1TitleScript \ "/posting/tax2/amount.script/title" $Tax2TitleScript \ ; ::sargs::var::set _postings_table_column_setup \ "/posting/tax1/account/odb_path_help.script/title" "${Tax1TitleScript} Account" \ "/posting/tax2/account/odb_path_help.script/title" "${Tax2TitleScript} Account" \ ; ::sargs::var::+= ColumnSetup $_postings_table_column_setup; [$_postings_table_window ".column_definitions"] odb_set [::sargs::+= [[$_postings_table_window ".column_definitions"] qw_get] $ColumnSetup]; [$_postings_table_window ".column_names"] odb_set $ColumnNames; $_postings_table_window odb_commit; ::set _column_titles [[$_postings_table_window ".client"] dataInterfaceRowTitle]; ::set _column_names [[$_postings_table_window ".column_names"] odb_get]; ::set _column_names_user_selected $_column_names; ::lappend _column_names /account/odb_address; ::lappend _column_names /posting/charge/account/odb_address; ::lappend _column_names /cross_account/odb_address; ::lappend _column_names /posting/tax1/account/odb_address; ::lappend _column_names /posting/tax2/account/odb_address; ::lappend _column_names /posting/inventory/account/odb_address; ::lappend _column_names /posting/cgs/account/odb_address; ::foreach Colname { /account/odb_path_help /cross_account/odb_path_help /cross_account/name /cross_account/description /posting/charge/account/odb_path_help /posting/charge/amount } { ::if {[::lsearch $_column_names $Colname]<0} { ::lappend _column_names $Colname; } } [$_postings_table_window ".column_names"] odb_set $_column_names; $_postings_table_window odb_commit; ::set _column_definition_tree [$_postings_table_window columnDefinitionTree]; ::set _empty_row_values ""; ::foreach Name $_column_names { ::lappend _empty_row_values ""; } ::set _postings_table_initialize_odb_level [postings_table_initialize_odb_level]; } public method postings_table_initialize_odb_level {} { ::set Pdefs ""; ::set Ddefs $_distribution_table_column_setup; ::set NormalBalance "credit"; ::if {[::sargs::boolean_get $settings .print_distributions_flows_analysis]} { } ::set Postings ""; ::append Postings "/posting/charge /posting/debit/charge /charge"; ::foreach {Path BorrowPath Sub} $Postings { ::set Script { ::switch -glob -- [[%_object odb_master] odb_path] { "/OBJECT/NEWVIEWS/SYSTEM/TRANSACTION/SALES*" {::return [%_object "/credit%_sub"];} "/OBJECT/NEWVIEWS/SYSTEM/TRANSACTION/PURCHASE*" {::return [%_object "/debit%_sub"];} "/OBJECT/NEWVIEWS/SYSTEM/TRANSACTION/BANK/DEPOSIT*" {::return [%_object "/credit"];} "/OBJECT/NEWVIEWS/SYSTEM/TRANSACTION/BANK/PAYMENT*" {::return [%_object "/debit"];} "/OBJECT/NEWVIEWS/SYSTEM/TRANSACTION/GENERAL*" { ::set Account [[[%_object odb_master] ".posting/debit.account"] qw_get]; ::if {$Account ne ""} { ::return [%_object "/debit"]; } ::return [%_object "/credit"]; } "/OBJECT/NEWVIEWS/SYSTEM/TRANSACTION/PAYROLL*" {::return [%_object "/debit"];} } ::return ""; } ::set Script [::string map "%_sub $Sub" $Script]; ::sargs::var::set Pdefs "$Path.script/command/get" $Script; ::sargs::var::set Ddefs "$Path.script/command/get" $Script; ::if {[::sargs::boolean_get $settings .print_distributions_flows_analysis]} { ::foreach Value "quantity amount" { ::set Script { ::set Amount [[%_object ".%_value"] odb_get]; ::if {[%_context_account normal_balance_get] ne "%_normal_balance"} { ::qw::number::var::negative Amount; } ::return [::qw::number::format $Amount $::qw::number::formats(%_format)]; } ::set Script [::string map "%_value $Value" $Script]; ::set Script [::string map "%_normal_balance $NormalBalance" $Script]; ::sargs::var::set Pdefs "$Path/$Value.script/command/get" $Script; ::sargs::var::set Ddefs "$Path/$Value.script/command/get" $Script; } } } ::set Postings ""; ::append Postings " /posting/tax1 /posting/debit/tax1 /tax1"; ::append Postings " /posting/tax2 /posting/debit/tax2 /tax2"; ::foreach {Path BorrowPath Sub} $Postings { ::set Script { ::switch -glob -- [[%_object odb_master] odb_path] { "/OBJECT/NEWVIEWS/SYSTEM/TRANSACTION/SALES*" {::return [%_object "/credit%_sub"];} "/OBJECT/NEWVIEWS/SYSTEM/TRANSACTION/PURCHASE*" {::return [%_object "/debit%_sub"];} } ::return ""; } ::set Script [::string map "%_sub $Sub" $Script]; ::sargs::var::set Pdefs "$Path.script/command/get" $Script; ::sargs::var::set Ddefs "$Path.script/command/get" $Script; ::if {[::sargs::boolean_get $settings .print_distributions_flows_analysis]} { ::foreach Value "amount" { ::set Script { ::set Amount [[%_object ".%_value"] odb_get]; ::if {[%_context_account normal_balance_get] ne "%_normal_balance"} { ::qw::number::var::negative Amount; } ::return [::qw::number::format $Amount $::qw::number::formats(%_format)]; } ::set Script [::string map "%_value $Value" $Script]; ::set Script [::string map "%_normal_balance $NormalBalance" $Script]; ::sargs::var::set Pdefs "$Path/$Value.script/command/get" $Script; ::sargs::var::set Ddefs "$Path/$Value.script/command/get" $Script; } } } ::set Postings ""; ::append Postings " /posting/cgs /posting/debit/cgs /cgs"; ::foreach {Path BorrowPath Sub} $Postings { ::set Script { ::switch -glob -- [[%_object odb_master] odb_path] { "/OBJECT/NEWVIEWS/SYSTEM/TRANSACTION/SALES*" {::return [%_object "/debit%_sub"];} } ::return ""; } ::set Script [::string map "%_sub $Sub" $Script]; ::sargs::var::set Pdefs "$Path.script/command/get" $Script; ::sargs::var::set Ddefs "$Path.script/command/get" $Script; ::if {[::sargs::boolean_get $settings .print_distributions_flows_analysis]} { ::foreach Value "quantity amount" { ::set Script { ::set Amount [[%_object ".%_value"] odb_get]; ::if {[%_context_account normal_balance_get] eq "%_normal_balance"} {::qw::number::var::negative Amount;} ;#// AR works, Current Assets doesn't ::return [::qw::number::format $Amount $::qw::number::formats(%_format)]; } ::set Script [::string map "%_value $Value" $Script]; ::set Script [::string map "%_normal_balance $NormalBalance" $Script]; ::sargs::var::set Pdefs "$Path/$Value.script/command/get" $Script; ::sargs::var::set Ddefs "$Path/$Value.script/command/get" $Script; } } } ::set Postings ""; ::append Postings " /posting/inventory /posting/credit/inventory /inventory"; ::foreach {Path BorrowPath Sub} $Postings { ::set Script { ::switch -glob -- [[%_object odb_master] odb_path] { "/OBJECT/NEWVIEWS/SYSTEM/TRANSACTION/SALES*" {::return [%_object "/credit%_sub"];} } ::return ""; } ::set Script [::string map "%_sub $Sub" $Script]; ::sargs::var::set Pdefs "$Path.script/command/get" $Script; ::sargs::var::set Ddefs "$Path.script/command/get" $Script; ::if {[::sargs::boolean_get $settings .print_distributions_flows_analysis]} { ::foreach Value "quantity amount" { ::set Script { ::set Amount [[%_object ".%_value"] odb_get]; ::if {[%_context_account normal_balance_get] eq "%_normal_balance"} { ::qw::number::var::negative Amount; } ::return [::qw::number::format $Amount $::qw::number::formats(%_format)]; } ::set Script [::string map "%_value $Value" $Script]; ::set Script [::string map "%_normal_balance $NormalBalance" $Script]; ::sargs::var::set Pdefs "$Path/$Value.script/command/get" $Script; ::sargs::var::set Ddefs "$Path/$Value.script/command/get" $Script; } } } ::return $Ddefs; ::sargs::var::+= Pdefs $Ddefs; ::return $Pdefs; } public method workbook_new {{Filename ""}} { ::if {$Filename eq ""} { ::return [$_excel_workbooks factory]; } ::qw::try { ::return [$_excel_workbooks factory -filename $Filename]; } catch Exception { ::qw::throw [::sargs \ .text "Could not open file $Filename, $Exception" \ .help_id 907020050517120300 \ ]; } } public method workbook_select {Src} { ::set _workbook [$_excel_workbooks select $Src]; $_workbook activate; ::set _excel_sheets [$_workbook sheets]; ::set Sheet [$_excel_sheets selected]; ::if {$Sheet eq ""} { ::set Sheet [$_excel_sheets kidFirst [::sargs ".kid_create" 1]]; } sheet_select $Sheet; ::return $_workbook; } public method workbook_close {Src} { $Src mark_file_saved; $Src close; $_excel_workbooks destroy $Src; ::set _sheet ""; ::return $this; } public method hide_extra_sheets {} { ::foreach Sheet [::sargs::get [$_workbook clientdata] ".default_sheets"] { $Sheet visible 0; } ::return $this; } public method sheet_new {} { ::return [$_excel_sheets factory]; } public method sheet_select {Src} { ::if {$_sheet eq $Src} {::return $_sheet;} ::if {$_sheet ne ""} { ::set Clientdata [$_sheet clientdata]; ::sargs::var::set Clientdata ".current_row" $_sheet_row; ::sargs::var::set Clientdata ".current_column" $_sheet_column; $_sheet clientdata $Clientdata } ::set _sheet [$_excel_sheets select $Src]; $_sheet activate; ::set Clientdata [$Src clientdata]; ::set _sheet_row [::sargs::get $Clientdata ".current_row"]; ::set _sheet_column [::sargs::get $Clientdata ".current_column"]; ::set _pagesetup [$_sheet pagesetup]; ::set _columns [$_sheet columns]; ::set _rows [$_sheet rows]; ::set _cells [$_sheet cells]; ::set _ranges [$_sheet ranges]; ::set _column [$_columns kidFirst [::sargs ".kid_create" 1]]; ::set _row [$_rows kidFirst [::sargs ".kid_create" 1]]; ::set _cell [$_cells kidFirst [::sargs ".kid_create" 1]]; ::set _range [$_ranges kidFirst [::sargs ".kid_create" 1]]; $_range rectangle_Set {.size {.x 1 .y 1} .position {.x 1 .y 1}}; ::return $_sheet; } public method sheet_name {{Src "get"}} { ::if {$Src eq "get"} { ::return [$_sheet name_Get]; } $_sheet name_Set $Src; } public method workbook_name {{Src "get"}} { ::if {$Src eq "get"} { ::return [$_workbook name_Get]; } $_workbook name_Set $Src; } public method workbook_current {} { ::return $_workbook; } public method sheet_current {} { ::return $_sheet; } public method sheet_initialize {} { ::if {[::sargs::boolean_get [$_sheet clientdata] ".initialized"]} { ::qw::throw "$_sheet has already been initialized." ::return $_sheet; } load_template_settings; pagesetup_column_widths_set; pagesetup_column_types_set; pagesetup_margins_set; pagesetup_header_and_footer_set; pagesetup_page_layout_set; ::set _content_rectangle [::list .position [::list .x $_sheet_start_column .y $_sheet_row] .size [::list .x [::llength $_column_titles] .y 0]]; $_sheet clientdata [::sargs::set [$_sheet clientdata] ".initialized" 1]; ::return $_sheet; } public method sheet_finalize {} { ::if {[::sargs::boolean_get [$_sheet clientdata] ".finalized"]} { ::return $_sheet; } pagesetup_column_formats_set; pagesetup_column_justifications_set; set_print_range [::list .position [::list .x 0 .y 0] .size [::list .x [::llength $_column_names_user_selected] .y $_sheet_row]]; apply_template_settings; activate_top_left; mark_file_saved $_sheet clientdata [::sargs::set [$_sheet clientdata] ".finalized" 1]; ::return $_sheet; } } ::itcl::class ::qw::print::windows::table::transactions { inherit ::qw::print::windows::table; protected variable _postings_table_initialize_odb_level ""; protected variable _columnDefinitionTree ""; protected variable _column_names_user_selected ""; protected variable _postings_table_column_setup ""; protected variable _distribution_table_column_setup ""; protected variable _distribution_table ""; protected variable _print_range ""; protected variable _opening_balances ""; protected variable _postings_master_desktop_window ""; protected variable _postings_explorer_window ""; protected variable _postings_table_window ""; protected variable _amount_and_quantity_totals ""; ;#// structure, real numbers for summing are identified by searching get scripts for number formatting! protected variable _postings_data ""; protected variable _empty_row_values ""; public variable print_distributions "no" {configure_print_distributions $print_distributions;} public variable account_list ""; public variable booted_by ""; method configure_print_distributions {Src} { ::if {![::string is boolean $print_distributions]} { ::qw::throw "Invalid print_distributions boolean \"$print_distributions\"."; } } method configure_window {Src} { ::if {[::string first "/OBJECT/SYSTEM/WINDOW/SCROLLED/DESKTOP/OBJECT/MASTER/NEWVIEWS/JOURNAL" [$Src odb_path]]!=0} { ::qw::throw "-window is not a /OBJECT/SYSTEM/WINDOW/SCROLLED/DESKTOP/OBJECT/MASTER/NEWVIEWS/JOURNAL."; } ::set _application_database [$Src odb_database application]; ::set _postings_master_desktop_window $Src; ::set _postings_explorer_window [[[[$_postings_master_desktop_window .owner.kids] odb_primary] odb_first] odb_master]; ::if {[::string first "/OBJECT/SYSTEM/WINDOW/EXPLORER/MASTER/NEWVIEWS/SYSTEM/TRANSACTION" [$_postings_explorer_window odb_path]]!=0} { ::qw::throw [::sargs \ .text "Could not find transactions explorer in journal desktop." \ .help_id 271820050404143220 \ ]; } ::set _postings_table_window [$_postings_explorer_window tree]; chain $_postings_table_window; } constructor {args} { ::eval ::qw::print::windows::table::constructor $args; } { } public method init {} { chain; ::return $this; } public method init_next_sheet {} { ::return $this; } destructor { } #qw_include .class ::qw::print::windows::table::postings .method {public method doit {}} public method doit {} { ::switch -- $destination { "file" { ::if {$filename eq ""} { ::qw::throw "-destination is \"file\", but -filename has not been set."; } } "pdf" { ::if {$filename eq ""} { ::qw::throw "-destination is \"pdf\", but -filename has not been set."; } ::sargs::var::set settings ".account_separator" "page"; ;#// options: none, page, sheet } } ::if {$window eq ""} { ::qw::throw "-window has not been configured."; } ::set window $_postings_table_window; ::set ColumnTitleSettings { .font { .size "" .weight bold .family "" .slant roman .underline 0 .overstrike 0 } .border { .position "bottom" .style "single" } }; ::set PageSetupStructure [page_setup]; ::sargs::var::set PageSetupStructure ".column_titles" $ColumnTitleSettings; ::sargs::var::set PageSetupStructure ".orientation" [::sargs::get $settings ".orientation"]; ::sargs::var::set PageSetupStructure ".fit_to_pages_wide" [::sargs::get $settings ".fit_to_pages_wide"]; ::sargs::var::set PageSetupStructure ".scaling" [::sargs::get $settings ".scaling"]; ::set CompanyName [[[$_application_database "/OBJECT/NEWVIEWS/ACCOUNT"] ".address.company"] odb_get]; ::if {$CompanyName ne ""} { ::sargs::var::set PageSetupStructure ".page_footer.left" "&L$CompanyName"; } else { ::set Directory [::file nativename [$_application_database cpp_directory]]; ::sargs::var::set PageSetupStructure ".page_footer.left" "&L$Directory"; } ::sargs::var::set PageSetupStructure ".page_footer.center" "&C&D &T"; ::sargs::var::set PageSetupStructure ".page_footer.right" "&R&P of &N"; page_setup $PageSetupStructure; postings_table_initialize; init; ::set Workbook [workbook_current]; ::if {$Workbook eq ""} { ::set Workbook [workbook_new]; } workbook_select $Workbook; ::if {$destination eq "file"} { ::set filename [::file nativename $filename]; ::set State [$_excel display_alerts]; $_excel display_alerts 0; $_workbook name_Set $filename; $_excel display_alerts $State; } ::set ProgressLimit [::llength $account_list]; ::set ProgressMinimum 1; ::set Progress ""; ::if {$ProgressLimit>=$ProgressMinimum} { ::set Progress [::itcl::local ::QW::PROGRESS::OPERATION #auto \ .database_id [$_application_database cpp_id] \ .file [$_application_database cpp_database_path] \ .user [$_application_database cpp_user_name] \ .limit $ProgressLimit \ .operation "Printing Ledgers/Transactions" \ .status "[$_application_database cpp_database_path] printing ledgers/transactions." \ ]; } ::set ListIndex 0; ::foreach Account $account_list { ::set S_Args [::sargs \ .account $Account \ .list_index $ListIndex \ ]; print_account_start $S_Args; print_account_titles $S_Args; print_account_ledger $S_Args; print_account_end $S_Args; ::incr ListIndex; ::if {$Progress ne ""} { $Progress increment; } } ::switch -- $destination { "display" { } "file" { ::set filename [::file nativename $filename]; ::set State [$_excel display_alerts]; $_excel display_alerts 0; $_workbook name_Set $filename; $_excel display_alerts $State; } "printer" { ::if {$print_when eq "now"} { ::if {$printer eq ""} { ::set printer [$::nv2::print::printers default_Get]; } printer_Set $printer; print; } } "pdf" { ::set FileName [::file rootname $filename]; ::set FileName "$FileName.pdf"; ::set Result [[sheet_current] create_pdf_file [::sargs ".filename" $FileName]]; } } } public method doit_XXX {} { ::switch -- $destination { "file" { ::if {$filename eq ""} { ::qw::throw "-destination is \"file\", but -filename has not been set."; } } "pdf" { ::if {$filename eq ""} { ::qw::throw "-destination is \"pdf\", but -filename has not been set."; } ::sargs::var::set settings ".account_separator" "page"; ;#// options: none, page, sheet } } ::if {$window eq ""} { ::qw::throw "-window has not been configured."; } ::set window $_postings_table_window; ::set ColumnTitleSettings { .font { .size "" .weight bold .family "" .slant roman .underline 0 .overstrike 0 } .border { .position "bottom" .style "single" } }; ::set PageSetupStructure [page_setup]; ::sargs::var::set PageSetupStructure ".column_titles" $ColumnTitleSettings; ::sargs::var::set PageSetupStructure ".orientation" [::sargs::get $settings ".orientation"]; ::sargs::var::set PageSetupStructure ".fit_to_pages_wide" [::sargs::get $settings ".fit_to_pages_wide"]; ::sargs::var::set PageSetupStructure ".scaling" [::sargs::get $settings ".scaling"]; ::set CompanyName [[[$_application_database "/OBJECT/NEWVIEWS/ACCOUNT"] ".address.company"] odb_get]; ::if {$CompanyName ne ""} { ::sargs::var::set PageSetupStructure ".page_footer.left" "&L$CompanyName"; } else { ::set Directory [::file nativename [$_application_database cpp_directory]]; ::sargs::var::set PageSetupStructure ".page_footer.left" "&L$Directory"; } ::sargs::var::set PageSetupStructure ".page_footer.center" "&C&D &T"; ::sargs::var::set PageSetupStructure ".page_footer.right" "&R&P of &N"; page_setup $PageSetupStructure; postings_table_initialize; init; ::set Workbook [workbook_current]; ::if {$Workbook eq ""} { ::set Workbook [workbook_new]; } workbook_select $Workbook; ::if {$destination eq "file"} { ::set filename [::file nativename $filename]; ::set State [$_excel display_alerts]; $_excel display_alerts 0; $_workbook name_Set $filename; $_excel display_alerts $State; } ::set ProgressLimit [::llength $account_list]; ::set ProgressMinimum 1; ::set Progress ""; ::if {$ProgressLimit>=$ProgressMinimum} { ::set Progress [::itcl::local ::QW::PROGRESS::OPERATION #auto \ .database_id [$_application_database cpp_id] \ .file [$_application_database cpp_database_path] \ .user [$_application_database cpp_user_name] \ .limit $ProgressLimit \ .operation "Printing Transactions" \ .status "[$_application_database cpp_database_path] printing journal transactions." \ ]; } ::set ListIndex 0; ::foreach Account $account_list { ::set S_Args [::sargs \ .account $Account \ .list_index $ListIndex \ ]; print_account_start $S_Args; print_account_titles $S_Args; print_account_ledger $S_Args; print_account_end $S_Args; ::incr ListIndex; ::if {$Progress ne ""} { $Progress increment; } } ::switch -- $destination { "display" { } "file" { ::set filename [::file nativename $filename]; ::set State [$_excel display_alerts]; $_excel display_alerts 0; $_workbook name_Set $filename; $_excel display_alerts $State; } "printer" { ::if {$print_when eq "now"} { ::if {$printer eq ""} { ::set printer [$::nv2::print::printers default_Get]; } printer_Set $printer; print; } } "pdf" { ::set FileName [::file rootname $filename]; ::set FileName "$FileName.pdf"; ::set Result [[sheet_current] create_pdf_file [::sargs ".filename" $FileName]]; } } } #qw_include .class ::qw::print::windows::table::postings .method {public method done {}} public method done {} { ::set Result ""; ::switch -- $destination { "file" { ::switch -- [::string tolower [::file extension $filename]] { ".pdf" { ::set Result [[sheet_current] create_pdf_file [::sargs ".filename" $filename]]; } ".xls" - ".xlsx" - ".xlt" - ".xltx" - default { ::set filename [::file nativename $filename]; ::set State [$_excel display_alerts]; $_excel display_alerts 0; $_workbook name_Set $filename; $_excel display_alerts $State; file_save; file_close; ::set Result $filename; } } } "printer" { ::if {$print_when eq "now"} { ::if {$printer eq ""} { ::set printer [$::nv2::print::printers default_Get]; } printer_Set $printer; print; file_save; file_close; } } "display" { hide_extra_sheets; mark_file_saved; print_show; } "preview" { hide_extra_sheets; mark_file_saved; print_preview; } } [::qw::get_com_applications] destroy $_excel; ::set _excel ""; ::set _sheet ""; ::unset -nocomplain progress_window; ::set progress_window ""; ::set _state "inactive"; ::return $Result; } public method done_XXX {} { ::set Result ""; ::switch -- $destination { "file" { ::switch -- [::string tolower [::file extension $filename]] { ".pdf" { ::set Result [[sheet_current] create_pdf_file [::sargs ".filename" $filename]]; } ".xls" - ".xlsx" - ".xlt" - ".xltx" - default { ::set filename [::file nativename $filename]; ::set State [$_excel display_alerts]; $_excel display_alerts 0; $_workbook name_Set $filename; $_excel display_alerts $State; file_save; file_close; ::set Result $filename; } } } "printer" { ::if {$print_when eq "now"} { ::if {$printer eq ""} { ::set printer [$::nv2::print::printers default_Get]; } printer_Set $printer; print; file_save; file_close; } } "display" { hide_extra_sheets; mark_file_saved; print_show; } "preview" { hide_extra_sheets; mark_file_saved; print_preview; } } [::qw::get_com_applications] destroy $_excel; ::set _excel ""; ::set _sheet ""; ::unset -nocomplain progress_window; ::set progress_window ""; ::set _state "inactive"; ::return $Result; } #qw_include .class ::qw::print::windows::table::postings .method {public method print_account_start {s_args}} public method print_account_start {s_args} { ::set ListIndex [::sargs::get $s_args ".list_index"]; ::set Account [::sargs::get $s_args ".account"]; ::if {$ListIndex==0} { ::set Sheet [sheet_new]; sheet_select $Sheet; sheet_initialize; sheet_name [[$Account ".name"] odb_get]; ::lappend _sheets_to_print $Sheet; ::return; } ::switch -- [::sargs::get $settings .account_separator] { "page" { page_break_insert; } "sheet" { ::set Sheet [sheet_new]; sheet_select $Sheet; sheet_initialize; sheet_name [[$Account ".name"] odb_get]; ::lappend _sheets_to_print $Sheet; } "none" - default {} } } public method print_account_start_XXX {s_args} { ::set ListIndex [::sargs::get $s_args ".list_index"]; ::set Account [::sargs::get $s_args ".account"]; ::if {$ListIndex==0} { ::set Sheet [sheet_new]; sheet_select $Sheet; sheet_initialize; sheet_name [[$Account ".name"] odb_get]; ::lappend _sheets_to_print $Sheet; ::return; } ::switch -- [::sargs::get $settings .account_separator] { "page" { page_break_insert; } "sheet" { ::set Sheet [sheet_new]; sheet_select $Sheet; sheet_initialize; sheet_name [[$Account ".name"] odb_get]; ::lappend _sheets_to_print $Sheet; } "none" - default {} } } #qw_include .class ::qw::print::windows::table::postings .method {public method print_account_end {s_args}} public method print_account_end {s_args} { ::switch -- [::sargs::get $settings .account_separator] { "page" {} "sheet" { sheet_finalize; } "none" - default { print_blank_rows 1; } } } public method print_account_end_XXX {s_args} { ::switch -- [::sargs::get $settings .account_separator] { "page" {} "sheet" { sheet_finalize; } "none" - default { print_blank_rows 1; } } } public method print_account_titles {s_args} { ::set Account [::sargs::get $s_args ".account"]; ::set AccountPath [::QW::GUI::NEWVIEWS::odb_path_help_format [::sargs .object $Account .format short_lower_case_folder]]; ::set AccountName [[$Account ".name"] odb_get]; ::set AccountDescription [[$Account ".description"] odb_get]; ::set RangeBegin [::sargs::get $settings ".range_begin"] ::set RangeEnd [::sargs::get $settings ".range_end"] ::set Format $::qw::date::formats(month dd, yyyy); ::if {$RangeBegin ne ""} {::set RangeBegin [::qw::date::format $RangeBegin $Format];} ::if {$RangeEnd ne ""} {::set RangeEnd [::qw::date::format $RangeEnd $Format];} ::set View [::sargs::get $settings ".view"]; ::set Tag [::sargs::get $settings ".tag"]; ::set AccountTitle [::sargs::get $settings .account_title_1]; ::for {::set j 2;} {$j<=4} {::incr j;} { ::if {[::sargs::get $settings .account_title_$j] ne ""} { ::append AccountTitle \n[::sargs::get $settings .account_title_$j]; } } ::set Today [::clock format [::clock seconds] -format "%Y%m%d"]; ::set User [[$Account odb_database] cpp_user_get]; ::if {$User ne ""} { ::set Format [[$User .options.date.format] odb_get]; ::if {$Format ne ""} { ::set Today [::qw::date::format $Today $::qw::date::formats($Format)]; } } ::set AccountTitle [::string map [::list \ %_today $Today \ %_path $AccountPath \ %_name $AccountName \ %_description $AccountDescription \ %_begin $RangeBegin \ %_end $RangeEnd \ %_tag $Tag \ ] $AccountTitle]; print_titles [::sargs ".title_lines" $AccountTitle]; } #qw_include .class ::qw::print::windows::table::postings .method {public method print_titles {s_args}} public method print_titles {s_args} { ::set TitleLines [::sargs::get $s_args ".title_lines"]; ::set TitleLines [::string map [::list {\n} \n] $TitleLines]; ::set TitleLineCount [::llength [::split $TitleLines \n]]; page_setup \ .document_title.items $TitleLineCount \ .title/rows.start $TitleLineCount \ .title/rows.end $TitleLineCount \ ; ::set FontSize 16; ::set Underline 1; ::for {::set i 0;::set j 1;} {$i<$TitleLineCount} {::incr i;::incr j;} { ::set Title [::string trim [::lindex [::split $TitleLines \n] $i]]; ::set Alignment "left"; ::if {[::string index $Title 0] eq "|"} { ::set Title [::string range $Title 1 end]; ::set Alignment "center"; ::if {[::string index $Title 0] eq "|"} { ::set Title [::string range $Title 1 end]; ::set Alignment "right"; } } page_setup .document_title/$j.text $Title; page_setup .document_title/$j.alignment $Alignment; page_setup .document_title/$j.font.size $FontSize; page_setup \ .document_title/$j.font.weight bold \ .document_title/$j.font.family Arial \ .document_title/$j.font.slant roman \ .document_title/$j.font.underline $Underline \ .document_title/$j.font.overstrike 0 \ ; ::set Underline 0; ::if {$FontSize>10 && $Title ne ""} {::incr FontSize -2;} } pagesetup_document_title_set; column_titles_set "dummy_s_args"; } public method print_titles_XXX {s_args} { ::set TitleLines [::sargs::get $s_args ".title_lines"]; ::set TitleLines [::string map [::list {\n} \n] $TitleLines]; ::set TitleLineCount [::llength [::split $TitleLines \n]]; page_setup \ .document_title.items $TitleLineCount \ .title/rows.start $TitleLineCount \ .title/rows.end $TitleLineCount \ ; ::set FontSize 16; ::set Underline 1; ::for {::set i 0;::set j 1;} {$i<$TitleLineCount} {::incr i;::incr j;} { ::set Title [::string trim [::lindex [::split $TitleLines \n] $i]]; ::set Alignment "left"; ::if {[::string index $Title 0] eq "|"} { ::set Title [::string range $Title 1 end]; ::set Alignment "center"; ::if {[::string index $Title 0] eq "|"} { ::set Title [::string range $Title 1 end]; ::set Alignment "right"; } } page_setup .document_title/$j.text $Title; page_setup .document_title/$j.alignment $Alignment; page_setup .document_title/$j.font.size $FontSize; page_setup \ .document_title/$j.font.weight bold \ .document_title/$j.font.family Arial \ .document_title/$j.font.slant roman \ .document_title/$j.font.underline $Underline \ .document_title/$j.font.overstrike 0 \ ; ::set Underline 0; ::if {$FontSize>10 && $Title ne ""} {::incr FontSize -2;} } pagesetup_document_title_set; column_titles_set "dummy_s_args"; } #qw_include .class ::qw::print::windows::table::postings .method {public method print_blank_rows {{Src "1"}}} public method print_blank_rows {{Src "1"}} { row_values $_empty_row_values; ::for {::set i 0;} {$i<$Src} {::incr i;} { print_row_values; } ::return $this; } public method print_blank_rows_XXX {{Src "1"}} { row_values $_empty_row_values; ::for {::set i 0;} {$i<$Src} {::incr i;} { print_row_values; } ::return $this; } public method print_account_ledger {s_args} { ::set Account [::sargs::get $s_args ".account"]; ::sargs::var::set _content_rectangle ".size.y" 0 ".position.y" $_sheet_row; postings_table_configure $Account; ::set _postings_data [load_postings_data $Account]; ::set Limit [::llength [::sargs::subs .structure $_postings_data]]; ::if {$Limit} { ::set RectangleFilled $_content_rectangle; ::sargs::var::set RectangleFilled ".position.y" $_sheet_row ".size.y" 0; ::sargs::var::set RectangleFilled ".size.y" $Limit; ::set S_Args [::sargs ".rectangle" $RectangleFilled]; content_font_set $S_Args; column_justifications_set $S_Args; column_formats_set $S_Args; print_rows $s_args; row_values_font_set $S_Args; ::sargs::var::set RectangleFilled ".size.y" [::expr {[::sargs::get $RectangleFilled ".size.y"]+[::sargs::get $RectangleFilled ".position.y"]}]; ::sargs::var::set RectangleFilled ".position.y" 0; $_range rectangle_Set $RectangleFilled; $_range autofit; } } #qw_include .class ::qw::print::windows::table::postings .method {public method row_values_font_set {s_args}} public method row_values_font_set {s_args} { ::set Rectangle [::sargs::get $s_args ".rectangle"] ::set Row [::sargs::get $Rectangle ".position.y"]; ::sargs::var::set Rectangle ".size.y" 1; ::sargs::var::set Rectangle ".size.x" [::llength $_column_titles]; ::sargs::var::set Rectangle ".position.x" $_sheet_start_column; ::set Subs [::sargs::subs .structure $_postings_data]; ::foreach Sub $Subs { ::set Font [::sargs::get $_postings_data "$Sub.font"]; ::if {$Font eq ""} { ::incr Row; ::continue; } ::set Command ""; ::foreach Path {size weight family slant underline overstrike} { ::set Attribute [::sargs::get $Font .$Path]; ::if {$Attribute ne ""} { ::lappend Command "-$Path";::lappend Command $Attribute; } } ::if {$Command ne ""} { ::sargs::var::set Rectangle ".position.y" $Row; ::set Command [::linsert $Command 0 "range_font_Set" $Rectangle]; ::eval $Command; } ::incr Row; } } public method row_values_font_set_XXX {s_args} { ::set Rectangle [::sargs::get $s_args ".rectangle"] ::set Row [::sargs::get $Rectangle ".position.y"]; ::sargs::var::set Rectangle ".size.y" 1; ::sargs::var::set Rectangle ".size.x" [::llength $_column_titles]; ::sargs::var::set Rectangle ".position.x" $_sheet_start_column; ::set Subs [::sargs::subs .structure $_postings_data]; ::foreach Sub $Subs { ::set Font [::sargs::get $_postings_data "$Sub.font"]; ::if {$Font eq ""} { ::incr Row; ::continue; } ::set Command ""; ::foreach Path {size weight family slant underline overstrike} { ::set Attribute [::sargs::get $Font .$Path]; ::if {$Attribute ne ""} { ::lappend Command "-$Path";::lappend Command $Attribute; } } ::if {$Command ne ""} { ::sargs::var::set Rectangle ".position.y" $Row; ::set Command [::linsert $Command 0 "range_font_Set" $Rectangle]; ::eval $Command; } ::incr Row; } } #qw_include .class ::qw::print::windows::table::postings .method {public method print_row_values {}} public method print_row_values {} { ::set Rectangle [::list .position [::list .x $_sheet_start_column .y $_sheet_row] .size [::list .x [::llength $_row_values] .y 1]]; range_value_Set $Rectangle [::join [row_values] \t]; ::incr _sheet_row; ::set Height [::sargs::get $_content_rectangle ".size.y"]; ::incr Height; ::sargs::var::set _content_rectangle ".size.y" $Height; ::return $Rectangle; } public method print_row_values_XXX {} { ::set Rectangle [::list .position [::list .x $_sheet_start_column .y $_sheet_row] .size [::list .x [::llength $_row_values] .y 1]]; range_value_Set $Rectangle [::join [row_values] \t]; ::incr _sheet_row; ::set Height [::sargs::get $_content_rectangle ".size.y"]; ::incr Height; ::sargs::var::set _content_rectangle ".size.y" $Height; ::return $Rectangle; } #qw_include .class ::qw::print::windows::table::postings .method {public method row_values {{Src "get"}}} public method row_values {{Src "get"}} { ::if {$Src eq "get"} {::return $_row_values;} ::set _row_values $Src; ::return $this; } public method row_values_XXX {{Src "get"}} { ::if {$Src eq "get"} {::return $_row_values;} ::set _row_values $Src; ::return $this; } #qw_include .class ::qw::print::windows::table::postings .method {public method print_rows {{s_args ""}}} public method print_rows {{s_args ""}} { ::set Account [::sargs::get $s_args .account]; ::set Account [::QW::GUI::NEWVIEWS::odb_path_help_format [::sargs .object $Account .format short_lower_case_folder]]; ::set Limit [::llength [::sargs::subs .structure $_postings_data]]; ::set Progress [::itcl::local ::QW::PROGRESS::OPERATION #auto \ .database_id [$_application_database cpp_id] \ .file [$_application_database cpp_directory] \ .user [[$_application_database "/OBJECT"] odb_user_name] \ .limit $Limit \ .operation "Printing $Account" \ .status "[$_application_database cpp_directory] $Account" \ ]; range_types_Set $_column_type_list; ::set Subs [::sargs::subs .structure $_postings_data]; ::foreach Sub $Subs { ::set _row_values ""; ::foreach Name $_column_names_user_selected { ::lappend _row_values [::sargs::get $_postings_data "$Sub.values$Name"]; } ::set Rectangle [print_row_values]; $Progress increment; } } public method print_rows_XXX {{s_args ""}} { ::set Account [::sargs::get $s_args .account]; ::set Limit [::llength [::sargs::subs .structure $_postings_data]]; ::set Progress [::itcl::local ::QW::PROGRESS::OPERATION #auto \ .database_id [$_application_database cpp_id] \ .file [$_application_database cpp_directory] \ .user [[$_application_database "/OBJECT"] odb_user_name] \ .limit $Limit \ .operation "Printing Account [[$Account .name] odb_get]" \ .status "[$_application_database cpp_directory] Account [[$Account .name] odb_get]" \ ]; range_types_Set $_column_type_list; ::set Subs [::sargs::subs .structure $_postings_data]; ::foreach Sub $Subs { ::set _row_values ""; ::foreach Name $_column_names_user_selected { ::lappend _row_values [::sargs::get $_postings_data "$Sub.values$Name"]; } ::set Rectangle [print_row_values]; $Progress increment; } } public method load_postings_data {Account} { ::set ::qw::control(clock_clicks_total) 0; ::set ::qw::control(clock_clicks) 0; ::set TotalClicks [::clock clicks -milliseconds]; ::set Rlist ""; ::switch -glob -- [$booted_by odb_path] { "/OBJECT/SYSTEM/WINDOW/SCROLLED/TABLE/NEWVIEWS/JOURNAL/*" { ::set StartLine 1; ;#// NOTICE - KLUDGE ALERT - should get the actual number of title rows ::set EndLine [$_postings_table_window observer_rows]; ::for {::set TableRow $StartLine} {$TableRow<=$EndLine} {::incr TableRow} { ::lappend Rlist [[$_postings_table_window observer_database] odb_seek_count [::expr $TableRow-1]]; } } "/OBJECT/SYSTEM/WINDOW/SCROLLED/TABLE/NEWVIEWS/SYSTEM/TRANSACTION/*" { ::set Rlist [$prompt_window reference_list]; } } ::set Items [::llength $Rlist]; ::set Progress [::itcl::local ::QW::PROGRESS::OPERATION #auto \ .database_id [$_application_database cpp_id] \ .file [$_application_database cpp_directory] \ .user [[$_application_database "/OBJECT"] odb_user_name] \ .limit $Items \ .operation "Loading" \ .status "Loading transactions from journal [[$Account .name] odb_get]" \ ]; ::set Sub 0; ::set Result ""; ::set ColumnNames $_column_names; ::set PrintDistributions 1; ::foreach Reference $Rlist { ::set DistributionItems 0; ::if {$PrintDistributions} { ::if {$Reference ne ""} { ::set Transaction [$Reference odb_master]; ::set DistributionItems [[$Transaction ".odb_deriveds"] odb_items]; } } ::set LineNumber [[$_postings_table_window observer_database] odb_total [::sargs .path .count .reference $Reference]]; ::set Correction -1; ::set TableRow [::expr {int([$_postings_table_window dataInterface_tableRow $LineNumber])+$Correction}]; ::set RowValues [[$_postings_table_window ".client"] dataInterface_cache_row [$_postings_table_window dataInterface_fileRow $TableRow] 0 foreground]; ::set Column 0; ::foreach ColumnName $ColumnNames { ::switch -glob -- $ColumnName { "/posting/*name" - "/posting/*help" - "/posting/*description" { ::set FileRow [$_postings_table_window dataInterface_fileRow $TableRow]; ::set MyAccount [[$_postings_table_window ".client"] dataInterfaceCell $FileRow $Reference $Reference "/account"]; ::set DetailAccount [[$_postings_table_window ".client"] dataInterfaceCell $FileRow $Reference $Reference "/posting/charge/account"]; ::if {$DetailAccount eq $MyAccount} { ::sargs::var::set Result "/$Sub.values$ColumnName" ""; } else { ::sargs::var::set Result "/$Sub.values$ColumnName" [::lindex $RowValues $Column]; } } "/posting/*rate" { ::if {$DistributionItems} { ::sargs::var::set Result "/$Sub.values$ColumnName" ""; } else { ::sargs::var::set Result "/$Sub.values$ColumnName" [::lindex $RowValues $Column]; } } "/account*" { ::sargs::var::set Result "/$Sub.values$ColumnName" [::lindex $RowValues $Column]; } default { ::sargs::var::set Result "/$Sub.values$ColumnName" [::lindex $RowValues $Column]; } } ::incr Column; } ::if {$DistributionItems} { ::set Default [::sargs::get [page_setup] ".content.font"]; ::sargs::var::set Default ".weight" "bold"; ::sargs::var::set Result "/$Sub.font" $Default; ::sargs::var::set Result "/$Sub.header" "yes"; } ::sargs::var::set Result "/$Sub.reference" $Reference; ::set HeaderSub $Sub; ::set HeaderValues $RowValues; ::incr Sub ::if {$DistributionItems} { ::sargs::var::set Sargs .context_account $Account; ::sargs::var::set Sargs .reference $Reference; ::sargs::var::set Sargs .settings [::sargs::set $settings .column_names $_column_names]; ::sargs::var::set Sargs .postings_table_initialize_odb_level $_postings_table_initialize_odb_level; ::set Dlist [$_postings_table_window load_postings_data_odb_level_distribution_values $Sargs]; ::foreach RowValues $Dlist { ::set Column 0; ::foreach ColumnName $ColumnNames { ::set IsTotalled [::sargs::exists $_amount_and_quantity_totals $ColumnName]; ::if {[::string first "/running_balance" $ColumnName]==0 \ ||[::lindex $RowValues $Column] eq [::lindex $HeaderValues $Column] \ &&![::string match "/formula_posting*_quantity" $ColumnName] \ &&![::string match "/formula_posting*_amount" $ColumnName] \ } { ::sargs::var::set Result "/$Sub.values$ColumnName" ""; } else { ::sargs::var::set Result "/$Sub.values$ColumnName" [::lindex $RowValues $Column]; } ::incr Column; } ::if {[::sargs::get $Result "/$Sub.values/posting/charge/account/odb_address"] eq ""} { ::sargs::var::set Result "/$Sub.header" "yes"; ;#// or .text_line (whatever) } ::if {[::sargs::get $Result "/$Sub.values/posting/charge/account/odb_address"] eq [::sargs::get $Result "/$Sub.values/cross_account/odb_address"]} { ::sargs::var::set Result "/$Sub.header" "yes"; ;#// or .boomerang (whatever) } ::sargs::var::set Result "/$Sub.type" "distribution"; ::sargs::var::set Result "/$Sub.header_sub" $HeaderSub; ::incr Sub; } } ;#// end of ::if {$DistributionItems} $Progress increment; } ::return $Result; } public method postings_table_configure {Account} { $_postings_master_desktop_window observer_database $Account; ::if {$::qw::control(signal_pick_kids_after_time_delay)} { [$_postings_master_desktop_window ".pick.kids"] signalWrite; } $_postings_master_desktop_window odb_commit; ::set _print_range "all"; ::switch -glob -- [$booted_by odb_path] { "/OBJECT/SYSTEM/WINDOW/SCROLLED/TABLE/NEWVIEWS/JOURNAL/*" { ::set RangeBeginDate [::qw::date::extend_begin [::string range [::sargs::get $settings ".range_begin"] 0 7]]; ::set RangeEndDate [::qw::date::extend_end [::string range [::sargs::get $settings ".range_end"] 0 7]]; ::set Tag [::string trim [::sargs::get $settings ".tag"]]; ::if {$Tag eq ""} { ::set Tag "financial"; } [$_postings_table_window ".observer_range_begin"] odb_set ".tag $Tag .date $RangeBeginDate"; [$_postings_table_window ".observer_range_end"] odb_set ".tag $Tag .date $RangeEndDate"; } "/OBJECT/SYSTEM/WINDOW/SCROLLED/TABLE/NEWVIEWS/SYSTEM/TRANSACTION/*" { [$_postings_table_window ".observer_range_begin"] odb_set [[$booted_by .observer_range_begin] odb_get]; [$_postings_table_window ".observer_range_end"] odb_set [[$booted_by .observer_range_begin] odb_get]; } } [$_postings_table_window ".column_names"] odb_set $_column_names; $_postings_master_desktop_window odb_commit; } public method XXX_postings_table_initialize {} { ::set Cdefs ""; ::set Cnames [::sargs::get $settings ".column_names"]; ::set ScriptGet { ::return [::QW::NEWVIEWS::transaction_posting_field_value_get [::sargs .transaction %_object .posting_path $Ppath .field_name $Fname .include_no_account_amounts 1]]; } ::foreach Cname $Cnames { ::switch -glob -- $Cname { "/posting*" { ::switch -glob -- $Cname { "*/name" {::set FnameData {.aname {\nAccount} none left 20};} "*/odb_path_help" {::set FnameData {.account {\nAccount} none left 20};} "*/description" {::set FnameData {.adesc {\nAccount} none left 20};} "*/quantity" {::set FnameData {.quantity {\nQuantity} dollar_minus_parentheses right 10};} "*/rate" {::set FnameData {.rate {\nRate} dollar_minus_parentheses right 10};} "*/amount" {::set FnameData {.amount {\nAmount} dollar_minus_parentheses right 10};} } ::set Ppath [::string range $Cname 0 [::expr {[::string last / $Cname]-1}]]; ::if {[::string first "/account" $Ppath]>0} { ::set Ppath [::string range $Ppath 0 [::expr {[::string last / $Ppath]-1}]]; } ::set Ppath ".[::string range $Ppath 1 end]"; ::set Ppaths { .posting/debit Dr .posting/debit/charge {Dr Charge} .posting/debit/tax1 {Dr Tax1} .posting/debit/tax2 {Dr Tax2} .posting/debit/customer {Dr Customer} .posting/debit/cgs {Dr CGS} .posting/credit Cr .posting/credit/inventory {Cr Inventory} .posting/credit/charge {Cr Charge} .posting/credit/tax1 {Cr Tax1} .posting/credit/tax2 {Cr Tax2} } ::set Ptitle [::lindex $Ppaths [::expr {[::lsearch $Ppaths $Ppath]+1}]]; ::foreach {Fname Ftitle Format Justify Width} $FnameData { ::set Cname "/formula[::string map [::list / _] $Cname]"; ::sargs::var::set Cdefs \ $Cname.script/title "$Ptitle $Ftitle" \ $Cname.script/command/get [::subst -nocommands $ScriptGet] \ $Cname.script/command/change_before {} \ $Cname.script/command/set {} \ $Cname.format $Format \ $Cname.justify $Justify \ $Cname.width $Width \ ; } } } ::lappend CnamesUsed $Cname; } ::sargs::var::set Cdefs /journal/name.script/title "Journal"; ::sargs::var::set Cdefs /journal/odb_path_help.script/title "Journal"; ::sargs::var::set Cdefs /journal/odb_path_help.format short_lower_case_folder; [$_postings_table_window ".column_definitions"] odb_set [::sargs::+= [[$_postings_table_window ".column_definitions"] qw_get] $Cdefs]; [$_postings_table_window ".column_names"] odb_set $CnamesUsed; $_postings_table_window odb_commit; ::set _column_titles [[$_postings_table_window ".client"] dataInterfaceRowTitle]; ::set _column_names [[$_postings_table_window ".column_names"] odb_get]; ::set _column_names_user_selected $_column_names; ::set _column_definition_tree [$_postings_table_window columnDefinitionTree]; ::set _empty_row_values ""; ::foreach Name $_column_names { ::lappend _empty_row_values ""; } ::set _postings_table_initialize_odb_level $_column_definition_tree; ::set _distribution_table_column_setup $_column_definition_tree; ::return; } public method postings_table_initialize {} { ::return [XXX_postings_table_initialize]; ::set IndexPath [::sargs::get $settings .index_path]; ::set IndexPath ".transactions.index/date"; ::set IndexPath ".index/date"; ::set ColumnNames [::sargs::get $settings ".column_names"]; ::set ColumnDefinitions [[$_postings_table_window ".column_definitions"] odb_get]; ::set ColumnSetup ""; ::if {[::lsearch -exact $ColumnNames "/account/report/name"]>=0} { ::sargs::var::set ColumnSetup "/account/report/name.script/title" "Report"; } ::if {[::lsearch -exact $ColumnNames "/account/report/description"]>=0} { ::sargs::var::set ColumnSetup "/account/report/description.script/title" "Report Description"; } ::sargs::var::set ColumnSetup "/running_balance_quantity.script/title" "Qty Balance"; ::sargs::var::set ColumnSetup "/running_balance_amount.script/title" "Amt Balance"; ::if {$::qw::control(comprehensive_postings_table)} {} ::set Database [$_postings_table_window odb_database]; ::append Postings "/posting/debit/charge /charge"; ;#// for overloaded version we just want any posting column profile, which will be patched ::append Postings " /posting/debit/tax1 /tax1"; ::append Postings " /posting/debit/tax2 /tax2"; ::append Postings " /posting/debit/cgs /cgs"; ::append Postings " /posting/credit/inventory /inventory"; ::set RefDefs [[$Database "/OBJECT/SYSTEM/WINDOW/SCROLLED/TABLE/NEWVIEWS/POSTINGSUBS"] columnDefinitionTree]; ::sargs::var::set NewDefs "/posting" $RefDefs; ::sargs::var::set NewDefs "/posting/debit" $RefDefs; ::sargs::var::set NewDefs "/posting/credit" $RefDefs; ::foreach {Path Sub} $Postings { ::sargs::var::set NewDefs $Path $RefDefs; } ::foreach Class "/TRANSACTION" { ::sargs::var::set PostingDef "/posting" [::sargs::get [[$Database "/OBJECT/SYSTEM/WINDOW/SCROLLED/TABLE/NEWVIEWS/SYSTEM$Class.column_definitions"] qw_get] "/posting"]; ::sargs::var::+= NewDefs $PostingDef; } ::set Postings ""; ::append Postings "/posting/charge /posting/debit/charge /charge"; ::foreach {Path BorrowPath Sub} $Postings { ::sargs::var::set NewDefs "$Path" [::sargs::get $NewDefs $BorrowPath]; ::sargs::var::set _distribution_table_column_setup "$Path" [::sargs::get $NewDefs $BorrowPath]; ::set Script { ::switch -glob -- [[%_object odb_master] odb_path] { "/OBJECT/NEWVIEWS/SYSTEM/TRANSACTION/SALES*" {::return [%_object "/credit%_sub"];} "/OBJECT/NEWVIEWS/SYSTEM/TRANSACTION/PURCHASE*" {::return [%_object "/debit%_sub"];} "/OBJECT/NEWVIEWS/SYSTEM/TRANSACTION/BANK/DEPOSIT*" {::return [%_object "/credit"];} "/OBJECT/NEWVIEWS/SYSTEM/TRANSACTION/BANK/PAYMENT*" {::return [%_object "/debit"];} "/OBJECT/NEWVIEWS/SYSTEM/TRANSACTION/GENERAL*" { ::set Account [[[%_object odb_master] ".posting/debit.account"] qw_get]; ::if {$Account ne ""} { ::return [%_object "/debit"]; } ::return [%_object "/credit"]; } "/OBJECT/NEWVIEWS/SYSTEM/TRANSACTION/PAYROLL*" {::return [%_object "/debit"];} } ::return ""; } ::set Script [::string map "%_sub $Sub" $Script]; ::sargs::var::set NewDefs "$Path.script/command/get" $Script; ::sargs::var::set _distribution_table_column_setup "$Path.script/command/get" $Script; ::if {[::sargs::boolean_get $settings .print_distributions_flows_analysis]} { ::foreach Value "quantity amount" { ::sargs::var::set NewDefs "$Path/amount.script/command/get" [::sargs::get $ColumnDefinitions "/amount.script/command/get"]; ::set Script { ::set Amount [[%_object ".%_value"] odb_get]; ::set Observer [[%_this odb_master] observer_database]; ::if {$Observer ne ""} { ::if {[[$Observer odb_master] normal_balance_get] eq "credit"} {::qw::number::var::negative Amount;} } ::return [::qw::number::format $Amount $::qw::number::formats(%_format)]; } ::set Script [::string map "%_value $Value" $Script]; ::sargs::var::set NewDefs "$Path/$Value.script/command/get" $Script; ::sargs::var::set _distribution_table_column_setup "$Path/$Value.script/command/get" $Script; } } } ::set Postings ""; ::append Postings " /posting/tax1 /posting/debit/tax1 /tax1"; ::append Postings " /posting/tax2 /posting/debit/tax2 /tax2"; ::foreach {Path BorrowPath Sub} $Postings { ::sargs::var::set NewDefs "$Path" [::sargs::get $NewDefs $BorrowPath]; ::sargs::var::set _distribution_table_column_setup "$Path" [::sargs::get $NewDefs $BorrowPath]; ::set Script { ::switch -glob -- [[%_object odb_master] odb_path] { "/OBJECT/NEWVIEWS/SYSTEM/TRANSACTION/SALES*" {::return [%_object "/credit%_sub"];} "/OBJECT/NEWVIEWS/SYSTEM/TRANSACTION/PURCHASE*" {::return [%_object "/debit%_sub"];} "/OBJECT/NEWVIEWS/SYSTEM/TRANSACTION/BANK/PAYMENT*" {::return "";} "/OBJECT/NEWVIEWS/SYSTEM/TRANSACTION/BANK/DEPOSIT*" {::return "";} "/OBJECT/NEWVIEWS/SYSTEM/TRANSACTION/GENERAL*" {::return "";} "/OBJECT/NEWVIEWS/SYSTEM/TRANSACTION/PAYROLL*" {::return "";} } ::return ""; } ::set Script [::string map "%_sub $Sub" $Script]; ::sargs::var::set NewDefs "$Path.script/command/get" $Script; ::sargs::var::set _distribution_table_column_setup "$Path.script/command/get" $Script; ::if {[::sargs::boolean_get $settings .print_distributions_flows_analysis]} { ::foreach Value "amount" { ::sargs::var::set NewDefs "$Path/amount.script/command/get" [::sargs::get $ColumnDefinitions "/amount.script/command/get"]; ::set Script { ::set Amount [[%_object ".%_value"] odb_get]; ::set Observer [[%_this odb_master] observer_database]; ::if {$Observer ne ""} { ::if {[[$Observer odb_master] normal_balance_get] eq "credit"} {::qw::number::var::negative Amount;} } ::return [::qw::number::format $Amount $::qw::number::formats(%_format)]; } ::set Script [::string map "%_value $Value" $Script]; ::sargs::var::set NewDefs "$Path/$Value.script/command/get" $Script; ::sargs::var::set _distribution_table_column_setup "$Path/$Value.script/command/get" $Script; } } } ::set Postings ""; ::append Postings " /posting/cgs /posting/debit/cgs /cgs"; ::foreach {Path BorrowPath Sub} $Postings { ::sargs::var::set NewDefs "$Path" [::sargs::get $NewDefs $BorrowPath]; ::sargs::var::set _distribution_table_column_setup "$Path" [::sargs::get $NewDefs $BorrowPath]; ::set Script { ::switch -glob -- [[%_object odb_master] odb_path] { "/OBJECT/NEWVIEWS/SYSTEM/TRANSACTION/SALES*" {::return [%_object "/debit%_sub"];} "/OBJECT/NEWVIEWS/SYSTEM/TRANSACTION/PURCHASE*" - "/OBJECT/NEWVIEWS/SYSTEM/TRANSACTION/BANK/PAYMENT*" - "/OBJECT/NEWVIEWS/SYSTEM/TRANSACTION/BANK/DEPOSIT*" - "/OBJECT/NEWVIEWS/SYSTEM/TRANSACTION/GENERAL*" - "/OBJECT/NEWVIEWS/SYSTEM/TRANSACTION/PAYROLL*" {::return "";} } ::return ""; } ::set Script [::string map "%_sub $Sub" $Script]; ::sargs::var::set NewDefs "$Path.script/command/get" $Script; ::sargs::var::set _distribution_table_column_setup "$Path.script/command/get" $Script; ::if {[::sargs::boolean_get $settings .print_distributions_flows_analysis]} { ::foreach Value "quantity amount" { ::sargs::var::set NewDefs "$Path/amount.script/command/get" [::sargs::get $ColumnDefinitions "/amount.script/command/get"]; ::set Script { ::set Amount [[%_object ".%_value"] odb_get]; ::set Observer [[%_this odb_master] observer_database]; ::if {$Observer ne ""} { ::if {[[$Observer odb_master] normal_balance_get] eq "debit"} {::qw::number::var::negative Amount;} ;#// AR works, Current Assets doesn't } ::return [::qw::number::format $Amount $::qw::number::formats(%_format)]; } ::set Script [::string map "%_value $Value" $Script]; ::sargs::var::set NewDefs "$Path/$Value.script/command/get" $Script; ::sargs::var::set _distribution_table_column_setup "$Path/$Value.script/command/get" $Script; } } } ::set Postings ""; ::append Postings " /posting/inventory /posting/credit/inventory /inventory"; ::foreach {Path BorrowPath Sub} $Postings { ::sargs::var::set NewDefs "$Path" [::sargs::get $NewDefs $BorrowPath]; ::sargs::var::set _distribution_table_column_setup "$Path" [::sargs::get $NewDefs $BorrowPath]; ::set Script { ::switch -glob -- [[%_object odb_master] odb_path] { "/OBJECT/NEWVIEWS/SYSTEM/TRANSACTION/SALES*" {::return [%_object "/credit%_sub"];} "/OBJECT/NEWVIEWS/SYSTEM/TRANSACTION/PURCHASE*" - "/OBJECT/NEWVIEWS/SYSTEM/TRANSACTION/BANK/PAYMENT*" - "/OBJECT/NEWVIEWS/SYSTEM/TRANSACTION/BANK/DEPOSIT*" - "/OBJECT/NEWVIEWS/SYSTEM/TRANSACTION/GENERAL*" - "/OBJECT/NEWVIEWS/SYSTEM/TRANSACTION/PAYROLL*" {::return "";} } ::return ""; } ::set Script [::string map "%_sub $Sub" $Script]; ::sargs::var::set NewDefs "$Path.script/command/get" $Script; ::sargs::var::set _distribution_table_column_setup "$Path.script/command/get" $Script; ::if {[::sargs::boolean_get $settings .print_distributions_flows_analysis]} { ::foreach Value "quantity amount" { ::sargs::var::set NewDefs "$Path/amount.script/command/get" [::sargs::get $ColumnDefinitions "/amount.script/command/get"]; ::set Script { ::set Amount [[%_object ".%_value"] odb_get]; ::set Observer [[%_this odb_master] observer_database]; ::if {$Observer ne ""} { ::if {[[$Observer odb_master] normal_balance_get] eq "debit"} {::qw::number::var::negative Amount;} } ::return [::qw::number::format $Amount $::qw::number::formats(%_format)]; } ::set Script [::string map "%_value $Value" $Script]; ::sargs::var::set NewDefs "$Path/$Value.script/command/get" $Script; ::sargs::var::set _distribution_table_column_setup "$Path/$Value.script/command/get" $Script; } } } ::sargs::var::set _distribution_table_column_setup \ "/posting/charge/account/odb_path_help.format" "short_lower_case_folder" \ ; ::sargs::var::set _distribution_table_column_setup \ "/posting/tax1/account/odb_path_help.format" "short_lower_case_folder" \ "/posting/tax2/account/odb_path_help.format" "short_lower_case_folder" \ "/posting/cgs/account/odb_path_help.format" "short_lower_case_folder" \ "/posting/inventory/account/odb_path_help.format" "short_lower_case_folder" \ ; ::sargs::var::+= ColumnSetup $NewDefs; ::set _postings_table_column_setup ""; ::sargs::var::set _postings_table_column_setup \ "/account/odb_path_help.format" "short_lower_case_folder" \ "/journal/odb_path_help.format" "short_lower_case_folder" \ "/cross_account/odb_path_help.format" "short_lower_case_folder" \ "/account/report/odb_path_help.format" "short_lower_case_folder" \ "/posting/charge/quantity.script/title" "Detail Qty" \ "/posting/charge/rate.script/title" "Detail Rate" \ "/posting/charge/amount.script/title" "Detail Amt" \ "/posting/charge/account/name.script/title" "Detail\nAccount Name" \ "/posting/charge/account/description.script/title" "Detail Account Description" \ "/posting/charge/account/odb_path_help.script/title" "Detail\nAccount Path" \ "/posting/charge/account/odb_path_help.format" "short_lower_case_folder" \ ; ::sargs::var::set _postings_table_column_setup \ "/posting/tax1/account/odb_path_help.format" "short_lower_case_folder" \ "/posting/tax2/account/odb_path_help.format" "short_lower_case_folder" \ "/posting/cgs/account/odb_path_help.format" "short_lower_case_folder" \ "/posting/inventory/account/odb_path_help.format" "short_lower_case_folder" \ ; ::sargs::var::set _postings_table_column_setup \ "/posting/cgs/quantity.script/title" "CGS Qty" \ "/posting/cgs/rate.script/title" "CGS Rate" \ "/posting/cgs/amount.script/title" "CGS Amt" \ "/posting/cgs/account/name.script/title" "CGS\nAccount Name" \ "/posting/cgs/account/description.script/title" "CGS Account Description" \ "/posting/cgs/account/odb_path_help.script/title" "CGS\nAccount Path" \ ; ::sargs::var::set _postings_table_column_setup \ "/posting/inventory/quantity.script/title" "Inventory Qty" \ "/posting/inventory/rate.script/title" "Inventory Rate" \ "/posting/inventory/amount.script/title" "Inventory Amt" \ "/posting/inventory/account/name.script/title" "Inventory\nAccount Name" \ "/posting/inventory/account/description.script/title" "Inventory Account Description" \ "/posting/inventory/account/odb_path_help.script/title" "Inventory\nAccount Path" \ ; ::set Tax1TitleScript {[ ::set Journal [[$this odb_database application] "/OBJECT/NEWVIEWS/JOURNAL/SALES"]; ::set Title [[$Journal ".trade_tax/1.description"] odb_get]; ::if {$Title ne ""} {::return $Title;} ::set Journal [[$this odb_database application] "/OBJECT/NEWVIEWS/JOURNAL/PURCHASE"]; ::set Title [[$Journal ".trade_tax/1.description"] odb_get]; ::if {$Title ne ""} {::return $Title;} ::return "Tax1"; ]} ::set Tax2TitleScript {[ ::set Journal [[$this odb_database application] "/OBJECT/NEWVIEWS/JOURNAL/SALES"]; ::set Title [[$Journal ".trade_tax/2.description"] odb_get]; ::if {$Title ne ""} {::return $Title;} ::set Journal [[$this odb_database application] "/OBJECT/NEWVIEWS/JOURNAL/PURCHASE"]; ::set Title [[$Journal ".trade_tax/2.description"] odb_get]; ::if {$Title ne ""} {::return $Title;} ::return "Tax2"; ]} ::sargs::var::set _postings_table_column_setup \ "/posting/tax1/amount.script/title" $Tax1TitleScript \ "/posting/tax2/amount.script/title" $Tax2TitleScript \ ; ::sargs::var::set _postings_table_column_setup \ "/posting/tax1/account/odb_path_help.script/title" "${Tax1TitleScript} Account" \ "/posting/tax2/account/odb_path_help.script/title" "${Tax2TitleScript} Account" \ ; ::sargs::var::+= ColumnSetup $_postings_table_column_setup; [$_postings_table_window ".column_definitions"] odb_set [::sargs::+= [[$_postings_table_window ".column_definitions"] qw_get] $ColumnSetup]; [$_postings_table_window ".column_names"] odb_set $ColumnNames; $_postings_table_window odb_commit; ::set _column_titles [[$_postings_table_window ".client"] dataInterfaceRowTitle]; ::set _column_names [[$_postings_table_window ".column_names"] odb_get]; ::set _column_names_user_selected $_column_names; ::lappend _column_names /account/odb_address; ::lappend _column_names /posting/charge/account/odb_address; ::lappend _column_names /cross_account/odb_address; ::lappend _column_names /posting/tax1/account/odb_address; ::lappend _column_names /posting/tax2/account/odb_address; ::lappend _column_names /posting/inventory/account/odb_address; ::lappend _column_names /posting/cgs/account/odb_address; ::foreach Colname { /account/odb_path_help /cross_account/odb_path_help /cross_account/name /cross_account/description /posting/charge/account/odb_path_help /posting/charge/amount } { ::if {[::lsearch $_column_names $Colname]<0} { ::lappend _column_names $Colname; } } [$_postings_table_window ".column_names"] odb_set $_column_names; $_postings_table_window odb_commit; ::set _column_definition_tree [$_postings_table_window columnDefinitionTree]; ::set _empty_row_values ""; ::foreach Name $_column_names { ::lappend _empty_row_values ""; } ::set _postings_table_initialize_odb_level [postings_table_initialize_odb_level]; } public method XXX_postings_table_initialize_odb_level {} { ::set Ddefs $_distribution_table_column_setup; ::return $Ddefs; } public method postings_table_initialize_odb_level {} { ::return [XXX_postings_table_initialize_odb_level]; ::set Pdefs ""; ::set Ddefs $_distribution_table_column_setup; ::set NormalBalance "credit"; ::if {[::sargs::boolean_get $settings .print_distributions_flows_analysis]} { } ::set Postings ""; ::append Postings "/posting/charge /posting/debit/charge /charge"; ::foreach {Path BorrowPath Sub} $Postings { ::set Script { ::switch -glob -- [[%_object odb_master] odb_path] { "/OBJECT/NEWVIEWS/SYSTEM/TRANSACTION/SALES*" {::return [%_object "/credit%_sub"];} "/OBJECT/NEWVIEWS/SYSTEM/TRANSACTION/PURCHASE*" {::return [%_object "/debit%_sub"];} "/OBJECT/NEWVIEWS/SYSTEM/TRANSACTION/BANK/DEPOSIT*" {::return [%_object "/credit"];} "/OBJECT/NEWVIEWS/SYSTEM/TRANSACTION/BANK/PAYMENT*" {::return [%_object "/debit"];} "/OBJECT/NEWVIEWS/SYSTEM/TRANSACTION/GENERAL*" { ::set Account [[[%_object odb_master] ".posting/debit.account"] qw_get]; ::if {$Account ne ""} { ::return [%_object "/debit"]; } ::return [%_object "/credit"]; } "/OBJECT/NEWVIEWS/SYSTEM/TRANSACTION/PAYROLL*" {::return [%_object "/debit"];} } ::return ""; } ::set Script [::string map "%_sub $Sub" $Script]; ::sargs::var::set Pdefs "$Path.script/command/get" $Script; ::sargs::var::set Ddefs "$Path.script/command/get" $Script; ::if {[::sargs::boolean_get $settings .print_distributions_flows_analysis]} { ::foreach Value "quantity amount" { ::set Script { ::set Amount [[%_object ".%_value"] odb_get]; ::if {[%_context_account normal_balance_get] ne "%_normal_balance"} { ::qw::number::var::negative Amount; } ::return [::qw::number::format $Amount $::qw::number::formats(%_format)]; } ::set Script [::string map "%_value $Value" $Script]; ::set Script [::string map "%_normal_balance $NormalBalance" $Script]; ::sargs::var::set Pdefs "$Path/$Value.script/command/get" $Script; ::sargs::var::set Ddefs "$Path/$Value.script/command/get" $Script; } } } ::set Postings ""; ::append Postings " /posting/tax1 /posting/debit/tax1 /tax1"; ::append Postings " /posting/tax2 /posting/debit/tax2 /tax2"; ::foreach {Path BorrowPath Sub} $Postings { ::set Script { ::switch -glob -- [[%_object odb_master] odb_path] { "/OBJECT/NEWVIEWS/SYSTEM/TRANSACTION/SALES*" {::return [%_object "/credit%_sub"];} "/OBJECT/NEWVIEWS/SYSTEM/TRANSACTION/PURCHASE*" {::return [%_object "/debit%_sub"];} } ::return ""; } ::set Script [::string map "%_sub $Sub" $Script]; ::sargs::var::set Pdefs "$Path.script/command/get" $Script; ::sargs::var::set Ddefs "$Path.script/command/get" $Script; ::if {[::sargs::boolean_get $settings .print_distributions_flows_analysis]} { ::foreach Value "amount" { ::set Script { ::set Amount [[%_object ".%_value"] odb_get]; ::if {[%_context_account normal_balance_get] ne "%_normal_balance"} { ::qw::number::var::negative Amount; } ::return [::qw::number::format $Amount $::qw::number::formats(%_format)]; } ::set Script [::string map "%_value $Value" $Script]; ::set Script [::string map "%_normal_balance $NormalBalance" $Script]; ::sargs::var::set Pdefs "$Path/$Value.script/command/get" $Script; ::sargs::var::set Ddefs "$Path/$Value.script/command/get" $Script; } } } ::set Postings ""; ::append Postings " /posting/cgs /posting/debit/cgs /cgs"; ::foreach {Path BorrowPath Sub} $Postings { ::set Script { ::switch -glob -- [[%_object odb_master] odb_path] { "/OBJECT/NEWVIEWS/SYSTEM/TRANSACTION/SALES*" {::return [%_object "/debit%_sub"];} } ::return ""; } ::set Script [::string map "%_sub $Sub" $Script]; ::sargs::var::set Pdefs "$Path.script/command/get" $Script; ::sargs::var::set Ddefs "$Path.script/command/get" $Script; ::if {[::sargs::boolean_get $settings .print_distributions_flows_analysis]} { ::foreach Value "quantity amount" { ::set Script { ::set Amount [[%_object ".%_value"] odb_get]; ::if {[%_context_account normal_balance_get] eq "%_normal_balance"} {::qw::number::var::negative Amount;} ;#// AR works, Current Assets doesn't ::return [::qw::number::format $Amount $::qw::number::formats(%_format)]; } ::set Script [::string map "%_value $Value" $Script]; ::set Script [::string map "%_normal_balance $NormalBalance" $Script]; ::sargs::var::set Pdefs "$Path/$Value.script/command/get" $Script; ::sargs::var::set Ddefs "$Path/$Value.script/command/get" $Script; } } } ::set Postings ""; ::append Postings " /posting/inventory /posting/credit/inventory /inventory"; ::foreach {Path BorrowPath Sub} $Postings { ::set Script { ::switch -glob -- [[%_object odb_master] odb_path] { "/OBJECT/NEWVIEWS/SYSTEM/TRANSACTION/SALES*" {::return [%_object "/credit%_sub"];} } ::return ""; } ::set Script [::string map "%_sub $Sub" $Script]; ::sargs::var::set Pdefs "$Path.script/command/get" $Script; ::sargs::var::set Ddefs "$Path.script/command/get" $Script; ::if {[::sargs::boolean_get $settings .print_distributions_flows_analysis]} { ::foreach Value "quantity amount" { ::set Script { ::set Amount [[%_object ".%_value"] odb_get]; ::if {[%_context_account normal_balance_get] eq "%_normal_balance"} { ::qw::number::var::negative Amount; } ::return [::qw::number::format $Amount $::qw::number::formats(%_format)]; } ::set Script [::string map "%_value $Value" $Script]; ::set Script [::string map "%_normal_balance $NormalBalance" $Script]; ::sargs::var::set Pdefs "$Path/$Value.script/command/get" $Script; ::sargs::var::set Ddefs "$Path/$Value.script/command/get" $Script; } } } ::return $Ddefs; } #qw_include .class ::qw::print::windows::table::postings .method {public method workbook_new {{Filename ""}}} public method workbook_new {{Filename ""}} { ::if {$Filename eq ""} { ::return [$_excel_workbooks factory]; } ::qw::try { ::return [$_excel_workbooks factory -filename $Filename]; } catch Exception { ::qw::throw [::sargs \ .text "Could not open file $Filename, $Exception" \ .help_id 907020050517120300 \ ]; } } public method workbook_new_XXX {{Filename ""}} { ::if {$Filename eq ""} { ::return [$_excel_workbooks factory]; } ::qw::try { ::return [$_excel_workbooks factory -filename $Filename]; } catch Exception { ::qw::throw [::sargs \ .text "Could not open file $Filename, $Exception" \ .help_id 907020050517120300 \ ]; } } #qw_include .class ::qw::print::windows::table::postings .method {public method workbook_select {Src}} public method workbook_select {Src} { ::set _workbook [$_excel_workbooks select $Src]; $_workbook activate; ::set _excel_sheets [$_workbook sheets]; ::set Sheet [$_excel_sheets selected]; ::if {$Sheet eq ""} { ::set Sheet [$_excel_sheets kidFirst [::sargs ".kid_create" 1]]; } sheet_select $Sheet; ::return $_workbook; } public method workbook_select_XXX {Src} { ::set _workbook [$_excel_workbooks select $Src]; $_workbook activate; ::set _excel_sheets [$_workbook sheets]; ::set Sheet [$_excel_sheets selected]; ::if {$Sheet eq ""} { ::set Sheet [$_excel_sheets kidFirst [::sargs ".kid_create" 1]]; } sheet_select $Sheet; ::return $_workbook; } #qw_include .class ::qw::print::windows::table::postings .method {public method workbook_close {Src}} public method workbook_close {Src} { $Src mark_file_saved; $Src close; $_excel_workbooks destroy $Src; ::set _sheet ""; ::return $this; } public method workbook_close_XXX {Src} { $Src mark_file_saved; $Src close; $_excel_workbooks destroy $Src; ::set _sheet ""; ::return $this; } #qw_include .class ::qw::print::windows::table::postings .method {public method hide_extra_sheets {}} public method hide_extra_sheets {} { ::foreach Sheet [::sargs::get [$_workbook clientdata] ".default_sheets"] { $Sheet visible 0; } ::return $this; } public method hide_extra_sheets_XXX {} { ::foreach Sheet [::sargs::get [$_workbook clientdata] ".default_sheets"] { $Sheet visible 0; } ::return $this; } #qw_include .class ::qw::print::windows::table::postings .method {public method sheet_new {}} public method sheet_new {} { ::return [$_excel_sheets factory]; } public method sheet_new_XXX {} { ::return [$_excel_sheets factory]; } #qw_include .class ::qw::print::windows::table::postings .method {public method sheet_select {Src}} public method sheet_select {Src} { ::if {$_sheet eq $Src} {::return $_sheet;} ::if {$_sheet ne ""} { ::set Clientdata [$_sheet clientdata]; ::sargs::var::set Clientdata ".current_row" $_sheet_row; ::sargs::var::set Clientdata ".current_column" $_sheet_column; $_sheet clientdata $Clientdata } ::set _sheet [$_excel_sheets select $Src]; $_sheet activate; ::set Clientdata [$Src clientdata]; ::set _sheet_row [::sargs::get $Clientdata ".current_row"]; ::set _sheet_column [::sargs::get $Clientdata ".current_column"]; ::set _pagesetup [$_sheet pagesetup]; ::set _columns [$_sheet columns]; ::set _rows [$_sheet rows]; ::set _cells [$_sheet cells]; ::set _ranges [$_sheet ranges]; ::set _column [$_columns kidFirst [::sargs ".kid_create" 1]]; ::set _row [$_rows kidFirst [::sargs ".kid_create" 1]]; ::set _cell [$_cells kidFirst [::sargs ".kid_create" 1]]; ::set _range [$_ranges kidFirst [::sargs ".kid_create" 1]]; $_range rectangle_Set {.size {.x 1 .y 1} .position {.x 1 .y 1}}; ::return $_sheet; } public method sheet_select_XXX {Src} { ::if {$_sheet eq $Src} {::return $_sheet;} ::if {$_sheet ne ""} { ::set Clientdata [$_sheet clientdata]; ::sargs::var::set Clientdata ".current_row" $_sheet_row; ::sargs::var::set Clientdata ".current_column" $_sheet_column; $_sheet clientdata $Clientdata } ::set _sheet [$_excel_sheets select $Src]; $_sheet activate; ::set Clientdata [$Src clientdata]; ::set _sheet_row [::sargs::get $Clientdata ".current_row"]; ::set _sheet_column [::sargs::get $Clientdata ".current_column"]; ::set _pagesetup [$_sheet pagesetup]; ::set _columns [$_sheet columns]; ::set _rows [$_sheet rows]; ::set _cells [$_sheet cells]; ::set _ranges [$_sheet ranges]; ::set _column [$_columns kidFirst [::sargs ".kid_create" 1]]; ::set _row [$_rows kidFirst [::sargs ".kid_create" 1]]; ::set _cell [$_cells kidFirst [::sargs ".kid_create" 1]]; ::set _range [$_ranges kidFirst [::sargs ".kid_create" 1]]; $_range rectangle_Set {.size {.x 1 .y 1} .position {.x 1 .y 1}}; ::return $_sheet; } #qw_include .class ::qw::print::windows::table::postings .method {public method sheet_name {{Src "get"}}} public method sheet_name {{Src "get"}} { ::if {$Src eq "get"} { ::return [$_sheet name_Get]; } $_sheet name_Set $Src; } public method sheet_name_XXX {{Src "get"}} { ::if {$Src eq "get"} { ::return [$_sheet name_Get]; } $_sheet name_Set $Src; } #qw_include .class ::qw::print::windows::table::postings .method {public method workbook_name {{Src "get"}}} public method workbook_name {{Src "get"}} { ::if {$Src eq "get"} { ::return [$_workbook name_Get]; } $_workbook name_Set $Src; } public method workbook_name_XXX {{Src "get"}} { ::if {$Src eq "get"} { ::return [$_workbook name_Get]; } $_workbook name_Set $Src; } #qw_include .class ::qw::print::windows::table::postings .method {public method workbook_current {}} public method workbook_current {} { ::return $_workbook; } public method workbook_current_XXX {} { ::return $_workbook; } #qw_include .class ::qw::print::windows::table::postings .method {public method sheet_current {}} public method sheet_current {} { ::return $_sheet; } public method sheet_current_XXX {} { ::return $_sheet; } #qw_include .class ::qw::print::windows::table::postings .method {public method sheet_initialize {}} public method sheet_initialize {} { ::if {[::sargs::boolean_get [$_sheet clientdata] ".initialized"]} { ::qw::throw "$_sheet has already been initialized." ::return $_sheet; } load_template_settings; pagesetup_column_widths_set; pagesetup_column_types_set; pagesetup_margins_set; pagesetup_header_and_footer_set; pagesetup_page_layout_set; ::set _content_rectangle [::list .position [::list .x $_sheet_start_column .y $_sheet_row] .size [::list .x [::llength $_column_titles] .y 0]]; $_sheet clientdata [::sargs::set [$_sheet clientdata] ".initialized" 1]; ::return $_sheet; } public method sheet_initialize_XXX {} { ::if {[::sargs::boolean_get [$_sheet clientdata] ".initialized"]} { ::qw::throw "$_sheet has already been initialized." ::return $_sheet; } load_template_settings; pagesetup_column_widths_set; pagesetup_column_types_set; pagesetup_margins_set; pagesetup_header_and_footer_set; pagesetup_page_layout_set; ::set _content_rectangle [::list .position [::list .x $_sheet_start_column .y $_sheet_row] .size [::list .x [::llength $_column_titles] .y 0]]; $_sheet clientdata [::sargs::set [$_sheet clientdata] ".initialized" 1]; ::return $_sheet; } #qw_include .class ::qw::print::windows::table::postings .method {public method sheet_finalize {}} public method sheet_finalize {} { ::if {[::sargs::boolean_get [$_sheet clientdata] ".finalized"]} { ::return $_sheet; } pagesetup_column_formats_set; pagesetup_column_justifications_set; set_print_range [::list .position [::list .x 0 .y 0] .size [::list .x [::llength $_column_names_user_selected] .y $_sheet_row]]; apply_template_settings; activate_top_left; mark_file_saved $_sheet clientdata [::sargs::set [$_sheet clientdata] ".finalized" 1]; ::return $_sheet; } public method sheet_finalize_XXX {} { ::if {[::sargs::boolean_get [$_sheet clientdata] ".finalized"]} { ::return $_sheet; } pagesetup_column_formats_set; pagesetup_column_justifications_set; set_print_range [::list .position [::list .x 0 .y 0] .size [::list .x [::llength $_column_names_user_selected] .y $_sheet_row]]; apply_template_settings; activate_top_left; mark_file_saved $_sheet clientdata [::sargs::set [$_sheet clientdata] ".finalized" 1]; ::return $_sheet; } } ::itcl::class ::qw::print::windows::template { inherit ::qw::print::windows; protected variable _template ""; protected variable _template_default ""; protected variable _methodArray ""; protected variable _template_manager ""; protected variable _reference ""; ;#// a database REFERENCE field. protected variable _sub ""; protected variable _headerInfo ""; protected variable _itemInfo ""; protected variable _page_number "0"; protected variable _itemsToDo "0"; protected variable _itemsDone "0"; protected variable _headerNames ""; protected variable _itemNames ""; protected variable _template_test_mode "0"; protected variable _template_test_method ""; protected variable _company_address_object ""; protected variable _item_reference ""; protected variable _item_master ""; protected variable _references ""; protected variable _extra_bill_address_object ""; protected variable _extra_ship_address_object ""; public variable ocr_date_format ""; public variable asterisk_amount_format ""; public variable text_amount_format ""; public variable currency_symbol ""; public variable currency_name ""; public variable currency_fraction_name ""; public variable currency_format $::qw::number::formats(dollar_minus_parentheses) {configure_currency_format $currency_format;} protected variable _textAmountWidth 0; protected variable _textAmountShrinkToFit 0; protected variable _textAmountFontInfo ""; protected variable _amountWidth 0; protected variable _amountFontInfo ""; protected variable _asteriskAmountWidth 0; protected variable _asteriskAmountFontInfo ""; protected variable _addressLines ""; constructor {args} { ::eval ::qw::print::windows::constructor $args; ::unset -nocomplain _methodArray; ::array set _methodArray {}; ::foreach Function [$this info function] { ::set MethodTail [::lindex [::split $Function ::] end]; ::if {$MethodTail eq "_TEMPLATE_TEST_DATA_METHOD"} { ::set _template_test_mode "1"; ::set _template_test_method $Function; ::break; } } ::foreach Function [$this info function] { ::set MethodTail [::lindex [::split $Function ::] end]; ::if {[::string index $MethodTail 0] eq "_" && [::string toupper $MethodTail] eq $MethodTail} { ::if {[::info exists _methodArray($MethodTail)]} { ::if {[::llength [::split $Function ":"]]<[::llength [::split $_methodArray($MethodTail) ":"]]} { ::continue; } } ::set _methodArray($MethodTail) $Function; } } } { ::set _template_manager [::qw::print::windows::template::manager ::qw::print::windows::template::manager::#auto]; $_template_manager owner_Set $this; $_template_manager callback_command $this template_callback; ::eval configure $args; } method constructorXXX {} { ::unset -nocomplain _methodArray; ::array set _methodArray {}; ::foreach Function [$this info function] { ::set MethodTail [::lindex [::split $Function ::] end]; ::if {$MethodTail eq "_TEMPLATE_TEST_DATA_METHOD"} { ::set _template_test_mode "1"; ::set _template_test_method $Function; ::break; } } ::foreach Function [$this info function] { ::set MethodTail [::lindex [::split $Function ::] end]; ::if {[::string index $MethodTail 0] eq "_" && [::string toupper $MethodTail] eq $MethodTail} { ::if {[::info exists _methodArray($MethodTail)]} { ::if {[::llength [::split $Function ":"]]<[::llength [::split $_methodArray($MethodTail) ":"]]} { ::continue; } } ::set _methodArray($MethodTail) $Function; } } ::set _template_manager [::qw::print::windows::template::manager ::qw::print::windows::template::manager::#auto]; $_template_manager owner_Set $this; $_template_manager callback_command $this template_callback; } destructor { ::if {$_template_manager ne ""} { ::if {[$_template_manager is_being_destroyed]} { ::qw::throw "$this attempted to destroy _template_manager $_template_manager but it is already being destroyed."; } ::itcl::delete object $_template_manager; ::set _template_manager ""; } } method configure_destination {Src} { chain $Src; ::if {$_template_manager ne ""} {$_template_manager configure -destination $destination;} } method configure_filename {Src} { chain $Src; ::if {$_template_manager ne ""} {$_template_manager configure -filename $filename;} } method configure_printer {Src} { chain $Src; ::if {$_template_manager ne ""} {$_template_manager configure -printer $printer;} } method configure_prompt_settings {Src} { chain $Src; ::if {$_template_manager ne ""} {$_template_manager configure -prompt_settings $prompt_settings;} } public method template_manager_get {} { ::return $_template_manager; } public method done {} { template_Set ""; $_template_manager configure -printer $printer; ::switch -- $destination { "display" { print_show; } "preview" { print_preview; } "printer" { print; file_close; } "file" { ::if {[::string first ".xl" [::sargs::get [::qw::file::info "$filename"] .extension]]==0} { ::if {[::string first %_ "[::sargs::get $prompt_settings .filename]"]<0} { file_save; } file_close; } } "email" { file_close; } } chain; } public method abort {} { chain; ::return $this; } public method template_Set {Src} { ::set _template $Src; ::if {$_template ne ""} { init; } ::return $this; } public method template_Get {} { ::return $_template; } public method template_default_Set {Src} { ::set _template_default $Src; ::return $this; } public method template_default_Get {} { ::return $_template_default; } public method filename_Set {Src} { $_template_manager filename_Set $Src; ::return $this; } public method printer_Set {Src} { ::return $this; } public method printer_Get {} { ::return [$_template_manager printer_Get]; } public method can_print {} { ::return [$_template_manager can_print]; } public method template_range_list {} { ::return [$_template_manager template_range_list]; } public method template_was_selected {} { ::if {$_template eq ""} {::return 0;} ::return 1; } public method load {Src} { ::if {[template_Get] eq ""} { ::qw::throw "Attempted to print with no template selected." } ::set _reference $Src; ::set _page_number 0; ::set _itemsDone 0; chain $Src; $_template_manager load; ;#// calling back ::return [::sargs .page_count $_page_number .address_source $_addressSource]; } public method print {} { $_template_manager print; ::return $this; } public method print_show {} { $_template_manager visible_Set 1; ::return $this; } public method print_preview {} { $_template_manager print_preview; ::return $this; } public method file_save {} { $_template_manager file_save; } public method file_close {} { $_template_manager file_close; } public method template_select {} { ::if {[template_default_Get] ne ""} { ::set DefaultDirectory [template_default_Get]; } else { ::set DefaultDirectory [$_database cpp_directory]; } ::set TemplateFile ""; ::while {1} { ::if {$TemplateFile ne ""} { ::set DefaultDirectory [::file dirname $TemplateFile]; } ::set TemplateFile [::qw::dialog::file [::qw::list { .files 1 .patterns "*.xls *.xlsx *.xlt *.xltx" .title "Select Template" .default $DefaultDirectory }]]; ::if {$TemplateFile eq ""} {::break;} ::set Extension [string tolower [::file extension $TemplateFile]]; ::switch $Extension { .xlt - .xltx - .xls - .xlsx {} default { ::qw::dialog::error "Template file must have .xls or .xlsx or .xlt or .xltx extension."; ::continue; } } ::break; } template_Set $TemplateFile; ::return $this; } method templateManagerCommand {args} { ::set Result [::eval $_template_manager $args]; ::return $Result; } public method template_callback {s_args} { ::set Command [::sargs::get $s_args ".command"]; ::switch -exact -- $Command { "data" { headerInfoLoad [::sargs::get $s_args ".names"]; ::return [::array get _headerInfo]; } "item" { itemInfoLoad [::sargs::get $s_args ".names"]; ::incr _itemsDone; ::return [::array get _itemInfo]; } "moreitemsquery" {::return [moreItemsQuery];} "pagebreakquery" {::return [pageBreakQuery];} "pagestart" {::incr _page_number;::return $this;} "itemstart" {itemStart;} "documentstart" {documentStart;} "pageend" {} "documentend" {documentEnd;} "ready" {::return $this;} default { ::qw::throw "Unknown callback command \"$Command\"."; } } } method pageStart {} { ::incr _page_number;::return $this; } method pageEnd {Src} { ::return; } method sortUserNames {Src} { ::if {[::llength $Src]<2} {::return $Src;} ::set Names ""; ::foreach Name $Src {::lappend Names [::scan $Name {%[A-Z_]%d}]} ::set Names [::lsort -integer -index 1 $Names]; ::set Result ""; ::foreach Pair $Names { ::foreach {Name Number} $Pair {}; ::lappend Result $Name$Number; } ::return $Result; } method isUserName {Src Prefix} { ::set Count [::scan $Src %\[$Prefix\]%d Name Number]; ::if {$Count!=2} {::return 0;} ::if {$Name ne $Prefix} {::return 0;} ::if {$Number eq ""} {::return 0;} ::if {![::string is integer $Number]} {::return 0;} ::return 1; } private method nameRoot {Src} { ::set NamePieces [::split $Src "_"]; ::if {[::llength $NamePieces]>3} {::qw::throw "Invalid range name \"$Src\". (Contains more than 2 \"_\" characters.)";} ::if {[::llength $NamePieces]>2} {::return [::join [::lrange $NamePieces 0 end-1] "_"];} ::if {[::lindex $NamePieces 0] eq "ITEM"} {::return [::join $NamePieces "_"];} ::return [::lindex $NamePieces 0]; } private method nameSuffix {Src} { ::if {[::regexp {(_)([0-9]*)$} $Src match Trash Suffix]} { ::return $Suffix; } ::return ""; } method headerInfoLoad {Src} { ::set UserNames ""; ::foreach Name $Src { ::if {[isUserName $Name "USER"]} { ::lappend UserNames $Name; ::continue; } ::set RootName [nameRoot $Name]; ::set _headerInfo($Name) [$_methodArray(_$RootName) [::sargs ".name" $RootName ".suffix" [nameSuffix $Name]]]; } ::foreach Name [sortUserNames $UserNames] { ::set _headerInfo($Name) [$_methodArray(_$Name) [::sargs ".name" $Name ".suffix" [nameSuffix $Name]]]; } ::return $this; } method itemInfoLoad {Src} { ::set UserNames ""; ::foreach Name $Src { ::if {[isUserName $Name "ITEM_USER"]} { ::lappend UserNames $Name; ::continue; } ::set RootName [nameRoot $Name]; ::set _itemInfo($Name) [$_methodArray(_$RootName) [::sargs ".name" $RootName ".suffix" [nameSuffix $Name]]]; } ::foreach Name [sortUserNames $UserNames] { ::set _itemInfo($Name) [$_methodArray(_$Name) [::sargs ".name" $Name ".suffix" [nameSuffix $Name]]]; } ::return $this; } public method address_printable {Address} { ::if {$Address eq ""} { ::return ""; } ::foreach Field {street street2 city state country zipcode} { ::set Value($Field) [[$Address ".$Field"] odb_get]; } ::set Result ""; ::if {$Value(street) ne ""} {::append Result "$Value(street)\n";} ::if {$Value(street2) ne ""} {::append Result "$Value(street2)\n";} ::append Result [city_state_zipcode_printable $Address]; ::set Result [::string trim $Result]; ::if {$Result eq ""} { ::set Result [[$Address ".freeform"] odb_get]; } ::return $Result; } public method city_state_zipcode_printable {Address} { ::if {$Address eq ""} { ::return ""; } ::set Result ""; ::foreach Field {city state zipcode} { ::set Value($Field) [[$Address ".$Field"] odb_get]; } ::set Result ""; ::if {$Value(city) ne ""} {::append Result "$Value(city)";} ::if {$Value(state) ne ""} {::append Result " $Value(state)";} ::if {$Value(zipcode) ne ""} {::append Result " $Value(zipcode)";} ::set Result [::string trim $Result]; ::return $Result; } public method city_state_zipcode_printable_from_qw_structure {s_args} { ::if {$s_args eq ""} { ::return ""; } ::set Result ""; ::if {[::sargs::get $s_args .city] ne ""} {::append Result [::sargs::get $s_args .city];} ::if {[::sargs::get $s_args .state] ne ""} {::append Result " [::sargs::get $s_args .state]";} ::if {[::sargs::get $s_args .zipcode] ne ""} {::append Result " [::sargs::get $s_args .zipcode]";} ::set Result [::string trim $Result]; ::return $Result; } public method _PAGE {args} {::return $_page_number;} public method _DATEPRINTED {args} {::return [now];} public method _CHECKDATE {s_args} { } public method _OCRCHECKDATE {s_args} { ::set Date [_CHECKDATE dummy_s_args]; ::if {$ocr_date_format eq ""} {::return $Date;} ::set Date [::qw::date::format $Date $::qw::date::formats(yyyymmdd)]; ::set Day [::string range $Date 6 7]; ::set Month [::string range $Date 4 5]; ::set Year [::string range $Date 0 3]; ::switch -- $ocr_date_format { "Mmm dd,yy" {::set Date [::qw::date::format $Date "%b %d,%y"];} "Mmm dd,yyyy" {::set Date [::qw::date::format $Date "%b %d,%Y"];} "Month dd,yyyy" {::set Date [::qw::date::format $Date "%B %d,%Y"];} "D D M M Y Y Y Y" - "DDMMYYYY" {::set Date "$Day$Month$Year";} "DD MM YYYY" {::set Date "$Day $Month $Year";} "DD-MM-YYYY" {::set Date "$Day-$Month-$Year";} "DD.MM.YYYY" {::set Date "$Day.$Month.$Year";} "M M D D Y Y Y Y" - "MMDDYYYY" {::set Date "$Month$Day$Year";} "MM DD YYYY" {::set Date "$Month $Day $Year";} "MM-DD-YYYY" {::set Date "$Month-$Day-$Year";} "MM.DD.YYYY" {::set Date "$Month.$Day.$Year";} "Y Y Y Y M M D D" - "YYYYMMDD" {::set Date "$Year$Month$Day";} "YYYY MM DD" {::set Date "$Year $Month $Day";} "YYYY-MM-DD" {::set Date "$Year-$Month-$Day";} "YYYY.MM.DD" {::set Date "$Year.$Month.$Day";} } ::switch -- $ocr_date_format { "M M D D Y Y Y Y" - "D D M M Y Y Y Y" - "Y Y Y Y M M D D" {::set Date [::join [::split $Date ""] " "];} } ::return [::sargs ".value" $Date ".format" "@"]; } public method _OCRDATEGUIDE {s_args} { ::return $ocr_date_format; } ::set ::qw::print::Limit [::sargs::get $::qw::options ".print.template.user_variables"]; ::foreach {::qw::print::Name ::qw::print::Field} { "_COMPANYADDRESS" "freeform" "_COMPANYNAME" "company" "_COMPANYCONTACTNAME" "name.freeform" "_COMPANYCONTACTNAMESALUTATION" "name.salutation" "_COMPANYCONTACTNAMEFIRST" "name.first" "_COMPANYCONTACTNAMEMIDDLE" "name.middle" "_COMPANYCONTACTNAMELAST" "name.last" "_COMPANYSTREET" "street" "_COMPANYSTREET2" "street2" "_COMPANYCITY" "city" "_COMPANYSTATE" "state" "_COMPANYCOUNTRY" "country" "_COMPANYZIPCODE" "zipcode" "_COMPANYCITYSTATEZIPCODE" "city_state_zipcode" "_COMPANYPHONE" "phone.freeform" "_COMPANYPHONECOUNTRYCODE" "phone.country_code" "_COMPANYPHONEAREACODE" "phone.area_code" "_COMPANYPHONEPREFIX" "phone.prefix" "_COMPANYPHONESUFFIX" "phone.suffix" "_COMPANYPHONEEXTENSION" "phone.extension" "_COMPANYFAX" "phone/fax.freeform" "_COMPANYFAXCOUNTRYCODE" "phone/fax.country_code" "_COMPANYFAXAREACODE" "phone/fax.area_code" "_COMPANYFAXPREFIX" "phone/fax.prefix" "_COMPANYFAXSUFFIX" "phone/fax.suffix" "_COMPANYFAXEXTENSION" "phone/fax.extension" "_COMPANYEMAIL" "email" "_COMPANYWEBSITE" "website" } { ::set ::qw::print::Body [::string map "%_field $::qw::print::Field" {::return [company_address_item [::sargs::set [::lindex $args 0] .field %_field]];}] public method $::qw::print::Name {args} $::qw::print::Body; } ::unset ::qw::print::Name; ::unset ::qw::print::Field; ::unset ::qw::print::Body; public method company_address_item {s_args} { ::if {$_company_address_object eq ""} { ::return ""; } ::set Name [::sargs::get $s_args ".name"]; ::set Field [::sargs::get $s_args ".field"]; ::set Suffix [::sargs::get $s_args ".suffix"]; ::if {$Suffix eq ""} { ::set AddressSource $_company_address_object; } else { ::incr Suffix -1; ::set AddressSource [::lindex $_references $Suffix]; ::if {$AddressSource ne ""} { ::set AddressSource [$AddressSource odb_master]; } } ::if {$AddressSource eq ""} { ::return ""; } ::set Src $Field; ::switch -exact -- $Src { "freeform" { ::return [address_printable [$_company_address_object ".address"]]; } "city_state_zipcode" { ::return [city_state_zipcode_printable [$_company_address_object ".address"]]; } } ::return [[$_company_address_object ".address.$Src"] odb_get]; } public method init {} { chain; ::qw::try { ::tcom::ref getactiveobject "Excel.Application"; } catch Exception { } ::if {$_template eq ""} { ::return $this; } $_template_manager template_file_name_Set $_template; $_template_manager init; ::set _headerNames [$_template_manager headerNames]; ::set _itemNames [$_template_manager itemNames]; ::set j 0; ::set ErrorList ""; ::foreach Name [::concat $_headerNames $_itemNames] { ::if {$_template_test_mode} { ::set _methodArray(_$Name) $_template_test_method; ::continue; } ::if {![::info exists _methodArray(_$Name)]} { ::append ErrorList " $Name"; } } ::if {$ErrorList ne ""} { $_template_manager deinit; ::set S [::expr [::llength $ErrorList]>1?{s}:{}]; ::qw::throw [::sargs \ .text "The template contains [::llength $ErrorList] unknown name$S. Click Help for details." \ .help_id 907020060427113946 \ .error_list $ErrorList \ .template_filename $_template \ ]; } ::unset -nocomplain _headerInfo;::array set _headerInfo {}; ::unset -nocomplain _itemInfo;::array set _itemInfo {}; ::set _company_address_object [[database_Get] "/OBJECT/NEWVIEWS/ACCOUNT"]; ::if {[::lsearch -exact $_headerNames "TEXTAMOUNT"]>=0} { ::array set RangeInfo [templateManagerCommand rangeInformationGet "TEXTAMOUNT"]; ::set _textAmountFontInfo $RangeInfo(-font); ::set _textAmountWidth [::sargs::get $RangeInfo(-size) ".x"]; ::set _textAmountShrinkToFit $RangeInfo(-shrinktofit); } ::if {[::lsearch -exact $_headerNames "CHECKAMOUNT"]>=0} { ::array set RangeInfo [templateManagerCommand rangeInformationGet "CHECKAMOUNT"]; ::set _amountFontInfo $RangeInfo(-font); ::set _amountWidth [::sargs::get $RangeInfo(-size) ".x"]; } ::if {[::lsearch -exact $_headerNames "CHECKAMOUNTASTERISK"]>=0} { ::array set RangeInfo [templateManagerCommand rangeInformationGet "CHECKAMOUNTASTERISK"]; ::set _asteriskAmountFontInfo $RangeInfo(-font); ::set _asteriskAmountWidth [::sargs::get $RangeInfo(-size) ".x"]; } ::return $this; } public method documentStart {} { numberOfItemsSet; ::unset -nocomplain _headerInfo; ::array set _headerInfo {}; ::return $this; } public method itemStart {} { ::unset -nocomplain _itemInfo;::array set _itemInfo {}; nextItemLoad; ::return $this; } public method documentEnd {} { ::return $this; } method nextItemLoad {} { ::return $this; } method numberOfItemsSet {} { ::set _itemsToDo "0"; } method moreItemsQuery {} { ::return [::expr $_itemsDone<$_itemsToDo]; } method pageBreakQuery {} { ::return 0; } protected variable _addressSource ""; method address_source_get {} { ::return $_addressSource; } method addressSourceGet {s_args} { ::set Name [::sargs::get $s_args ".name"]; ::set Field [::sargs::get $s_args ".field"]; ::set Suffix [::sargs::get $s_args ".suffix"]; ::if {$Suffix eq ""} { ::set AddressSource $_addressSource; } else { ::incr Suffix -1; ::set AddressSource [::lindex $_references $Suffix]; ::if {$AddressSource ne ""} { ::set AddressSource [$AddressSource odb_master]; } } ::if {$AddressSource eq ""} { ::return ""; } ::return [$AddressSource $Field]; } method addressSourceSet {} { ::if {$_reference eq ""} { ::set _addressSource ""; ::return; } ::switch -glob -- [[$_reference odb_master] odb_path] { "/OBJECT/NEWVIEWS/SYSTEM/EMPLOYEE*" - "/OBJECT/NEWVIEWS/ACCOUNT*" { ::set _addressSource [$_reference odb_master]; } default { ::set _addressSource ""; } } } public method address_field {s_args} { ::set Name [::sargs::get $s_args ".name"]; ::set Field [::sargs::get $s_args ".field"]; ::set Suffix [::sargs::get $s_args ".suffix"]; ::if {$Suffix eq ""} { ::set AddressSource $_addressSource; } else { ::incr Suffix -1; ::set AddressSource [::lindex $_references $Suffix]; ::if {$AddressSource ne ""} { ::set AddressSource [$AddressSource odb_master]; } } ::if {$AddressSource eq ""} { ::return ""; } ::switch -glob -- [$AddressSource odb_path] { "/OBJECT/NEWVIEWS/ACCOUNT/AP*" - "/OBJECT/NEWVIEWS/ACCOUNT/AR*" { ::switch -glob -- $Field { "/shipping*" { ::if {$_extra_ship_address_object ne ""} { ::set Field [::string map {/shipping ""} $Field]; ::return [[$_extra_ship_address_object ".address$Field"] odb_get]; } ::return [[$AddressSource ".address$Field"] odb_get]; } default { ::if {$_extra_bill_address_object ne ""} { ::return [[$_extra_bill_address_object ".address$Field"] odb_get]; } ::return [[$AddressSource ".address$Field"] odb_get]; } } } "/OBJECT/NEWVIEWS/ACCOUNT*" { ::switch -glob -- $Field { "/shipping*" { ::return ""; } default { ::if {$_extra_bill_address_object ne ""} { ::return [[$_extra_bill_address_object ".address$Field"] odb_get]; } ::return [[$AddressSource ".address$Field"] odb_get]; } } ::return [[$AddressSource ".address$Field"] odb_get]; } "/OBJECT/NEWVIEWS/SYSTEM/EMPLOYEE*" { ::switch -glob -- $Field { ".company*" - "/shipping*" { ::return ""; } ".name*" { ::return [[$AddressSource [::string map {.name .employee_name .freeform .print_as} $Field]] odb_get]; } default { ::return [[$AddressSource ".address$Field"] odb_get]; } } } } ::return ""; } public method _ADDRESS {args} { ::if {$_addressSource eq ""} { ::return ""; } ::if {$_extra_bill_address_object ne ""} { ::return [address_printable [$_extra_bill_address_object ".address"]]; } ::return [address_printable [addressSourceGet [::sargs::set [::lindex $args 0] .field .address]]]; } public method _COMPANY {args} {::return [address_field [::sargs::set [::lindex $args 0] .field .company]];} public method _CONTACTNAME {args} { ::return [address_field [::sargs::set [::lindex $args 0] .field .name.freeform]]; } public method _CONTACTSALUTATION {args} {::return [address_field [::sargs::set [::lindex $args 0] .field .name.salutation]];} public method _CONTACTFIRST {args} {::return [address_field [::sargs::set [::lindex $args 0] .field .name.first]];} public method _CONTACTMIDDLE {args} {::return [address_field [::sargs::set [::lindex $args 0] .field .name.middle]];} public method _CONTACTLAST {args} {::return [address_field [::sargs::set [::lindex $args 0] .field .name.last]];} public method _STREET {args} { ::return [address_field [::sargs::set [::lindex $args 0] .field .street]]; } public method _STREET2 {args} {::return [address_field [::sargs::set [::lindex $args 0] .field .street2]];} public method _CITY {args} {::return [address_field [::sargs::set [::lindex $args 0] .field .city]];} public method _STATE {args} {::return [address_field [::sargs::set [::lindex $args 0] .field .state]];} public method _COUNTRY {args} {::return [address_field [::sargs::set [::lindex $args 0] .field .country]];} public method _ZIPCODE {args} {::return [address_field [::sargs::set [::lindex $args 0] .field .zipcode]];} public method _CITYSTATEZIPCODE {args} { ::if {$_extra_bill_address_object ne ""} { ::return [city_state_zipcode_printable [$_extra_bill_address_object ".address"]]; } ::return [city_state_zipcode_printable [addressSourceGet [::sargs::set [::lindex $args 0] .field .address]]]; } public method _PHONE {args} {::return [address_field [::sargs::set [::lindex $args 0] .field .phone.freeform]];} public method _PHONECOUNTRYCODE {args} {::return [address_field [::sargs::set [::lindex $args 0] .field .phone.country_code]];} public method _PHONEAREACODE {args} {::return [address_field [::sargs::set [::lindex $args 0] .field .phone.area_code]];} public method _PHONEPREFIX {args} {::return [address_field [::sargs::set [::lindex $args 0] .field .phone.prefix]];} public method _PHONESUFFIX {args} {::return [address_field [::sargs::set [::lindex $args 0] .field .phone.suffix]];} public method _PHONEEXTENSION {args} {::return [address_field [::sargs::set [::lindex $args 0] .field .phone.extension]];} public method _FAX {args} {::return [address_field [::sargs::set [::lindex $args 0] .field .phone/fax.freeform]];} public method _FAXCOUNTRYCODE {args} {::return [address_field [::sargs::set [::lindex $args 0] .field .phone/fax.country_code]];} public method _FAXAREACODE {args} {::return [address_field [::sargs::set [::lindex $args 0] .field .phone/fax.area_code]];} public method _FAXPREFIX {args} {::return [address_field [::sargs::set [::lindex $args 0] .field .phone/fax.prefix]];} public method _FAXSUFFIX {args} {::return [address_field [::sargs::set [::lindex $args 0] .field .phone/fax.suffix]];} public method _FAXEXTENSION {args} {::return [address_field [::sargs::set [::lindex $args 0] .field .phone/fax.extension]];} public method _EMAIL {args} {::return [address_field [::sargs::set [::lindex $args 0] .field .email]];} public method _WEBSITE {args} {::return [address_field [::sargs::set [::lindex $args 0] .field .website]];} public method _SHIPADDRESS {args} { ::if {$_addressSource eq ""} { ::return ""; } ::switch -glob -- [$_addressSource odb_path] { "/OBJECT/NEWVIEWS/ACCOUNT/AP*" - "/OBJECT/NEWVIEWS/ACCOUNT/AR*" { ::if {$_extra_ship_address_object ne ""} { ::return [address_printable [$_extra_ship_address_object ".address"]]; } ::return [address_printable [addressSourceGet [::sargs::set [::lindex $args 0] .field .address/shipping]]]; } default { ::return ""; } } } public method _SHIPCOMPANY {args} {::return [address_field [::sargs::set [::lindex $args 0] .field /shipping.company]];} public method _SHIPCONTACTNAME {args} { ::return [address_field [::sargs::set [::lindex $args 0] .field /shipping.name.freeform]]; } public method _SHIPCONTACTSALUTATION {args} {::return [address_field [::sargs::set [::lindex $args 0] .field /shipping.name.salutation]];} public method _SHIPCONTACTFIRST {args} {::return [address_field [::sargs::set [::lindex $args 0] .field /shipping.name.first]];} public method _SHIPCONTACTMIDDLE {args} {::return [address_field [::sargs::set [::lindex $args 0] .field /shipping.name.middle]];} public method _SHIPCONTACTLAST {args} {::return [address_field [::sargs::set [::lindex $args 0] .field /shipping.name.last]];} public method _SHIPSTREET {args} {::return [address_field [::sargs::set [::lindex $args 0] .field /shipping.street]];} public method _SHIPSTREET2 {args} {::return [address_field [::sargs::set [::lindex $args 0] .field /shipping.street2]];} public method _SHIPCITY {args} {::return [address_field [::sargs::set [::lindex $args 0] .field /shipping.city]];} public method _SHIPSTATE {args} {::return [address_field [::sargs::set [::lindex $args 0] .field /shipping.state]];} public method _SHIPCOUNTRY {args} {::return [address_field [::sargs::set [::lindex $args 0] .field /shipping.country]];} public method _SHIPZIPCODE {args} {::return [address_field [::sargs::set [::lindex $args 0] .field /shipping.zipcode]];} public method _SHIPCITYSTATEZIPCODE {args} { ::if {$_extra_ship_address_object ne ""} { ::return [city_state_zipcode_printable [$_extra_ship_address_object ".address"]]; } ::return [city_state_zipcode_printable [addressSourceGet [::sargs::set [::lindex $args 0] .field .address/shipping]]]; } public method _SHIPPHONE {args} {::return [address_field [::sargs::set [::lindex $args 0] .field /shipping.phone.freeform]];} public method _SHIPPHONECOUNTRYCODE {args} {::return [address_field [::sargs::set [::lindex $args 0] .field /shipping.phone.country_code]];} public method _SHIPPHONEAREACODE {args} {::return [address_field [::sargs::set [::lindex $args 0] .field /shipping.phone.area_code]];} public method _SHIPPHONEPREFIX {args} {::return [address_field [::sargs::set [::lindex $args 0] .field /shipping.phone.prefix]];} public method _SHIPPHONESUFFIX {args} {::return [address_field [::sargs::set [::lindex $args 0] .field /shipping.phone.suffix]];} public method _SHIPPHONEEXTENSION {args} {::return [address_field [::sargs::set [::lindex $args 0] .field /shipping.phone.extension]];} public method _SHIPFAX {args} {::return [address_field [::sargs::set [::lindex $args 0] .field /shipping.phone/fax.freeform]];} public method _SHIPFAXCOUNTRYCODE {args} {::return [address_field [::sargs::set [::lindex $args 0] .field /shipping.phone/fax.country_code]];} public method _SHIPFAXAREACODE {args} {::return [address_field [::sargs::set [::lindex $args 0] .field /shipping.phone/fax.area_code]];} public method _SHIPFAXPREFIX {args} {::return [address_field [::sargs::set [::lindex $args 0] .field /shipping.phone/fax.prefix]];} public method _SHIPFAXSUFFIX {args} {::return [address_field [::sargs::set [::lindex $args 0] .field /shipping.phone/fax.suffix]];} public method _SHIPFAXEXTENSION {args} {::return [address_field [::sargs::set [::lindex $args 0] .field /shipping.phone/fax.extension]];} public method _SHIPEMAIL {args} {::return [address_field [::sargs::set [::lindex $args 0] .field /shipping.email]];} public method _SHIPWEBSITE {args} {::return [address_field [::sargs::set [::lindex $args 0] .field /shipping.website]];} method additional_info_field_id {Ftype Master Id} { ::set Adef [[$Master .additional_info_schema] odb_get]; ::set Asubs [::sargs::subs .structure $Adef]; ::set FTYPE [::string toupper $Ftype]; ::set Fid ""; ::foreach Sub $Asubs { ::if {[::sargs::get $Adef $Sub.field_type] ne $Ftype} { ::continue; } ::if {[::string map [::list ITEM_INFO${FTYPE} "" INFO${FTYPE} ""] [::sargs::get $Adef $Sub.field_id_template]] eq $Id} { ::set Fid [::sargs::get $Adef $Sub.field_id]; ::break; } } ::return $Fid; } public method additional_info_string {Master Id} { ::set Data [[$Master ".structure_data"] odb_get]; ::return [::sargs::get $Data ".newviews.additional_info_string_$Id"]; } public method additional_info_string_232 {Master Id} { ::set Data [[$Master .structure_data] odb_get]; ::set Fid [additional_info_field_id string $Master $Id]; ::return [::sargs::get $Data .newviews.additional_info_string_$Fid]; ;#// when $Fid is "" this will ::return "" because the path doesn't exist } public method additional_info_date {Master Id} { ::set Data [[$Master ".structure_data"] odb_get]; ::set Date [::sargs::get $Data ".newviews.additional_info_date_$Id"]; ::if {$Date eq ""} { ::return ""; } ::set Format [[[[$Master odb_database application] cpp_user_get] .options.date.format] odb_get]; ::set Format $::qw::date::formats($Format); ::return [::qw::date::format $Date $Format]; } public method additional_info_date_232 {Master Id} { ::set Data [[$Master .structure_data] odb_get]; ::set Fid [additional_info_field_id date $Master $Id]; ::set Date [::sargs::get $Data .newviews.additional_info_date_$Fid]; ::if {$Date eq ""} { ::return ""; } ::set Format [[[[$Master odb_database application] cpp_user_get] .options.date.format] odb_get]; ::set Format $::qw::date::formats($Format); ::return [::qw::date::format $Date $Format]; } public method additional_info_number {Master Id} { ::set Data [[$Master .structure_data] odb_get]; ::set Fid [additional_info_field_id number $Master $Id]; ::set Number [::sargs::get $Data .newviews.additional_info_number_$Fid]; ::if {$Number eq ""} { ::return ""; } ::return [::qw::number::format $Number $currency_format]; } public method _INFOSTRING1 {s_args} { ::return [additional_info_string [$_reference odb_master] 1]; } public method _INFOSTRING2 {s_args} {::return [additional_info_string [$_reference odb_master] 2];} public method _INFOSTRING3 {s_args} {::return [additional_info_string [$_reference odb_master] 3];} public method _INFOSTRING4 {s_args} {::return [additional_info_string [$_reference odb_master] 4];} public method _INFOSTRING5 {s_args} {::return [additional_info_string [$_reference odb_master] 5];} public method _INFOSTRING6 {s_args} {::return [additional_info_string [$_reference odb_master] 6];} public method _INFOSTRING7 {s_args} {::return [additional_info_string [$_reference odb_master] 7];} public method _INFOSTRING8 {s_args} {::return [additional_info_string [$_reference odb_master] 8];} public method _INFOSTRING9 {s_args} {::return [additional_info_string [$_reference odb_master] 9];} public method _INFOSTRING10 {s_args} {::return [additional_info_string [$_reference odb_master] 10];} public method _INFODATE1 {s_args} {::return [additional_info_date [$_reference odb_master] 1];} public method _INFODATE2 {s_args} {::return [additional_info_date [$_reference odb_master] 2];} public method _INFODATE3 {s_args} {::return [additional_info_date [$_reference odb_master] 3];} public method _INFODATE4 {s_args} {::return [additional_info_date [$_reference odb_master] 4];} public method _INFODATE5 {s_args} {::return [additional_info_date [$_reference odb_master] 5];} public method _ITEM_INFOSTRING1 {s_args} { ::return [additional_info_string $_item_master 1]; } public method _ITEM_INFOSTRING2 {s_args} {::return [additional_info_string $_item_master 2];} public method _ITEM_INFOSTRING3 {s_args} {::return [additional_info_string $_item_master 3];} public method _ITEM_INFOSTRING4 {s_args} {::return [additional_info_string $_item_master 4];} public method _ITEM_INFOSTRING5 {s_args} {::return [additional_info_string $_item_master 5];} public method _ITEM_INFOSTRING6 {s_args} {::return [additional_info_string $_item_master 6];} public method _ITEM_INFOSTRING7 {s_args} {::return [additional_info_string $_item_master 7];} public method _ITEM_INFOSTRING8 {s_args} {::return [additional_info_string $_item_master 8];} public method _ITEM_INFOSTRING9 {s_args} {::return [additional_info_string $_item_master 9];} public method _ITEM_INFOSTRING10 {s_args} {::return [additional_info_string $_item_master 10];} public method _ITEM_INFODATE1 {s_args} {::return [additional_info_date $_item_master 1];} public method _ITEM_INFODATE2 {s_args} {::return [additional_info_date $_item_master 2];} public method _ITEM_INFODATE3 {s_args} {::return [additional_info_date $_item_master 3];} public method _ITEM_INFODATE4 {s_args} {::return [additional_info_date $_item_master 4];} public method _ITEM_INFODATE5 {s_args} {::return [additional_info_date $_item_master 5];} method checkAmount {Src} { ::if {$_page_number==1} { ::set Amount \ [::qw::bob::PadText [::qw::list { ".text" [::string trim [::qw::number::format $Src $::qw::number::formats(dollar)]] ".font" $_amountFontInfo ".size" $_amountWidth ".side" "L" ".character1" " " ".character2" " " }]] \ ; } else { ::set Amount \ [::qw::bob::PadText [::qw::list { ".text" "" ".font" $_amountFontInfo ".size" $_amountWidth ".side" "L" ".character1" "*" ".character2" "*" }]] \ ; } ::return [::sargs::get $Amount ".result"]; } method checkAmountAsterisk {Src} { ::if {$_page_number==1} { ::set Format { .font {} .size -1 .fill { .left "*" .middle "" .right "" } .text "%U%.%D%" .currency { .unit { .symbol {$} .singular "dollar" .plural "dollars" } .decimal { .singular "cent" .plural "cents" } } }; ::sargs::var::set Format ".font" $_asteriskAmountFontInfo; ::sargs::var::set Format ".size" $_asteriskAmountWidth; ::if {$asterisk_amount_format ne ""} { ::foreach FormatStructure [::qw::bob::check_asterisk_amount_formats] { ::if {$asterisk_amount_format eq [::sargs::get $FormatStructure ".sample"]} { ::sargs::var::+= Format [::sargs::get $FormatStructure ".format"]; ::break; } } } ::sargs::var::set Format ".currency.unit.symbol" $currency_symbol; ::if {[::llength $currency_name]==1} { ::sargs::var::set Format ".currency.unit.singular" $currency_name; ::sargs::var::set Format ".currency.unit.plural" "${currency_name}s"; } else { ::sargs::var::set Format ".currency.unit.singular" [::lindex $currency_name 0]; ::sargs::var::set Format ".currency.unit.plural" [::lindex $currency_name 1]; } ::if {[::llength $currency_fraction_name]==1} { ::sargs::var::set Format ".currency.decimal.singular" $currency_fraction_name; ::sargs::var::set Format ".currency.decimal.plural" "${currency_fraction_name}s"; } else { ::sargs::var::set Format ".currency.decimal.singular" [::lindex $currency_fraction_name 0]; ::sargs::var::set Format ".currency.decimal.plural" [::lindex $currency_fraction_name 1]; } ::set Src [::qw::number::format $Src $::qw::number::formats(dollar)]; ::set Amount [::qw::bob::FormatCheckAmount $Src $Format]; } else { ::set Amount \ [::qw::bob::PadText [::qw::list { ".text" "" ".font" $_asteriskAmountFontInfo ".size" $_asteriskAmountWidth ".side" "L" ".character1" "*" ".character2" "*" }]] \ ; } ::return [::sargs::get $Amount ".result"]; } method checkTextAmount {Src} { ::if {$_page_number==1} { ::set Format { .font {} .size -1 .fill { .left "*" .middle "" .right "*" } .text " %Units% %d%/100 " .currency { .unit { .symbol {$} .singular "dollar" .plural "dollars" } .decimal { .singular "cent" .plural "cents" } } }; ::sargs::var::set Format ".font" $_textAmountFontInfo; ::sargs::var::set Format ".size" $_textAmountWidth; ::if {$text_amount_format ne ""} { ::foreach FormatStructure [::qw::bob::check_text_amount_formats] { ::if {$text_amount_format eq [::sargs::get $FormatStructure ".sample"]} { ::sargs::var::+= Format [::sargs::get $FormatStructure ".format"]; ::break; } } } ::sargs::var::set Format ".currency.unit.symbol" $currency_symbol; ::if {[::llength $currency_name]==1} { ::sargs::var::set Format ".currency.unit.singular" $currency_name; ::sargs::var::set Format ".currency.unit.plural" "${currency_name}s"; } else { ::sargs::var::set Format ".currency.unit.singular" [::lindex $currency_name 0]; ::sargs::var::set Format ".currency.unit.plural" [::lindex $currency_name 1]; } ::if {[::llength $currency_fraction_name]==1} { ::sargs::var::set Format ".currency.decimal.singular" $currency_fraction_name; ::sargs::var::set Format ".currency.decimal.plural" "${currency_fraction_name}s"; } else { ::sargs::var::set Format ".currency.decimal.singular" [::lindex $currency_fraction_name 0]; ::sargs::var::set Format ".currency.decimal.plural" [::lindex $currency_fraction_name 1]; } ::set TextAmountStructure [::qw::bob::FormatCheckAmount $Src $Format]; ::if {!$_textAmountShrinkToFit} { ::set Size [::sargs::get $TextAmountStructure ".size"]; ::if {$Size>$_textAmountWidth} { ::set CheckNumber [[[$_reference odb_master] .reference] odb_get]; ::qw::throw [::sargs \ .text "[::format %.2f $Src] in words does not fit in the TXTAMOUNT template cell." \ .help_id 9070200620090510 \ .amount [::format %.2f $Src] \ .amount_in_words [::sargs::get $TextAmountStructure ".result"] \ .size_required [::format %.0f $Size] \ .size_available [::format %.0f $_textAmountWidth] \ .check_number $CheckNumber \ ]; } } } else { ::set TextAmountStructure \ [::qw::bob::PadText [::qw::list { ".text" "Void" ".font" $_textAmountFontInfo ".size" $_textAmountWidth ".side" "B" ".character1" " " ".character2" "-" }]] \ ; } ::return [::sargs::get $TextAmountStructure ".result"]; } } ::itcl::class ::qw::print::windows::template::test { inherit ::qw::print::windows::template; private variable _itemData ""; constructor {args} { ::eval ::qw::print::windows::template::constructor $args; } { ::unset -nocomplain _itemData;::array set _itemData {}; } destructor { } public method _TEMPLATE_TEST_DATA_METHOD {Name} { ::return $_itemData($Name); } public method init {} { chain; ::foreach Name [::concat $_headerNames $_itemNames] { ::array set RangeInfo [templateManagerCommand rangeInformationGet $Name]; ::set FontInfo $RangeInfo(-font); ::set Width [::sargs::get $RangeInfo(-size) ".x"]; ::set Data [::qw::bob::PadText [::list ".text" "" ".font" $FontInfo ".size" $Width ".side" "L" ".character1" "*" ".character2" "*"]]; ::set Text [::sargs::get $Data ".result"]; ::set _itemData($Name) $Text; } ::return $this; } public method documentStart {} { ::return [chain]; } public method documentEnd {} { ::return [chain]; } method itemStart {} { ::return [chain]; } method numberOfItemsSet {} { ::set _itemsToDo [templateManagerCommand itemAreaRows]; ::return $this; } method moreItemsQuery {} { ::return [chain]; } method nextItemLoad {} { ::return [chain]; } } ::itcl::class ::qw::print::windows::template::check { inherit ::qw::print::windows::template; protected variable _itemList ""; protected variable _payee ""; protected variable _checkAmount ""; protected variable _posting ""; protected variable _crossPosting ""; protected variable _item_account ""; protected variable _item_description ""; protected variable _item_amount ""; protected variable _item_balance ""; protected variable _item_year_to_date ""; protected variable _item_quantity ""; protected variable _item_rate ""; protected variable _journal_type ""; protected variable _sign_factor 1; constructor {args} { ::eval ::qw::print::windows::template::constructor $args; } { } destructor { } public method _CHECKAMOUNTASTERISK {s_args} {::return [checkAmountAsterisk $_checkAmount];} public method _CHECKAMOUNT {s_args} {::return [checkAmount $_checkAmount];} public method _TEXTAMOUNT {s_args} {::return [checkTextAmount $_checkAmount];} public method _CHECKNUMBER {s_args} { ::return [[[$_reference odb_master] ".reference"] odb_get]; } public method _CHECKDATE {s_args} {::return [[[$_reference odb_master] ".date"] odb_get];} public method _PAYEE {s_args} {::return $_payee;} public method _ADDRESS {s_args} {::return $_addressLines;} public method bank_account {s_args} { ::set BankAccount [[[$_reference odb_master] ".posting/credit.account"] odb_get]; ::if {$BankAccount eq "" \ ||[::string first "/OBJECT/NEWVIEWS/ACCOUNT/BANK" [$BankAccount odb_path]]!=0 \ } { ::set BankAccount [[[$_reference odb_master] ".posting/debit.account"] odb_get]; } ::return $BankAccount; } public method _BANKNAME {s_args} { ::set BankAccount [bank_account $s_args]; ::if {$BankAccount eq ""} { ::return ""; } ::return [[[$BankAccount odb_master] ".name"] odb_get]; } public method _BANKDESCRIPTION {s_args} { ::set BankAccount [bank_account $s_args]; ::if {$BankAccount eq ""} { ::return ""; } ::return [[[$BankAccount odb_master] ".description"] odb_get]; } public method _BANKID {s_args} { ::set BankAccount [bank_account $s_args]; ::if {$BankAccount eq ""} { ::return ""; } ::if {[::string first "/OBJECT/NEWVIEWS/ACCOUNT/BANK" [$BankAccount odb_path]]!=0} { ::return ""; } ::set BankEftSettings [::sargs::get [[[$BankAccount odb_master] ".structure_data"] qw_get] "/eft"]; ::if {[eft_settings_empty $BankEftSettings]} { ::set BankEftSettings [::sargs::get [[[$BankAccount odb_master] ".structure_data"] qw_get] "/eft_usa"]; } ::return [::sargs::get $BankEftSettings ".bank_id"]; } public method _BANKTRANSIT {s_args} { ::set BankAccount [bank_account $s_args]; ::if {$BankAccount eq ""} { ::return ""; } ::if {[::string first "/OBJECT/NEWVIEWS/ACCOUNT/BANK" [$BankAccount odb_path]]!=0} { ::return ""; } ::set BankEftSettings [::sargs::get [[[$BankAccount odb_master] ".structure_data"] qw_get] "/eft"]; ::if {[eft_settings_empty $BankEftSettings]} { ::set BankEftSettings [::sargs::get [[[$BankAccount odb_master] ".structure_data"] qw_get] "/eft_usa"]; } ::return [::sargs::get $BankEftSettings ".bank_transit"]; } public method _BANKACCOUNT {s_args} { ::set BankAccount [bank_account $s_args]; ::if {$BankAccount eq ""} { ::return ""; } ::if {[::string first "/OBJECT/NEWVIEWS/ACCOUNT/BANK" [$BankAccount odb_path]]!=0} { ::return ""; } ::set BankEftSettings [::sargs::get [[[$BankAccount odb_master] ".structure_data"] qw_get] "/eft"]; ::if {[eft_settings_empty $BankEftSettings]} { ::set BankEftSettings [::sargs::get [[[$BankAccount odb_master] ".structure_data"] qw_get] "/eft_usa"]; } ::return [::sargs::get $BankEftSettings ".bank_account"]; } public method _CURRENCYTYPE {s_args} { ::set BankAccount [bank_account $s_args]; ::if {$BankAccount eq ""} { ::return ""; } ::if {[::string first "/OBJECT/NEWVIEWS/ACCOUNT/BANK" [$BankAccount odb_path]]!=0} { ::return ""; } ::set BankEftSettings [::sargs::get [[[$BankAccount odb_master] ".structure_data"] qw_get] "/eft"]; ::if {[eft_settings_empty $BankEftSettings]} { ::set BankEftSettings [::sargs::get [[[$BankAccount odb_master] ".structure_data"] qw_get] "/eft_usa"]; } ::return [::sargs::get $BankEftSettings ".currency_type"]; } public method _MICR {s_args} { ::set BankId [_BANKID $s_args]; ::set BankId [::string range $BankId [::expr {[::string length $BankId]-3}] end]; ::set BankTransit [_BANKTRANSIT $s_args]; ::set BankAccount [_BANKACCOUNT $s_args]; ::set BankChequeNumber [_CHECKNUMBER $s_args]; ::set BankChequeNumber [::format "%06s" $BankChequeNumber]; ;#// 6 characters wide with leading zeros ::set CurrencyType [_CURRENCYTYPE $s_args]; ;#//nv2.28.4 - MICR ::set Result "C${BankChequeNumber}C A${BankTransit}D${BankId}A "; ::switch -exact -- $BankId { "001" { ::set BankAccount "[::string range $BankAccount 0 3]D[::string range $BankAccount 4 8]"; } "002" { ::set BankAccount "[::string range $BankAccount 0 4]D[::string range $BankAccount 5 6]"; } "003" { ::set BankAccount "[::string range $BankAccount 0 2]D[::string range $BankAccount 3 5]D[::string range $BankAccount 6 6]"; } "004" { ::set BankAccount "[::string range $BankAccount 0 3]D[::string range $BankAccount 4 10]"; } "006" { ::set BankAccount "[::string range $BankAccount 0 1]D[::string range $BankAccount 2 4]D[::string range $BankAccount 5 6]"; } "010" { ::set BankAccount "[::string range $BankAccount 0 1]D[::string range $BankAccount 2 6]"; } "016" { ::set BankAccount "[::string range $BankAccount 0 5]D[::string range $BankAccount 6 8]"; } default { ::qw::throw [::sargs \ .text "MICR cheque encoding encountered unknown Bank Id \"$BankId\"." \ .help_id 271820051209113140 ]; } } ::append Result "${BankAccount}C"; ::if {$CurrencyType eq "USD"} { ::append Result " 45 "; ;#//nv2.28.4 - MICR - 4 leading spaces and 1 trailing } ::return $Result } method eft_settings_empty {s_args} { ::if {$s_args eq ""} { ::return 1; } ::foreach Path [::sargs::select_all .structure $s_args] { ::if {[::sargs::get $s_args $Path] ne ""} { ::return 0; } } ::return 1; } public method _EBANKID {s_args} { ::if {[::string first "/OBJECT/NEWVIEWS/SYSTEM/TRANSACTION/PAYROLL/PAYCHECK" [$_reference odb_path]]!=0} { ::return ""; } ::set Employee [[[$_reference odb_master] ".employee"] odb_get]; ::if {$Employee eq ""} { ::return ""; } ::return [::sargs::get [[[$Employee odb_master] ".structure_data"] qw_get] "/eft.bank_id"]; } public method _EBANKTRANSIT {s_args} { ::if {[::string first "/OBJECT/NEWVIEWS/SYSTEM/TRANSACTION/PAYROLL/PAYCHECK" [$_reference odb_path]]!=0} { ::return ""; } ::set Employee [[[$_reference odb_master] ".employee"] odb_get]; ::if {$Employee eq ""} { ::return ""; } ::return [::sargs::get [[[$Employee odb_master] ".structure_data"] qw_get] "/eft.bank_transit"]; } public method _EBANKACCOUNT {s_args} { ::if {[::string first "/OBJECT/NEWVIEWS/SYSTEM/TRANSACTION/PAYROLL/PAYCHECK" [$_reference odb_path]]!=0} { ::return ""; } ::set Employee [[[$_reference odb_master] ".employee"] odb_get]; ::if {$Employee eq ""} { ::return ""; } ::return [::sargs::get [[[$Employee odb_master] ".structure_data"] qw_get] "/eft.bank_account"]; } public method _PPSTARTDATE {s_args} { ::if {[::string first "/OBJECT/NEWVIEWS/SYSTEM/TRANSACTION/PAYROLL/PAYCHECK" [$_reference odb_path]]!=0} { ::return ""; } ::set Payrun [[[$_reference odb_master] ".payrun"] odb_get]; ::if {$Payrun eq ""} { ::return ""; } ::return [[[$Payrun odb_master] ".pay_period_start"] odb_get]; } public method _PPENDDATE {s_args} { ::if {[::string first "/OBJECT/NEWVIEWS/SYSTEM/TRANSACTION/PAYROLL/PAYCHECK" [$_reference odb_path]]!=0} { ::return ""; } ::set Payrun [[[$_reference odb_master] ".payrun"] odb_get]; ::if {$Payrun eq ""} { ::return ""; } ::return [[[$Payrun odb_master] ".pay_period_end"] odb_get]; } public method _ITEM_ACCOUNT {s_args} { ::return $_item_account; } public method _ITEM_DESCRIPTION {s_args} {::return $_item_description;} public method _ITEM_AMOUNT {s_args} {::return $_item_amount;} public method _ITEM_BALANCE {s_args} {::return $_item_balance;} public method _ITEM_QUANTITY {s_args} {::return $_item_quantity;} public method _ITEM_RATE {s_args} {::return $_item_rate;} public method _ITEM_YTD {s_args} {::return $_item_year_to_date;} public method init {} { chain; ::return $this; } public method documentStart {} { [$_reference odb_database] cpp_tcp_signals_process; ::set _journal_type [[$_reference odb_master] odb_path]; ::set _checkAmount [[[$_reference odb_master] ".posting/credit.amount"] odb_get]; ::if {$_checkAmount eq ""} { ::set _checkAmount 0; } ::qw::number::var::negative _checkAmount; ::set _sign_factor 1; ::if {[::string first "/OBJECT/NEWVIEWS/SYSTEM/TRANSACTION/GENERAL" $_journal_type]==0 \ ||[::string first "/OBJECT/NEWVIEWS/SYSTEM/TRANSACTION/BANK/PAYMENT" $_journal_type]==0 \ } { ::if {$_checkAmount<0} { ::set _sign_factor -1; } } ::set _checkAmount [::expr $_checkAmount*$_sign_factor] addressSourceSet; address_load; chain; ::return $this; } public method documentEnd {} { ::return [chain]; } method nextItemLoad {} { chain; ::if {$_itemList eq ""} { ::qw::throw "Ran off the end of the items."; } itemValuesSet [::lindex $_itemList 0]; ::set _itemList [::lrange $_itemList 1 end]; ::return $this; } method itemValuesSet {s_args} { ::set _item_master [::sargs::get $s_args ".master"]; ::set _item_account [::sargs::get $s_args ".account"]; ::set _item_description [::sargs::get $s_args ".description"]; ::set _item_amount [::sargs::get $s_args ".amount"]; ::set _item_balance [::sargs::get $s_args ".balance"]; ::set _item_quantity [::sargs::get $s_args ".quantity"]; ::set _item_rate [::sargs::get $s_args ".rate"]; ::set _item_year_to_date [::sargs::get $s_args ".year_to_date"]; ::return $this; } method addressSourceSet {} { ::set _addressSource ""; ::set Master [$_reference odb_master]; ::set Source ""; ::if {$::qw::control(pay_to_address_is_enabled)} { } ::switch -glob -- $_journal_type { /OBJECT/NEWVIEWS/SYSTEM/TRANSACTION/SALES* { ::set Source [[$Master ".posting/debit/customer.account"] odb_get]; } /OBJECT/NEWVIEWS/SYSTEM/TRANSACTION/PURCHASE* { ::set Source [[$Master ".posting/credit.account"] odb_get]; ::set Pto [[$Master .pay_to_address] odb_get]; ::if {$Pto ne ""&&[[$Master odb_database] cpp_find_from_address $Pto] ne ""} { ::set Source $Pto; } } /OBJECT/NEWVIEWS/SYSTEM/TRANSACTION/PAYROLL* { ::set Source [[$Master ".employee"] odb_get]; } /OBJECT/NEWVIEWS/SYSTEM/TRANSACTION/GENERAL* { ::set DebitAccountRef [[$Master ".posting/debit.account"] odb_get]; ::if {$DebitAccountRef ne ""} { ::if {[::string first /OBJECT/NEWVIEWS/ACCOUNT/BANK [[$DebitAccountRef odb_master] odb_path]]>=0} { ::set CreditAccountRef [[$Master ".posting/credit.account"] odb_get]; ::if {$CreditAccountRef ne ""} { ::set Source $CreditAccountRef; } } else { ::set Source $DebitAccountRef; } } } /OBJECT/NEWVIEWS/SYSTEM/TRANSACTION/BANK/PAYMENT* { ::set Source [[$Master ".posting/debit.account"] odb_get]; ::set Pto [[$Master .pay_to_address] odb_get]; ::if {$Pto ne ""&&[[$Master odb_database] cpp_find_from_address $Pto] ne ""} { ::set Source $Pto; } } default { ::set Source [[$Master ".posting/debit.account"] odb_get]; } } ::if {$Source ne ""} { ::set _addressSource [$Source odb_master]; ::return; } ::set Index [$Master ".odb_deriveds.index/interactive"]; ::for {::set Ref [$Index odb_first];} {$Ref ne ""} {::set Ref [$Index odb_next $Ref];} { ::set Source [[[$Ref odb_master] ".posting/debit.account"] qw_get]; ::if {$Source ne ""} { ::set _addressSource [$Source odb_master]; ::return; } } ::for {::set Ref [$Index odb_first];} {$Ref ne ""} {::set Ref [$Index odb_next $Ref];} { ::set Source [[[$Ref odb_master] ".posting/credit.account"] qw_get]; ::if {$Source ne ""} { ::set _addressSource [$Source odb_master]; ::return; } } } method transactionClass {Src} { ::foreach Class {GENERAL BANK/DEPOSIT BANK/PAYMENT PURCHASE SALES PAYROLL} { ::if {[$Src odb_is_a [[database_Get] "/OBJECT/NEWVIEWS/SYSTEM/TRANSACTION/$Class"]]} { ::return $Class; } } ::return ""; } method numberOfItemsSet {} { ::set _itemList ""; ::set _itemsToDo 0; ::set RunningBalance 0.0; ::set Transaction [$_reference odb_master]; ::set TransactionClass [transactionClass $Transaction]; ::switch -- $TransactionClass { GENERAL - BANK/DEPOSIT - BANK/PAYMENT - PAYROLL { ::if {[[$Transaction ".posting/credit.account"] odb_get] ne ""} { ::set AmountPath "debit" ::set AccountPath "debit" } else { ::set AmountPath "credit" ::set AccountPath "credit" } } PURCHASE { ::if {[[$Transaction ".posting/credit.account"] odb_get] ne ""} { ::set AmountPath "debit" ::set AccountPath "debit/charge" } else { ::set AmountPath "credit" ::set AccountPath "credit" } } SALES { ::if {[[$Transaction ".posting/debit/customer.account"] odb_get] ne ""} { ::set AmountPath "debit" ::set AccountPath "debit" } else { ::set AmountPath "credit" ::set AccountPath "credit" } } } ::set Index [$Transaction ".odb_deriveds.index/interactive"]; ::for {::set Ref [$Index odb_first];} {$Ref ne ""} {::set Ref [$Index odb_next $Ref];} { ::set Master [$Ref odb_master]; ::set Item ""; ::sargs::var::set Item ".master" $Master; ::sargs::var::set Item ".description" [[$Master ".description"] odb_get]; ::sargs::var::set Item ".quantity" [[$Master ".posting/$AmountPath.quantity"] odb_get]; ::sargs::var::set Item ".rate" [[$Master ".posting/$AmountPath.rate"] odb_get]; ::set ItemAmount ""; ::set ItemBalance ""; ::set ItemYTD ""; ::set Account [[$Master ".posting/$AccountPath.account"] odb_get]; ::if {$Account ne ""} { ::sargs::var::set Item ".account" [[[$Account odb_master] ".name"] odb_get]; ::set ItemAmount [[$Master ".posting/$AmountPath.amount"] odb_get]; ::if {$AmountPath eq "credit"} {::qw::number::var::negative ItemAmount;} ::set ItemAmount [::expr $ItemAmount*$_sign_factor]; ::set RunningBalance [::qw::number::add $RunningBalance $ItemAmount]; ::set ItemBalance $RunningBalance; ::if {[::lsearch -exact $_itemNames "ITEM_YTD"]>=0} { ::if {$_addressSource ne ""} { ::if {[::string first "/OBJECT/NEWVIEWS/SYSTEM/EMPLOYEE" [$_addressSource odb_path]]==0} { ::set ItemYTD [year_to_date_amount [::sargs .account [$Account odb_master] .date [_CHECKDATE dummy_s_args]]]; ::if {[[$Account odb_master] normal_balance_get] eq "credit"} { ::set ItemYTD [::qw::number::negative $ItemYTD]; } } } } } ::sargs::var::set Item ".amount" $ItemAmount; ::sargs::var::set Item ".balance" $ItemBalance; ::sargs::var::set Item ".year_to_date" $ItemYTD; ::lappend _itemList $Item; ::if {$RunningBalance==$_checkAmount} {::break;} } ::set _itemsToDo [::llength $_itemList]; ::return $this; } method year_to_date_amount {s_args} { ::set Account [::sargs::get $s_args ".account"]; ::set Date [::sargs::get $s_args ".date"]; ::if {[::qw::date::is_null $Date]} {::return "";} ::set Year [::qw::date::get $Date "year"]; ::set Begin $Date; ::set Begin [::qw::date::set $Begin "month" "1"]; ::set Begin [::qw::date::set $Begin "day" "1"]; ::set End $Date; ::set Index [$Account ".postings.index/date"]; ::set Range [::qw::odb::factory range]; ::qw::finally [::list $Range cpp_destroy]; $Range cpp_configure -index $Index -begin [::list .tag financial .date $Begin] -end [::list .tag financial .date $End]; ::return [[$Range odb_master] history_file_odb_total [::sargs .range $Range .rb_name .amount .priority foreground]]; } method moreItemsQuery {} { ::return [chain]; } method itemStart {} { ::return [chain]; ;#// base resets _itemInfo to NULL } public method address_load {} { ::set _payee ""; ::set _addressLines ""; ::if {$_addressSource eq ""} { ::return $this; } ::if {[::lsearch -exact $_headerNames "ADDRESS"]<0 \ &&[::lsearch -exact $_headerNames "PAYEE"]<0 \ } { ::return $this; } ::set _addressLines [address_printable [$_addressSource ".address"]]; ::if {[::string first "/OBJECT/NEWVIEWS/SYSTEM/EMPLOYEE" [$_addressSource odb_path]]==0} { ::set _payee [[$_addressSource ".employee_name.print_as"] odb_get]; } else { ::set _payee [[$_addressSource ".address.company"] odb_get]; } ::if {$_payee eq ""} { ::set _payee [[[$_reference odb_master] ".description"] odb_get]; } ::return $this; } } ::itcl::class ::qw::print::windows::template::check::ap { inherit ::qw::print::windows::template::check; protected variable _item_date ""; protected variable _item_discount 0.0; protected variable _item_paid 0.0; protected variable _item_age 0; protected variable _discount 0.0; protected variable _item_posting_reference ""; ;#// for cross_account_get lookup protected variable _item_amount_debit ""; protected variable _item_amount_debit_charge ""; protected variable _item_amount_debit_tax1 ""; protected variable _item_amount_debit_tax2 ""; constructor {args} { ::eval ::qw::print::windows::template::check::constructor $args; } { } destructor { } public method _ITEM_ACCOUNT {s_args} { ::if {$::qw::control(print_check_ap_with_paid_invoices_detail_items)} { } ::if {$_item_account ne ""} { ::return [[[$_item_account odb_master] .name] odb_get]; } ::if {$_addressSource eq ""} { ::return ""; } ::return [[$_addressSource ".name"] odb_get]; } public method _ITEM_CROSSACCOUNT {s_args} { ::if {$_item_master ne "" \ &&$_item_posting_reference ne "" \ } { ::set Xaccount [$_item_master cross_account_get [::sargs .posting_reference $_item_posting_reference]]; ::if {$Xaccount ne ""} { ::return [[$Xaccount .description] odb_get]; ::return [[$Xaccount .name] odb_get]; } } ::return ""; } public method _DISCOUNT {s_args} {::return $_discount;} public method _ITEM_DATE {s_args} {::return $_item_date;} public method _ITEM_REF {s_args} {::return $_item_reference;} public method _ITEM_DISCOUNT {s_args} {::return $_item_discount;} public method _ITEM_PAID {s_args} {::return $_item_paid;} public method _ITEM_AGE {s_args} {::return $_item_age;} public method documentStart {} { ::set _discount 0.0; ::return [chain]; } method itemStart {} { chain; ;#// base resets _itemInfo to NULL ::return $this; } method nextItemLoad {} { ::set Result [chain]; ::return $Result; } method numberOfItemsSet {} { ::set _itemsToDo 0; ::set _itemList ""; ::set ClientData [[[$_reference odb_master] ".clientdata"] odb_get]; ::if {![::sargs::exists $ClientData ".paylist"]} { ::return $this; } ::set PayList [::sargs::get $ClientData ".paylist"]; ::set Paylist [::sargs::get $PayList ".newviews.prtpay.paylist"]; ::set RunningBalance 0.0; ::foreach Sub [::sargs::subs .structure $Paylist] { ::set Item [::sargs::get $Paylist $Sub]; ::set Discount [::sargs::get $Item ".discount"]; ::set Pay_Amount [::sargs::get $Item ".pay_amount"]; ::if {$Pay_Amount==0.0&&$Discount==0.0} {::continue;} ::if {$Sub eq "/total"} {::continue;} ::set _discount [::qw::number::add $_discount $Discount]; ::set RunningBalance [::qw::number::add $RunningBalance $Pay_Amount]; ::sargs::var::set Item ".balance" $RunningBalance; ::lappend _itemList $Item; ::if {$::qw::control(print_check_ap_with_paid_invoices_detail_items)} { ::foreach Dsub [::sargs::subs .structure [::sargs::get $Paylist $Sub]] { ::set Ditem [::sargs::get $Paylist $Sub$Dsub]; ::lappend _itemList $Ditem; } } } ::set _itemsToDo [::llength $_itemList]; ::return $this; } method moreItemsQuery {} { ::return [chain]; } method itemValuesSet {s_args} { chain $s_args; ::set _item_master [::sargs::get $s_args ".odb_address"]; ::set _item_date [::sargs::get $s_args ".date"]; ::set _item_posting_reference ""; ::if {$_item_date ne ""} { ::set _item_posting_reference [::sargs::get $s_args .posting]; } ::if {$::qw::control(print_check_ap_with_paid_invoices_detail_items)} { ::if {[::sargs::exists $s_args .posting/debit/charge.account]} { ::set _item_account [::sargs::get $s_args .posting/debit/charge.account]; ::set _item_amount [::sargs::get $s_args .posting/debit.amount]; } } ::set _item_reference [::sargs::get $s_args ".reference"]; ::set _item_discount [::sargs::get $s_args ".discount"]; ::set _item_paid [::sargs::get $s_args ".pay_amount"]; ::set _item_age [::sargs::get $s_args ".age"]; ::return $this; } public method _EBANKID {s_args} { ::if {[::string first "/OBJECT/NEWVIEWS/SYSTEM/TRANSACTION/BANK/PAYMENT" [$_reference odb_path]]!=0} { ::return ""; } ::set Receiver [eft_receiver [$_reference odb_master]]; ::if {$Receiver eq ""} { ::return ""; } ::return [::sargs::get [[$Receiver ".structure_data"] qw_get] "/eft.bank_id"]; } public method _EBANKTRANSIT {s_args} { ::if {[::string first "/OBJECT/NEWVIEWS/SYSTEM/TRANSACTION/BANK/PAYMENT" [$_reference odb_path]]!=0} { ::return ""; } ::set Receiver [eft_receiver [$_reference odb_master]]; ::if {$Receiver eq ""} { ::return ""; } ::return [::sargs::get [[$Receiver ".structure_data"] qw_get] "/eft.bank_transit"]; } public method _EBANKACCOUNT {s_args} { ::if {[::string first "/OBJECT/NEWVIEWS/SYSTEM/TRANSACTION/BANK/PAYMENT" [$_reference odb_path]]!=0} { ::return ""; } ::set Receiver [eft_receiver [$_reference odb_master]]; ::if {$Receiver eq ""} { ::return ""; } ::return [::sargs::get [[$Receiver ".structure_data"] qw_get] "/eft.bank_account"]; } public method eft_receiver {Transaction} { ::set Receiver [[[$Transaction odb_master] ".posting/debit.account"] odb_get]; ::if {$Receiver ne ""} { ::set Receiver [$Receiver odb_master]; } else { ::set FirstDist [[[$Transaction odb_master] ".odb_deriveds.index/interactive"] odb_first]; ::if {$FirstDist ne ""} { ::set FirstDistDebit [[[$FirstDist odb_master] ".posting/debit.account"] odb_get]; ::if {$FirstDistDebit ne ""} { ::set Receiver [$FirstDistDebit odb_master]; } } } ::if {$Receiver eq ""} { ::return ""; } ::if {[::string first "/OBJECT/NEWVIEWS/ACCOUNT/AP" [$Receiver odb_path]]!=0} { ::return ""; } ::return [$Receiver odb_master]; } } ::itcl::class ::qw::print::windows::template::check::pay { inherit ::qw::print::windows::template::check; protected variable _report_codes ""; protected variable _employee ""; protected variable _vacation_amounts ""; constructor {args} { ::eval ::qw::print::windows::template::check::constructor $args; ::set _employee ""; ::catch {::unset _name_path_array;};::array set _name_path_array {}; ::catch {::unset _report_codes_array;};::array set _report_codes_array {}; ::catch {::unset _employee_earnings_array;};::array set _employee_earnings_array {}; } { } destructor { } public method _ENAME {args} {::return [[$_employee ".employee_name.print_as"] odb_get];} public method _EFNAME {args} {::return [[$_employee ".employee_name.first"] odb_get];} public method _EMNAME {args} {::return [[$_employee ".employee_name.middle"] odb_get];} public method _ELNAME {args} {::return [[$_employee ".employee_name.last"] odb_get];} public method _EID {args} {::return [[$_employee ".employee_id"] odb_get];} public method _ESSN {args} { ::if {![$_employee odb_is_a [[$_employee odb_database] "/OBJECT/NEWVIEWS/SYSTEM/EMPLOYEE/USA"]]} {::return "";} ::return [[$_employee ".social_security_number"] odb_get]; } public method _ESIN {args} { ::if {![$_employee odb_is_a [[$_employee odb_database] "/OBJECT/NEWVIEWS/SYSTEM/EMPLOYEE/CANADA"]]} {::return "";} ::return [[$_employee ".social_insurance_number"] odb_get]; } public method _VACYE {s_args} {::return [::sargs::get $_vacation_amounts ".earned/year_to_date"];} public method _VACYP {s_args} {::return [::sargs::get $_vacation_amounts ".paid/year_to_date"];} public method _VACYO {s_args} {::return [::sargs::get $_vacation_amounts ".owed/year_to_date"];} public method _VACE {s_args} {::return [::sargs::get $_vacation_amounts ".earned/perpetual"];} public method _VACP {s_args} {::return [::sargs::get $_vacation_amounts ".paid/perpetual"];} public method _VACO {s_args} {::return [::sargs::get $_vacation_amounts ".owed/perpetual"];} public method _CPPEX {s_args} {::return [total_data_request ".name CPPEX .period period"];} public method _CPPE {s_args} {::return [total_data_request ".name CPPE .period period"];} public method _EIE {s_args} {::return [total_data_request ".name EIE .period period"];} public method _EIH {s_args} {::return [total_data_request ".name EIH .period period"];} public method _PPIPE {s_args} {::return [total_data_request ".name PPIPE .period period"];} public method _HSFE {s_args} {::return [total_data_request ".name HSFE .period period"];} public method _NCTB1 {s_args} {::return [total_data_request ".name NCTB1 .period period"];} public method _NCTB2 {s_args} {::return [total_data_request ".name NCTB2 .period period"];} public method _NCTB3 {s_args} {::return [total_data_request ".name NCTB3 .period period"];} public method _NCTB4 {s_args} {::return [total_data_request ".name NCTB4 .period period"];} public method _YCPPEX {s_args} { ::set Whatever [total_data_request ".name YCPPEX .period year_to_date"]; ::return [total_data_request ".name YCPPEX .period year_to_date"]; } public method _YCPPE {s_args} {::return [total_data_request ".name YCPPE .period year_to_date"];} public method _YEIE {s_args} {::return [total_data_request ".name YEIE .period year_to_date"];} public method _YEIH {s_args} {::return [total_data_request ".name YEIH .period year_to_date"];} public method _YPPIPE {s_args} {::return [total_data_request ".name YPPIPE .period year_to_date"];} public method _YHSFE {s_args} {::return [total_data_request ".name YHSFE .period year_to_date"];} public method _YNCTB1 {s_args} {::return [total_data_request ".name YNCTB1 .period year_to_date"];} public method _YNCTB2 {s_args} {::return [total_data_request ".name YNCTB2 .period year_to_date"];} public method _YNCTB3 {s_args} {::return [total_data_request ".name YNCTB3 .period year_to_date"];} public method _YNCTB4 {s_args} {::return [total_data_request ".name YNCTB4 .period year_to_date"];} public method _PCPPEX {s_args} {::return [total_data_request ".name PCPPEX .period perpetual"];} public method _PCPPE {s_args} {::return [total_data_request ".name PCPPE .period perpetual"];} public method _PEIE {s_args} {::return [total_data_request ".name PEIE .period perpetual"];} public method _PEIH {s_args} {::return [total_data_request ".name PEIH .period perpetual"];} public method _PPPIPE {s_args} {::return [total_data_request ".name PPPIPE .period perpetual"];} public method _PHSFE {s_args} {::return [total_data_request ".name PHSFE .period perpetual"];} public method _PNCTB1 {s_args} {::return [total_data_request ".name PNCTB1 .period perpetual"];} public method _PNCTB2 {s_args} {::return [total_data_request ".name PNCTB2 .period perpetual"];} public method _PNCTB3 {s_args} {::return [total_data_request ".name PNCTB3 .period perpetual"];} public method _PNCTB4 {s_args} {::return [total_data_request ".name PNCTB4 .period perpetual"];} public method _SSE {s_args} {::return [total_data_request ".name SSE .period period"];} public method _ME {s_args} {::return [total_data_request ".name ME .period period"];} public method _FE {s_args} {::return [total_data_request ".name FE .period period"];} public method _YSSE {s_args} {::return [total_data_request ".name YSSE .period year_to_date"];} public method _YME {s_args} {::return [total_data_request ".name YME .period year_to_date"];} public method _YFE {s_args} {::return [total_data_request ".name YFE .period year_to_date"];} public method _PSSE {s_args} {::return [total_data_request ".name PSSE .period perpetual"];} public method _PME {s_args} {::return [total_data_request ".name PME .period perpetual"];} public method _PFE {s_args} {::return [total_data_request ".name PFE .period perpetual"];} public method init {} { ::qw::throw "::template::check::pay init enter - please contact Q.W. Page technical support to report this event"; chain; ::set _report_codes [[[database_Get] "/OBJECT/NEWVIEWS/PAYROLL.payroll_report_control"] odb_get]; ::return $this; } public method documentStart {} { ::return [chain]; ::set _vacation_amounts ""; ::foreach Name $_headerNames { ::if {[::string range $Name 0 2] ne "VAC"} {::continue;} ::set _vacation_amounts [$_employee vacation_amount [::qw::date::get [_CHECKDATE dummy_s_args] "year"]];; ::return; } } method itemStart {} { chain; ::return $this; } method nextItemLoad {} { ::return [chain]; } method addressSourceSet {} { chain; ::set _employee ""; ::if {$_addressSource eq ""} { ::return; } ::set _employee $_addressSource; } method numberOfItemsSet {} { chain; ::return $this; } public method total_data_request {s_args} { ::set Name [::sargs::get $s_args ".name"]; ::if {![::info exists _name_path_array($Name)]} {::return "";} ::set Paths $_name_path_array($Name); ::set Expression ""; ::if {[::info exists _expression_array($Name)]} { ::set Expression $_expression_array($Name); ::set Result [amount_get [::sargs \ .expression $Expression \ .amount_type "total" \ .paths $Paths \ ]]; } else { ::set Result 0.0; ::foreach Path $Paths { ::set Amount [::sargs::get $_report_total_structure $Path]; ::set Result [::qw::number::add $Result $Amount]; } } ::return $Result; } } ::itcl::class ::qw::print::windows::template::payroll_report { inherit ::qw::print::windows::template; public variable employee_list "" {load_employees_earnings}; public variable settings "" {build_earnings_mask}; public variable payroll ""; protected variable _report_codes ""; protected variable _employee ""; protected variable _earnings_mask ""; protected variable _employee_earnings_structure ""; protected variable _earnings_detail_list ""; protected variable _earnings_detail_structure ""; protected variable _employee_total_structure ""; protected variable _report_total_structure ""; protected variable _expression_array ""; protected variable _begin ""; protected variable _end ""; protected variable _details "0"; protected variable _item_journal ""; protected variable _item_date ""; protected variable _item_description ""; protected variable _name_path_array ""; protected variable _report_codes_array ""; protected variable _employee_earnings_array ""; protected variable _employee_subtotal_done 0; protected variable _employee_subtotal_in_progress 0; protected variable _employee_line_count 0; protected variable _payroll ""; protected variable _journal_type ""; protected variable _item_transaction ""; constructor {args} { ::eval ::qw::print::windows::template::constructor $args; } { ::set _employee ""; ::catch {::unset _name_path_array;};::array set _name_path_array {}; ::catch {::unset _report_codes_array;};::array set _report_codes_array {}; ::catch {::unset _employee_earnings_array;};::array set _employee_earnings_array {}; } destructor { } public method _BEGINDATE {args} { ::return [::sargs::get $settings ".begin_date"]; } public method _ENDDATE {args} {::return [::sargs::get $settings ".end_date"];} public method _TITLE {args} {::return [::sargs::get $settings ".title"];} public method _CHECKDATE {s_args} { ::if {$_item_transaction eq ""} { ::return ""; } ::return [[$_item_transaction .date] odb_get]; } public method _CHECKAMOUNTASTERISK {s_args} { ::if {$_item_transaction eq ""} { ::return ""; } ::return [checkAmountAsterisk [::qw::number::negative [[$_item_transaction .posting/credit.amount] odb_get]]]; } public method _CHECKAMOUNT {s_args} { ::if {$_item_transaction eq ""} { ::return ""; } ::return [checkAmount [::qw::number::negative [[$_item_transaction .posting/credit.amount] odb_get]]]; } public method _TEXTAMOUNT {s_args} { ::if {$_item_transaction eq ""} { ::return ""; } ::return [checkTextAmount [::qw::number::negative [[$_item_transaction .posting/credit.amount] odb_get]]]; } public method _JOURNAL {args} { ::if {$_employee_subtotal_in_progress} {::return "";} ::return $_item_journal; } public method _DATE {args} { ::if {$_employee_subtotal_in_progress} {::return "";} ::return $_item_date; } public method _REF {args} { ::if {$_employee_subtotal_in_progress} {::return "";} ::return $_item_reference; } public method _DESCRIPTION {args} { ::if {$_employee_subtotal_in_progress} {::return "";} ::return $_item_description; } public method _PNAME {args} { ::if {$_employee_line_count>0} {::return "";} ::return [[[[[$_employee ".payroll"] odb_get] odb_master] ".name"] odb_get]; } public method _PDESCRIPTION {args} { ::if {$_employee_line_count>0} {::return "";} ::return [[[[[$_employee ".payroll"] odb_get] odb_master] ".description"] odb_get]; } public method _EACTIVE {args} { ::if {$_employee_line_count>0} {::return "";} ::return [[$_employee ".active"] odb_get]; } public method _ENAME {args} { ::if {$_employee_line_count>0} {::return "";} ::return [[$_employee ".employee_name.print_as"] odb_get]; } public method _EFNAME {args} { ::if {$_employee_line_count>0} {::return "";} ::return [[$_employee ".employee_name.first"] odb_get]; } public method _EMNAME {args} { ::if {$_employee_line_count>0} {::return "";} ::return [[$_employee ".employee_name.middle"] odb_get]; } public method _ELNAME {args} { ::if {$_employee_line_count>0} {::return "";} ::return [[$_employee ".employee_name.last"] odb_get]; } public method _EID {args} { ::if {$_employee_line_count>0} {::return "";} ::return [[$_employee ".employee_id"] odb_get]; } public method _ESSN {args} { ::if {$_employee_line_count>0} {::return "";} ::if {![$_employee odb_is_a [[$_employee odb_database] "/OBJECT/NEWVIEWS/SYSTEM/EMPLOYEE/USA"]]} {::return "";} ::return [[$_employee ".social_security_number"] odb_get]; } public method _ESIN {args} { ::if {$_employee_line_count>0} {::return "";} ::if {![$_employee odb_is_a [[$_employee odb_database] "/OBJECT/NEWVIEWS/SYSTEM/EMPLOYEE/CANADA"]]} {::return "";} ::return [[$_employee ".social_insurance_number"] odb_get]; } public method _EDEPOSIT {s_args} { ::if {$_employee_line_count>0} {::return "";} ::return [::sargs::get [[$_employee ".structure_data"] qw_get] "/eft.status"]; } public method _EBANKID {s_args} { ::if {$_employee_line_count>0} {::return "";} ::return [::sargs::get [[$_employee ".structure_data"] qw_get] "/eft.bank_id"]; } public method _EBANKTRANSIT {s_args} { ::if {$_employee_line_count>0} {::return "";} ::return [::sargs::get [[$_employee ".structure_data"] qw_get] "/eft.bank_transit"]; } public method _EBANKACCOUNT {s_args} { ::if {$_employee_line_count>0} {::return "";} ::return [::sargs::get [[$_employee ".structure_data"] qw_get] "/eft.bank_account"]; } public method _ITEM_JOURNAL {args} { ::if {$_employee_subtotal_in_progress} {::return "";} ::return $_item_journal; } public method _ITEM_DATE {args} { ::if {$_employee_subtotal_in_progress} {::return "";} ::return $_item_date; } public method _ITEM_REF {args} { ::if {$_employee_subtotal_in_progress} {::return "";} ::return $_item_reference; } public method _ITEM_DESCRIPTION {args} { ::if {$_employee_subtotal_in_progress} {::return "";} ::return $_item_description; } public method _ITEM_PNAME {args} { ::if {$_employee_line_count>0} {::return "";} ::return [[[[[$_employee ".payroll"] odb_get] odb_master] ".name"] odb_get]; } public method _ITEM_PDESCRIPTION {args} { ::if {$_employee_line_count>0} {::return "";} ::return [[[[[$_employee ".payroll"] odb_get] odb_master] ".description"] odb_get]; } public method _ITEM_EACTIVE {args} { ::if {$_employee_line_count>0} {::return "";} ::return [[$_employee ".active"] odb_get]; } public method _ITEM_ENAME {args} { ::if {$_employee_line_count>0} {::return "";} ::return [[$_employee ".employee_name.print_as"] odb_get]; } public method _ITEM_EFNAME {args} { ::if {$_employee_line_count>0} {::return "";} ::return [[$_employee ".employee_name.first"] odb_get]; } public method _ITEM_EMNAME {args} { ::if {$_employee_line_count>0} {::return "";} ::return [[$_employee ".employee_name.middle"] odb_get]; } public method _ITEM_ELNAME {args} { ::if {$_employee_line_count>0} {::return "";} ::return [[$_employee ".employee_name.last"] odb_get]; } public method _ITEM_EID {args} { ::if {$_employee_line_count>0} {::return "";} ::return [[$_employee ".employee_id"] odb_get]; } public method _ITEM_ESSN {args} { ::if {$_employee_line_count>0} {::return "";} ::if {![$_employee odb_is_a [[$_employee odb_database] "/OBJECT/NEWVIEWS/SYSTEM/EMPLOYEE/USA"]]} {::return "";} ::return [[$_employee ".social_security_number"] odb_get]; } public method _ITEM_ESIN {args} { ::if {$_employee_line_count>0} {::return "";} ::if {![$_employee odb_is_a [[$_employee odb_database] "/OBJECT/NEWVIEWS/SYSTEM/EMPLOYEE/CANADA"]]} {::return "";} ::return [[$_employee ".social_insurance_number"] odb_get]; } public method _ITEM_EDEPOSIT {s_args} { ::if {$_employee_line_count>0} {::return "";} ::return [::sargs::get [[$_employee ".structure_data"] qw_get] "/eft.status"]; } public method _ITEM_EBANKID {s_args} { ::if {$_employee_line_count>0} {::return "";} ::return [::sargs::get [[$_employee ".structure_data"] qw_get] "/eft.bank_id"]; } public method _ITEM_EBANKTRANSIT {s_args} { ::if {$_employee_line_count>0} {::return "";} ::return [::sargs::get [[$_employee ".structure_data"] qw_get] "/eft.bank_transit"]; } public method _ITEM_EBANKACCOUNT {s_args} { ::if {$_employee_line_count>0} {::return "";} ::return [::sargs::get [[$_employee ".structure_data"] qw_get] "/eft.bank_account"]; } public method _ITEM_CPPEX {s_args} {::return [item_data_request ".name CPPEX .period period"];} public method _ITEM_CPPE {s_args} {::return [item_data_request ".name CPPE .period period"];} public method _ITEM_EIE {s_args} {::return [item_data_request ".name EIE .period period"];} public method _ITEM_EIH {s_args} {::return [item_data_request ".name EIH .period period"];} public method _ITEM_PPIPE {s_args} {::return [item_data_request ".name PPIPE .period period"];} public method _ITEM_HSFE {s_args} {::return [item_data_request ".name HSFE .period period"];} public method _ITEM_NCTB1 {s_args} {::return [item_data_request ".name NCTB1 .period period"];} public method _ITEM_NCTB2 {s_args} {::return [item_data_request ".name NCTB2 .period period"];} public method _ITEM_NCTB3 {s_args} {::return [item_data_request ".name NCTB3 .period period"];} public method _ITEM_NCTB4 {s_args} {::return [item_data_request ".name NCTB4 .period period"];} public method _ITEM_YCPPEX {s_args} {::return [item_data_request ".name YCPPEX .period year_to_date"];} public method _ITEM_YCPPE {s_args} {::return [item_data_request ".name YCPPE .period year_to_date"];} public method _ITEM_YEIE {s_args} {::return [item_data_request ".name YEIE .period year_to_date"];} public method _ITEM_YEIH {s_args} {::return [item_data_request ".name YEIH .period year_to_date"];} public method _ITEM_YPPIPE {s_args} {::return [item_data_request ".name YPPIPE .period year_to_date"];} public method _ITEM_YHSFE {s_args} {::return [item_data_request ".name YHSFE .period year_to_date"];} public method _ITEM_YNCTB1 {s_args} {::return [item_data_request ".name YNCTB1 .period year_to_date"];} public method _ITEM_YNCTB2 {s_args} {::return [item_data_request ".name YNCTB2 .period year_to_date"];} public method _ITEM_YNCTB3 {s_args} {::return [item_data_request ".name YNCTB3 .period year_to_date"];} public method _ITEM_YNCTB4 {s_args} {::return [item_data_request ".name YNCTB4 .period year_to_date"];} public method _ITEM_PCPPEX {s_args} {::return [item_data_request ".name PCPPEX .period perpetual"];} public method _ITEM_PCPPE {s_args} {::return [item_data_request ".name PCPPE .period perpetual"];} public method _ITEM_PEIE {s_args} {::return [item_data_request ".name PEIE .period perpetual"];} public method _ITEM_PEIH {s_args} {::return [item_data_request ".name PEIH .period perpetual"];} public method _ITEM_PPPIPE {s_args} {::return [item_data_request ".name PPPIPE .period perpetual"];} public method _ITEM_PHSFE {s_args} {::return [item_data_request ".name PHSFE .period perpetual"];} public method _ITEM_PNCTB1 {s_args} {::return [item_data_request ".name PNCTB1 .period perpetual"];} public method _ITEM_PNCTB2 {s_args} {::return [item_data_request ".name PNCTB2 .period perpetual"];} public method _ITEM_PNCTB3 {s_args} {::return [item_data_request ".name PNCTB3 .period perpetual"];} public method _ITEM_PNCTB4 {s_args} {::return [item_data_request ".name PNCTB4 .period perpetual"];} public method _CPPEX {s_args} {::return [total_data_request ".name CPPEX .period period"];} public method _CPPE {s_args} {::return [total_data_request ".name CPPE .period period"];} public method _EIE {s_args} {::return [total_data_request ".name EIE .period period"];} public method _EIH {s_args} {::return [total_data_request ".name EIH .period period"];} public method _PPIPE {s_args} {::return [total_data_request ".name PPIPE .period period"];} public method _HSFE {s_args} {::return [total_data_request ".name HSFE .period period"];} public method _NCTB1 {s_args} {::return [total_data_request ".name NCTB1 .period period"];} public method _NCTB2 {s_args} {::return [total_data_request ".name NCTB2 .period period"];} public method _NCTB3 {s_args} {::return [total_data_request ".name NCTB3 .period period"];} public method _NCTB4 {s_args} {::return [total_data_request ".name NCTB4 .period period"];} public method _YCPPEX {s_args} {::return [total_data_request ".name YCPPEX .period year_to_date"];} public method _YCPPE {s_args} {::return [total_data_request ".name YCPPE .period year_to_date"];} public method _YEIE {s_args} {::return [total_data_request ".name YEIE .period year_to_date"];} public method _YEIH {s_args} {::return [total_data_request ".name YEIH .period year_to_date"];} public method _YPPIPE {s_args} {::return [total_data_request ".name YPPIPE .period year_to_date"];} public method _YHSFE {s_args} {::return [total_data_request ".name YHSFE .period year_to_date"];} public method _YNCTB1 {s_args} {::return [total_data_request ".name YNCTB1 .period year_to_date"];} public method _YNCTB2 {s_args} {::return [total_data_request ".name YNCTB2 .period year_to_date"];} public method _YNCTB3 {s_args} {::return [total_data_request ".name YNCTB3 .period year_to_date"];} public method _YNCTB4 {s_args} {::return [total_data_request ".name YNCTB4 .period year_to_date"];} public method _PCPPEX {s_args} {::return [total_data_request ".name PCPPEX .period perpetual"];} public method _PCPPE {s_args} {::return [total_data_request ".name PCPPE .period perpetual"];} public method _PEIE {s_args} {::return [total_data_request ".name PEIE .period perpetual"];} public method _PEIH {s_args} {::return [total_data_request ".name PEIH .period perpetual"];} public method _PPPIPE {s_args} {::return [total_data_request ".name PPPIPE .period perpetual"];} public method _PHSFE {s_args} {::return [total_data_request ".name PHSFE .period perpetual"];} public method _PNCTB1 {s_args} {::return [total_data_request ".name PNCTB1 .period perpetual"];} public method _PNCTB2 {s_args} {::return [total_data_request ".name PNCTB2 .period perpetual"];} public method _PNCTB3 {s_args} {::return [total_data_request ".name PNCTB3 .period perpetual"];} public method _PNCTB4 {s_args} {::return [total_data_request ".name PNCTB4 .period perpetual"];} public method _ITEM_WCBE {s_args} {::return [item_data_request ".name WCBE .period period"];} public method _ITEM_YWCBE {s_args} {::return [item_data_request ".name YWCBE .period year_to_date"];} public method _ITEM_PWCBE {s_args} {::return [item_data_request ".name PWCBE .period perpetual"];} public method _WCBE {s_args} {::return [total_data_request ".name WCBE .period period"];} public method _YWCBE {s_args} {::return [total_data_request ".name YWCBE .period year_to_date"];} public method _PWCBE {s_args} {::return [total_data_request ".name PWCBE .period perpetual"];} public method _ITEM_SSE {s_args} {::return [item_data_request ".name SSE .period period"];} public method _ITEM_ME {s_args} {::return [item_data_request ".name ME .period period"];} public method _ITEM_FE {s_args} {::return [item_data_request ".name FE .period period"];} public method _ITEM_YSSE {s_args} {::return [item_data_request ".name YSSE .period year_to_date"];} public method _ITEM_YME {s_args} {::return [item_data_request ".name YME .period year_to_date"];} public method _ITEM_YFE {s_args} {::return [item_data_request ".name YFE .period year_to_date"];} public method _ITEM_PSSE {s_args} {::return [item_data_request ".name PSSE .period perpetual"];} public method _ITEM_PME {s_args} {::return [item_data_request ".name PME .period perpetual"];} public method _ITEM_PFE {s_args} {::return [item_data_request ".name PFE .period perpetual"];} public method _SSE {s_args} {::return [total_data_request ".name SSE .period period"];} public method _ME {s_args} {::return [total_data_request ".name ME .period period"];} public method _FE {s_args} {::return [total_data_request ".name FE .period period"];} public method _YSSE {s_args} {::return [total_data_request ".name YSSE .period year_to_date"];} public method _YME {s_args} {::return [total_data_request ".name YME .period year_to_date"];} public method _YFE {s_args} {::return [total_data_request ".name YFE .period year_to_date"];} public method _PSSE {s_args} {::return [total_data_request ".name PSSE .period perpetual"];} public method _PME {s_args} {::return [total_data_request ".name PME .period perpetual"];} public method _PFE {s_args} {::return [total_data_request ".name PFE .period perpetual"];} public method _ITEM_SE1 {s_args} {::return [item_data_request ".name SE1 .period period"];} public method _ITEM_SE2 {s_args} {::return [item_data_request ".name SE2 .period period"];} public method _ITEM_LE1 {s_args} {::return [item_data_request ".name LE1 .period period"];} public method _ITEM_LE2 {s_args} {::return [item_data_request ".name LE2 .period period"];} public method _ITEM_YSE1 {s_args} {::return [item_data_request ".name YSE1 .period year_to_date"];} public method _ITEM_YSE2 {s_args} {::return [item_data_request ".name YSE2 .period year_to_date"];} public method _ITEM_YLE1 {s_args} {::return [item_data_request ".name YLE1 .period year_to_date"];} public method _ITEM_YLE2 {s_args} {::return [item_data_request ".name YLE2 .period year_to_date"];} public method _ITEM_PSE1 {s_args} {::return [item_data_request ".name PSE1 .period perpetual"];} public method _ITEM_PSE2 {s_args} {::return [item_data_request ".name PSE2 .period perpetual"];} public method _ITEM_PLE1 {s_args} {::return [item_data_request ".name PLE1 .period perpetual"];} public method _ITEM_PLE2 {s_args} {::return [item_data_request ".name PLE2 .period perpetual"];} public method _SE1 {s_args} {::return [total_data_request ".name SE1 .period period"];} public method _SE2 {s_args} {::return [total_data_request ".name SE2 .period period"];} public method _LE1 {s_args} {::return [total_data_request ".name LE1 .period period"];} public method _LE2 {s_args} {::return [total_data_request ".name LE2 .period period"];} public method _YSE1 {s_args} {::return [total_data_request ".name YSE1 .period year_to_date"];} public method _YSE2 {s_args} {::return [total_data_request ".name YSE2 .period year_to_date"];} public method _YLE1 {s_args} {::return [total_data_request ".name YLE1 .period year_to_date"];} public method _YLE2 {s_args} {::return [total_data_request ".name YLE2 .period year_to_date"];} public method _PSE1 {s_args} {::return [total_data_request ".name PSE1 .period perpetual"];} public method _PSE2 {s_args} {::return [total_data_request ".name PSE2 .period perpetual"];} public method _PLE1 {s_args} {::return [total_data_request ".name PLE1 .period perpetual"];} public method _PLE2 {s_args} {::return [total_data_request ".name PLE2 .period perpetual"];} ::for {::set ::qw::print::i 1;} {$::qw::print::i<=100} {::incr ::qw::print::i;} { ::foreach {::qw::print::prefix ::qw::print::period} { {} period Y year_to_date P perpetual Q period YQ year_to_date PQ perpetual R period } { ::set ::qw::print::body [::format {::return [item_data_request ".name %s%s .period %s"];} $::qw::print::prefix $::qw::print::i $::qw::print::period]; public method _ITEM_$::qw::print::prefix$::qw::print::i {s_args} $::qw::print::body; ::set ::qw::print::body [::format {::return [total_data_request ".name %s%s .period %s"];} $::qw::print::prefix $::qw::print::i $::qw::print::period]; public method _TOTAL$::qw::print::prefix$::qw::print::i {s_args} $::qw::print::body; } } ::unset ::qw::print::i; ::unset ::qw::print::prefix; ::unset ::qw::print::period; ::unset ::qw::print::body; public method init {} { chain; ::return $this; } public method documentStart {} { ::if {$settings eq ""} { ::qw::throw "payroll_report -settings not configured." } ::if {[::sargs::get $settings .detail] eq "paycheck"} { addressSourceSet; ::set _addressLines [address_printable [$_addressSource ".address"]]; } chain; ::return $this; } public method documentEnd {} { ::return [chain]; } method nextItemLoad {} { chain; ::set _item_date ""; ::set _item_reference ""; ::set _item_master ""; ::set _item_description ""; ::set _item_journal ""; ::if {[details_on]} { ::if {[::sargs::get $_employee_earnings_structure ".details"] ne ""} { next_detail_item_load; ::incr _employee_line_count; ::return; } ::if {[employee_subtotals_on]} { ::if {!$_employee_subtotal_done} { ::set _employee_earnings_structure $_employee_total_structure; ::set _employee_subtotal_in_progress 1; ::set _employee_subtotal_done 1; ::return; } } } ::if {$employee_list eq ""} { ::qw::throw "Ran off the end of the items."; } nextEmployeeLoad [::lindex $employee_list 0]; ::set employee_list [::lrange $employee_list 1 end]; ::if {$progress_window ne ""} { $progress_window increment; } ::return $this; } method numberOfItemsSet {} { ::set _itemsToDo [::llength $employee_list]; ::return $this; } method moreItemsQuery {} { ::if {[details_on]} { ::if {[::sargs::get $_employee_earnings_structure ".details"] ne ""} { ::return 1; } ::if {[employee_subtotals_on]} { ::if {!$_employee_subtotal_done} { ::return 1; } } } ::if {$employee_list ne ""} {::return 1;} ::return 0; } method pageBreakQuery {} { ::return [chain]; } method itemStart {} { ::return [chain]; #// base resets _itemInfo to NULL } method details_on {} { ::if {[::sargs::get $settings ".detail"] ne "summary"} {::return 1;} ::return 0; } method employee_subtotals_on {} { ::if {[::sargs::get $settings ".detail"] eq "detail with employee subtotals"} {::return 1;} ::return 0; } method include_employees_with_no_earnings {} { ::if {[::sargs::get $settings ".include_all_employees"] eq "yes"} {::return 1;} ::return 0; } public method load_employees_earnings {} { ::array unset _employee_earnings_array; ::set NewList ""; ::foreach Reference $employee_list { ::set Employee [$Reference odb_master]; ::set _employee_earnings_structure [$Employee pay_amounts $_earnings_mask]; ::if {![::sargs::get $_employee_earnings_structure ".has_earnings"]} { ::if {![include_employees_with_no_earnings]} { ::continue; } } ::lappend NewList $Employee; ::set _employee_earnings_array($Employee) $_employee_earnings_structure; } ::set _employee_earnings_structure ""; ::if {[::llength $NewList]>0} { ::set employee_list $NewList; ::return; } ::if {[::sargs::get $settings .detail] ne "paycheck"} { ::if {![include_employees_with_no_earnings]} { ::if {[::llength $employee_list]>1} { ::qw::throw "None of the employees have any earnings in the period specified."; } else { ::qw::throw "Employee [[$Employee .employee_id] odb_get] has no earnings in the period specified."; } } } ::set employee_list $NewList; } public method item_data_request {s_args} { ::set Name [::sargs::get $s_args ".name"]; ::if {![::info exists _name_path_array($Name)]} { ::return ""; } ::set Paths $_name_path_array($Name); ::set Expression ""; ::if {[::info exists _expression_array($Name)]} { ::set Expression $_expression_array($Name); ::set Result [amount_get [::sargs \ .expression $Expression \ .amount_type "item" \ .paths $Paths \ ]]; } else { ::set Result 0.0; ::foreach Path $Paths { ::set Amount [::sargs::get $_employee_earnings_structure $Path]; ::set Result [::qw::number::add $Result $Amount]; } } ::return $Result; } public method total_data_request {s_args} { ::if {[moreItemsQuery]} {::return "";} ::set Name [::sargs::get $s_args ".name"]; ::if {![::info exists _name_path_array($Name)]} {::return "";} ::set Paths $_name_path_array($Name); ::set Expression ""; ::if {[::info exists _expression_array($Name)]} { ::set Expression $_expression_array($Name); ::set Result [amount_get [::sargs \ .expression $Expression \ .amount_type "total" \ .paths $Paths \ ]]; } else { ::set Result 0.0; ::foreach Path $Paths { ::set Amount [::sargs::get $_report_total_structure $Path]; ::set Result [::qw::number::add $Result $Amount]; } } ::return $Result; } public method amount_get {s_args} { ::set Expression [::sargs::get $s_args ".expression"]; ::set AmountType [::sargs::get $s_args ".amount_type"]; ::set Paths [::sargs::get $s_args ".paths"]; ::set Expression [::string map {" " ""} $Expression]; ::set Expression [::string map {+ " + " - " - " * " * " / " / " ( " ( " ) " ) "} $Expression]; ::for {::set i 0;} {$i<[::llength $Expression]} {::incr i} { ::set Term [::lindex $Expression $i]; ::if {[::string first $Term "+-*/()"]>=0} {::continue;} ::if {[::string is double $Term]} {::continue;} ::set Path [::lindex $Paths 0]; ::set Paths [::lrange $Paths 1 end]; ::if {$AmountType eq "item"} { ::set Amount [::sargs::get $_employee_earnings_structure $Path]; } else { ::set Amount [::sargs::get $_report_total_structure $Path]; } ::if {$Amount eq ""} {::set Amount 0.0;} ::set Expression [::lreplace $Expression $i $i $Amount]; } ::for {::set i 0;} {$i<[::llength $Expression]} {::incr i} { ::set Term [::lindex $Expression $i]; ::if {[::string first $Term "+-*/()"]>=0} {::continue;} ::if {[::string is double $Term]} {::continue;} ::set Expression [::lreplace $Expression $i $i 0.0]; } ::set Result 0.0 ::if {[::catch {::set Result [::expr $Expression]} Error]} { } ::return $Result; } method nextEmployeeLoad {Employee} { ::set _employee [$Employee odb_master]; ::set _employee_subtotal_done 0; ::set _employee_subtotal_in_progress 0; ::set _employee_line_count 0; ::set _employee_earnings_structure $_employee_earnings_array($Employee); ::unset _employee_earnings_array($Employee); ::if {![details_on]} { ::set _employee_total_structure $_employee_earnings_structure; report_totals_increment; ::return; } ::set _employee_total_structure $_earnings_mask; next_detail_item_load; ::return; } public method next_detail_item_load {} { ::set _earnings_detail_list ""; ::set Details [::sargs::get $_employee_earnings_structure ".details"]; ::if {$Details eq ""} { ::return $_employee_earnings_structure; } ::set DateSub [::lindex [::lsort -increasing [::sargs::subs .structure $Details]] 0]; ::set DateStructure [::sargs::get $Details $DateSub]; ::set TransSub [::lindex [::sargs::subs .structure $DateStructure] 0]; ::set _earnings_detail_list [::sargs::get $DateStructure $TransSub.postings]; ::set _earnings_detail_structure [::sargs::get $DateStructure $TransSub.earnings]; ::set _item_date [::sargs::get $DateStructure $TransSub.date]; ::set _item_reference [::sargs::get $DateStructure $TransSub.reference]; ::set _item_description [::sargs::get $DateStructure $TransSub.description]; ::set Transaction [::sargs::get $DateStructure $TransSub.transaction]; ::set _item_transaction $Transaction; ::set _item_journal [[[[[$Transaction ".journal"] odb_get] odb_master] ".name"] odb_get]; ::sargs::var::unset DateStructure $TransSub; ::sargs::var::set Details $DateSub $DateStructure; ::if {[::sargs::subs .structure $DateStructure] eq ""} { ::sargs::var::unset Details $DateSub; ::if {[::sargs::subs .structure $Details] eq ""} {::set Details "";} } ::sargs::var::set _employee_earnings_structure ".details" $Details; details_increment; employee_totals_increment; ::if {$Details eq ""} { report_totals_increment; } } public method details_increment {} { ::set Paths [::sargs::select_field .structure $_employee_earnings_structure .field /period]; ::foreach Path $Paths { ::sargs::var::set _employee_earnings_structure ${Path}/period ""; } ::foreach Posting $_earnings_detail_list { ::set Amount [::sargs::get $Posting ".amount"]; ::set Quantity [::sargs::get $Posting ".quantity"]; ::set Rate [::sargs::get $Posting ".rate"]; ::if {$Amount==0.0&&$Quantity==0.0} { ::continue; } ::set Key [::sargs::get $Posting ".suffix"]; ::if {$Key ne ""} { ::set Paths [::sargs::select_field_value .structure $_employee_earnings_structure .field .suffix .value $Key]; } else { ::set Key [::sargs::get $Posting ".account"]; ::set Paths [::sargs::select_field_value .structure $_employee_earnings_structure .field .account .value $Key]; } ::foreach Path $Paths { ::foreach Period {"period" "perpetual" "year_to_date"} { ::if {[::sargs::exists $_employee_earnings_structure "$Path.amount/$Period"]} { ::set Total 0.0; ::if {$Period ne "period"} { ::set Total [::sargs::get $_employee_earnings_structure "$Path.amount/$Period"]; } ::set Total [::qw::number::add $Total $Amount]; ::sargs::var::set _employee_earnings_structure "$Path.amount/$Period" $Total; } ::if {[::sargs::exists $_employee_earnings_structure "$Path.quantity/$Period"]} { ::set Total 0.0; ::if {$Period ne "period"} { ::set Total [::sargs::get $_employee_earnings_structure "$Path.quantity/$Period"]; } ::set Total [::qw::number::add $Total $Quantity]; ::sargs::var::set _employee_earnings_structure "$Path.quantity/$Period" $Total; } ::if {$Period ne "period"} { ::continue; } ::if {[::sargs::exists $_employee_earnings_structure "$Path.rate/$Period"]} { ::sargs::var::set _employee_earnings_structure "$Path.rate/$Period" $Rate; } } } } ::foreach Name [::sargs::names .structure $_earnings_detail_structure] { ::set Amount [::sargs::get $_earnings_detail_structure $Name]; ::if {$Amount==0.0} {::continue;} ::set Name [::string range $Name 1 end]; ::foreach Prefix {{} Y P} { ::set Key $Prefix$Name; ::if {![::info exists _name_path_array($Key)]} {::continue;} ::set Paths $_name_path_array($Key); ::foreach Path $Paths { ::switch -- $Prefix { {} {::set Total $Amount;} "Y" - "P" {::set Total [::qw::number::add $Amount [::sargs::get $_employee_earnings_structure $Path]];} } ::sargs::var::set _employee_earnings_structure $Path $Total; } } } } public method employee_totals_increment {} { ::set Paths [::sargs::select_field .structure $_earnings_mask .field /period]; ::foreach Path $Paths { ::append Path "/period"; ::set Total [::sargs::get $_employee_total_structure $Path]; ::set Amount [::sargs::get $_employee_earnings_structure $Path]; ::set Total [::qw::number::add $Total $Amount]; ::sargs::var::set _employee_total_structure $Path $Total; ::if {[::string first ".rate" $Path]<0} {::continue;} ::set Rate [::sargs::get $_employee_earnings_structure $Path]; ::set RatesPath [::string map {.rate .rates} $Path]; ::set Rates [::sargs::get $_employee_total_structure $RatesPath]; ::lappend Rates $Rate; ::sargs::var::set _employee_total_structure $RatesPath $Rates; ::set Total 0.0; ::foreach Rate $Rates { ::set Total [::qw::number::add $Total $Rate]; } ::set Average [::qw::number::divide $Total [::llength $Rates]]; ::sargs::var::set _employee_total_structure $Path $Average; } ::set Paths [::sargs::select_field .structure $_earnings_mask .field /year_to_date]; ::foreach Path $Paths { ::append Path "/year_to_date"; ::set Amount [::sargs::get $_employee_earnings_structure $Path]; ::sargs::var::set _employee_total_structure $Path $Amount; } ::set Paths [::sargs::select_field .structure $_earnings_mask .field /perpetual]; ::foreach Path $Paths { ::append Path "/perpetual"; ::set Amount [::sargs::get $_employee_earnings_structure $Path]; ::sargs::var::set _employee_total_structure $Path $Amount; } } public method report_totals_increment {} { ::foreach Period {/period /year_to_date /perpetual} { ::set Paths [::sargs::select_field .structure $_earnings_mask .field $Period]; ::foreach Path $Paths { ::append Path $Period; ::set Total [::sargs::get $_report_total_structure $Path]; ::set Amount [::sargs::get $_employee_total_structure $Path]; ::set Total [::qw::number::add $Total $Amount]; ::sargs::var::set _report_total_structure $Path $Total; } } } public method build_earnings_mask {} { ::catch {::unset _expression_array;};::array set _expression_array {}; ::set _earnings_mask ""; ::array unset _name_path_array; ::array unset _report_codes_array; ::set _employee_subtotal_done 1; ::set _employee_line_count 0; ::if {[details_on]} {::sargs::var::set _earnings_mask .details {};} ::sargs::var::set _earnings_mask ".begin" [::sargs::get $settings ".begin_date"]; ::sargs::var::set _earnings_mask ".end" [::sargs::get $settings ".end_date"]; ::sargs::var::set _earnings_mask ".has_earnings" 0; ::set _report_codes [::sargs::get $settings ".payroll_report_control"]; ::set SuffixSub 0; ::set AccountSub 0; ::array set SuffixArray {}; ::array set AccountArray {}; ::array set NamesArray {}; ::foreach Name $_itemNames { ::set NamesArray($Name) ""; } ::foreach Name $_headerNames { ::set Name [::string map {TOTAL ITEM_} $Name]; ::set NamesArray($Name) ""; } ::foreach Name [::array names NamesArray] { ::set Number ""; ::if {![::regexp {(ITEM_)(R|Y|P|Q|YQ|PQ)?([0-9]+)} $Name match Ignore Type Number]} { ::continue; } ::if {$Number eq ""||![::string is integer $Number]} { ::continue; } ::set ShortName [::string map {ITEM_ {}} $Name]; ::switch -- $Type { "" {::set Path ".amount/period";} "R" {::set Path ".rate/period";} "Y" {::set Path ".amount/year_to_date";} "P" {::set Path ".amount/perpetual";} "Q" {::set Path ".quantity/period";} "YQ" {::set Path ".quantity/year_to_date";} "PQ" {::set Path ".quantity/perpetual";} default { ::continue; } } ::if {$Number<=75} { ::set Expression [::sargs::get $_report_codes /$Number]; ::set Targets [::regsub -all {[^A-Z0-9]} $Expression " "] ::set SuffixList ""; ::foreach Term $Targets { ::if {![::string is double $Term]} {::lappend SuffixList $Term;} } ::set Targets $SuffixList; } else { ::set Expression ""; ::set Targets [::sargs::get $_report_codes /$Number]; } ::foreach Target $Targets { ::if {$Number<=75} { ::if {![::info exists SuffixArray($Target)]} { ::incr SuffixSub; ::sargs::var::set _earnings_mask ".earnings_by_suffix/$SuffixSub.suffix" $Target; ::set SuffixArray($Target) $SuffixSub; } ::set Sub $SuffixArray($Target); ::sargs::var::set _earnings_mask ".earnings_by_suffix/$Sub$Path" 0.00; ::lappend _name_path_array($ShortName) ".earnings_by_suffix/$Sub$Path"; ::set _expression_array($Type$Number) $Expression; ::continue; } ::if {![::info exists AccountArray($Target)]} { ::incr AccountSub; ::sargs::var::set _earnings_mask ".accounts/$AccountSub.account" $Target; ::set AccountArray($Target) $AccountSub; } ::set Sub $AccountArray($Target); ::sargs::var::set _earnings_mask ".accounts/$Sub$Path" 0.00; ::lappend _name_path_array($ShortName) ".accounts/$Sub$Path"; } } ::set EarningSub 0; ::array set EarningArray {}; ::foreach Name [::array names NamesArray] { ::set Suffix ""; ::set Number ""; ::if {![::regexp {(ITEM_)(Y|P|Q|YQ|PQ)?([A-Z]+)(1|2|3|4)?$} [::string toupper $Name] match Ignore Type Earning Number]} { ::continue; } ::if {$Earning eq ""} { ::continue; } ::switch $Earning { "SE" - "LE" - "NCTB" { ::if {$Number eq ""} {::continue;} } default { ::if {$Number ne ""} {::continue;} } } ::set ShortName [::string map {ITEM_ {}} $Name]; ::switch -- $Type { "" {::set Path ".amount/period";} "Y" {::set Path ".amount/year_to_date";} "P" { ::set Path ".amount/perpetual"; ::if {$Earning eq "PIPE"} { ::set Path ".amount/period"; } } default {::continue;} } ::switch -- $Earning { "SSE" - "ME" - "FE" - "CPPEX" - "CPPE" - "EIE" - "EIH" - "PPIPE" - "WCBE" - "HSFE" {::set Field $Earning} "SE" - "LE" - "NCTB" {::set Field $Earning$Number} "PIPE" {::set Field "PPIPE";} default {::continue;} } ::if {![::info exists EarningArray($Field)]} { ::incr EarningSub; ::sargs::var::set _earnings_mask ".earnings_by_type/$EarningSub.type" $Field; ::set EarningArray($Field) $EarningSub; } ::set Sub $EarningArray($Field); ::sargs::var::set _earnings_mask ".earnings_by_type/$Sub$Path" 0.00; ::lappend _name_path_array($ShortName) ".earnings_by_type/$Sub$Path"; } ::set _report_total_structure $_earnings_mask; ::foreach Sub [::sargs::subs .structure $_report_codes] { ::set Targets [::sargs::get $_report_codes $Sub]; ::set Sub [::string range $Sub 1 end]; ::foreach Target $Targets {::set _report_codes_array($Target) $Sub;} } } } ::itcl::class ::qw::print::windows::template::roe { inherit ::qw::print::windows::template; protected variable _roe_data {}; protected variable _ie_periods_to_report 0; protected variable _ie_periods_with_earnings 0; protected variable _name_map_array {}; constructor {args} { ::eval ::qw::print::windows::template::constructor $args; ::catch {::unset _name_map_array;}; ::array set _name_map_array { "AMENDEDSERIALNUMBER" ".other.2_serial_number_replaced" "BUSINESSNUMBER" ".employer.5_business_number" "COMMUNICATIONENGLISH" ".other.20_language_english" "COMMUNICATIONFRENCH" ".other.20_language_french" "CONTACT" ".employer.16_contact_name" "CONTACTPHONE" ".employer.16_contact_phone" "EMPLOYEESADDRESS" ".employee.9_address" "EMPLOYEESNAME" ".employee.9_name.print_as" "EMPLOYERSADDRESS" ".employer.4_address" "EMPLOYERSNAME" ".employer.4_employer_name" "EMPLOYERSPAYROLLREFERENCE" ".employee.3_reference" "EMPLOYERSPOSTALCODE" ".employer.4_address.zipcode" "EMPLOYERSPHONE" ".employer.21_employer_phone" "FINALPPENDDATE" ".employee.12_final_pay_period.ending_date" "FIRSTPAYDATE" ".employee.10_first_day_worked" "LASTPAYDATE" ".employee.11_last_day_worked" "OCCUPATION" ".employee.13_occupation" "OTHERMONIESAMOUNT1" ".other.17c_other/1.amount" "OTHERMONIESAMOUNT2" ".other.17c_other/2.amount" "OTHERMONIESAMOUNT3" ".other.17c_other/3.amount" "OTHERMONIESTEXT1" ".other.17c_other/1.description" "OTHERMONIESTEXT2" ".other.17c_other/2.description" "OTHERMONIESTEXT3" ".other.17c_other/3.description" "PAYPERIOD1" ".employee.15_insurable_earnings.amount_by_pay_period/1.amount" "PAYPERIOD2" ".employee.15_insurable_earnings.amount_by_pay_period/2.amount" "PAYPERIOD3" ".employee.15_insurable_earnings.amount_by_pay_period/3.amount" "PAYPERIOD4" ".employee.15_insurable_earnings.amount_by_pay_period/4.amount" "PAYPERIOD5" ".employee.15_insurable_earnings.amount_by_pay_period/5.amount" "PAYPERIOD6" ".employee.15_insurable_earnings.amount_by_pay_period/6.amount" "PAYPERIOD7" ".employee.15_insurable_earnings.amount_by_pay_period/7.amount" "PAYPERIOD8" ".employee.15_insurable_earnings.amount_by_pay_period/8.amount" "PAYPERIOD9" ".employee.15_insurable_earnings.amount_by_pay_period/9.amount" "PAYPERIOD10" ".employee.15_insurable_earnings.amount_by_pay_period/10.amount" "PAYPERIOD11" ".employee.15_insurable_earnings.amount_by_pay_period/11.amount" "PAYPERIOD12" ".employee.15_insurable_earnings.amount_by_pay_period/12.amount" "PAYPERIOD13" ".employee.15_insurable_earnings.amount_by_pay_period/13.amount" "PAYPERIOD14" ".employee.15_insurable_earnings.amount_by_pay_period/14.amount" "PAYPERIOD15" ".employee.15_insurable_earnings.amount_by_pay_period/15.amount" "PAYPERIOD16" ".employee.15_insurable_earnings.amount_by_pay_period/16.amount" "PAYPERIOD17" ".employee.15_insurable_earnings.amount_by_pay_period/17.amount" "PAYPERIOD18" ".employee.15_insurable_earnings.amount_by_pay_period/18.amount" "PAYPERIOD19" ".employee.15_insurable_earnings.amount_by_pay_period/19.amount" "PAYPERIOD20" ".employee.15_insurable_earnings.amount_by_pay_period/20.amount" "PAYPERIOD21" ".employee.15_insurable_earnings.amount_by_pay_period/21.amount" "PAYPERIOD22" ".employee.15_insurable_earnings.amount_by_pay_period/22.amount" "PAYPERIOD23" ".employee.15_insurable_earnings.amount_by_pay_period/23.amount" "PAYPERIOD24" ".employee.15_insurable_earnings.amount_by_pay_period/24.amount" "PAYPERIOD25" ".employee.15_insurable_earnings.amount_by_pay_period/25.amount" "PAYPERIOD26" ".employee.15_insurable_earnings.amount_by_pay_period/26.amount" "PAYPERIOD27" ".employee.15_insurable_earnings.amount_by_pay_period/27.amount" "PAYPERIODS" ".employee.6_pay_period_type" "PAYMENTPERDAY" ".other.19_sick_leave.per_day" "PAYMENTPERWEEK" ".other.19_sick_leave.per_week" "PAYMENTSTARTAMOUNT" ".other.19_sick_leave.amount" "PAYMENTSTARTDATE" ".other.19_sick_leave.start_date" "RECALLNOTRETURNING" ".other.14_recall.code_not_returning" "RECALLUNKNOWN" ".other.14_recall.code_unknown" "RECALLDATE" ".other.14_recall.date" "ROEDATE" ".date" "SERIALNUMBER" ".name" "SOCIALINSURANCENUMBER" ".employee.8_social_insurance_number" "STATUTORYHOLIDAYAMOUNT1" ".other.17b_statutory_holidays/1.amount" "STATUTORYHOLIDAYAMOUNT2" ".other.17b_statutory_holidays/2.amount" "STATUTORYHOLIDAYAMOUNT3" ".other.17b_statutory_holidays/3.amount" "STATUTORYHOLIDAYDATE1" ".other.17b_statutory_holidays/1.date" "STATUTORYHOLIDAYDATE2" ".other.17b_statutory_holidays/2.date" "STATUTORYHOLIDAYDATE3" ".other.17b_statutory_holidays/3.date" "TERMINATIONCODE" ".employee.16_reason.code" "TOTALINSURABLEEARNINGS" ".employee.15_insurable_earnings.total" "TOTALINSURABLEHOURS" ".employee.15_insurable_hours.total" "VACATIONPAY" ".employee.17a_vacation_pay" "COMMENT1" ".employee.18_comments.1" "COMMENT2" ".employee.18_comments.2" "COMMENT3" ".employee.18_comments.3" "COMMENT4" ".employee.18_comments.4" "COMMENT5" ".employee.18_comments.5" "COMMENT6" ".employee.18_comments.6" "COMMENT7" ".employee.18_comments.7" "COMMENT8" ".employee.18_comments.8" "COMMENT9" ".employee.18_comments.9" "COMMENT10" ".employee.18_comments.10" }; ::for {::set j 28;} {$j<=53} {::incr j} { ::array set _name_map_array [::list "PAYPERIOD$j" ".employee.web_insurable_earnings.amount_by_pay_period/$j.amount"]; ;#// why not take them all from .web (see above for first 27) } } { } destructor { } public method _AMENDEDSERIALNUMBER {s_args} {::return [data_item $s_args];} public method _BUSINESSNUMBER {s_args} {::return [data_item $s_args];} public method _COMMUNICATIONENGLISH {s_args} {::return [data_item $s_args];} public method _COMMUNICATIONFRENCH {s_args} {::return [data_item $s_args];} public method _CONTACT {s_args} {::return [data_item $s_args];} public method _CONTACTPHONE {s_args} {::return [data_item $s_args];} public method _EMPLOYEESADDRESS {s_args} {::return [data_item $s_args];} public method _EMPLOYEESNAME {s_args} {::return [data_item $s_args];} public method _EMPLOYERSADDRESS {s_args} {::return [data_item $s_args];} public method _EMPLOYERSNAME {s_args} {::return [data_item $s_args];} public method _EMPLOYERSPAYROLLREFERENCE {s_args} { ::return [data_item $s_args]; } public method _EMPLOYERSPOSTALCODE {s_args} {::return [data_item $s_args];} public method _EMPLOYERSPHONE {s_args} {::return [data_item $s_args];} public method _FINALPPENDDATE {s_args} {::return [data_item $s_args];} public method _FIRSTPAYDATE {s_args} {::return [data_item $s_args];} public method _LASTPAYDATE {s_args} {::return [data_item $s_args];} public method _OCCUPATION {s_args} {::return [data_item $s_args];} public method _OTHERMONIESAMOUNT1 {s_args} {::return [data_item $s_args];} public method _OTHERMONIESAMOUNT2 {s_args} {::return [data_item $s_args];} public method _OTHERMONIESAMOUNT3 {s_args} {::return [data_item $s_args];} public method _OTHERMONIESTEXT1 {s_args} {::return [data_item $s_args];} public method _OTHERMONIESTEXT2 {s_args} {::return [data_item $s_args];} public method _OTHERMONIESTEXT3 {s_args} {::return [data_item $s_args];} public method _PAYPERIOD1 {s_args} {::return [data_item $s_args];} public method _PAYPERIOD2 {s_args} {::return [data_item $s_args];} public method _PAYPERIOD3 {s_args} {::return [data_item $s_args];} public method _PAYPERIOD4 {s_args} {::return [data_item $s_args];} public method _PAYPERIOD5 {s_args} {::return [data_item $s_args];} public method _PAYPERIOD6 {s_args} {::return [data_item $s_args];} public method _PAYPERIOD7 {s_args} {::return [data_item $s_args];} public method _PAYPERIOD8 {s_args} {::return [data_item $s_args];} public method _PAYPERIOD9 {s_args} {::return [data_item $s_args];} public method _PAYPERIOD10 {s_args} {::return [data_item $s_args];} public method _PAYPERIOD11 {s_args} {::return [data_item $s_args];} public method _PAYPERIOD12 {s_args} {::return [data_item $s_args];} public method _PAYPERIOD13 {s_args} {::return [data_item $s_args];} public method _PAYPERIOD14 {s_args} {::return [data_item $s_args];} public method _PAYPERIOD15 {s_args} {::return [data_item $s_args];} public method _PAYPERIOD16 {s_args} {::return [data_item $s_args];} public method _PAYPERIOD17 {s_args} {::return [data_item $s_args];} public method _PAYPERIOD18 {s_args} {::return [data_item $s_args];} public method _PAYPERIOD19 {s_args} {::return [data_item $s_args];} public method _PAYPERIOD20 {s_args} {::return [data_item $s_args];} public method _PAYPERIOD21 {s_args} {::return [data_item $s_args];} public method _PAYPERIOD22 {s_args} {::return [data_item $s_args];} public method _PAYPERIOD23 {s_args} {::return [data_item $s_args];} public method _PAYPERIOD24 {s_args} {::return [data_item $s_args];} public method _PAYPERIOD25 {s_args} {::return [data_item $s_args];} public method _PAYPERIOD26 {s_args} {::return [data_item $s_args];} public method _PAYPERIOD27 {s_args} {::return [data_item $s_args];} public method _PAYPERIOD28 {s_args} {::return [data_item $s_args];} public method _PAYPERIOD29 {s_args} {::return [data_item $s_args];} public method _PAYPERIOD30 {s_args} {::return [data_item $s_args];} public method _PAYPERIOD31 {s_args} {::return [data_item $s_args];} public method _PAYPERIOD32 {s_args} {::return [data_item $s_args];} public method _PAYPERIOD33 {s_args} {::return [data_item $s_args];} public method _PAYPERIOD34 {s_args} {::return [data_item $s_args];} public method _PAYPERIOD35 {s_args} {::return [data_item $s_args];} public method _PAYPERIOD36 {s_args} {::return [data_item $s_args];} public method _PAYPERIOD37 {s_args} {::return [data_item $s_args];} public method _PAYPERIOD38 {s_args} {::return [data_item $s_args];} public method _PAYPERIOD39 {s_args} {::return [data_item $s_args];} public method _PAYPERIOD40 {s_args} {::return [data_item $s_args];} public method _PAYPERIOD41 {s_args} {::return [data_item $s_args];} public method _PAYPERIOD42 {s_args} {::return [data_item $s_args];} public method _PAYPERIOD43 {s_args} {::return [data_item $s_args];} public method _PAYPERIOD44 {s_args} {::return [data_item $s_args];} public method _PAYPERIOD45 {s_args} {::return [data_item $s_args];} public method _PAYPERIOD46 {s_args} {::return [data_item $s_args];} public method _PAYPERIOD47 {s_args} {::return [data_item $s_args];} public method _PAYPERIOD48 {s_args} {::return [data_item $s_args];} public method _PAYPERIOD49 {s_args} {::return [data_item $s_args];} public method _PAYPERIOD50 {s_args} {::return [data_item $s_args];} public method _PAYPERIOD51 {s_args} {::return [data_item $s_args];} public method _PAYPERIOD52 {s_args} {::return [data_item $s_args];} public method _PAYPERIOD53 {s_args} {::return [data_item $s_args];} public method _PAYPERIODS {s_args} {::return [data_item $s_args];} public method _PAYMENTPERDAY {s_args} {::return [data_item $s_args];} public method _PAYMENTPERWEEK {s_args} {::return [data_item $s_args];} public method _PAYMENTSTARTAMOUNT {s_args} {::return [data_item $s_args];} public method _PAYMENTSTARTDATE {s_args} {::return [data_item $s_args];} public method _RECALLNOTRETURNING {s_args} {::return [data_item $s_args];} public method _RECALLUNKNOWN {s_args} {::return [data_item $s_args];} public method _RECALLDATE {s_args} {::return [data_item $s_args];} public method _ROEDATE {s_args} {::return [data_item $s_args];} public method _SERIALNUMBER {s_args} {::return [data_item $s_args];} public method _SOCIALINSURANCENUMBER {s_args} {::return [data_item $s_args];} public method _STATUTORYHOLIDAYAMOUNT1 {s_args} {::return [data_item $s_args];} public method _STATUTORYHOLIDAYAMOUNT2 {s_args} {::return [data_item $s_args];} public method _STATUTORYHOLIDAYAMOUNT3 {s_args} {::return [data_item $s_args];} public method _STATUTORYHOLIDAYDATE1 {s_args} {::return [data_item $s_args];} public method _STATUTORYHOLIDAYDATE2 {s_args} {::return [data_item $s_args];} public method _STATUTORYHOLIDAYDATE3 {s_args} {::return [data_item $s_args];} public method _TERMINATIONCODE {s_args} {::return [data_item $s_args];} public method _TOTALINSURABLEEARNINGS {s_args} {::return [data_item $s_args];} public method _TOTALINSURABLEHOURS {s_args} {::return [data_item $s_args];} public method _VACATIONPAY {s_args} {::return [data_item $s_args];} public method _COMMENT1 {s_args} {::return [data_item $s_args];} public method _COMMENT2 {s_args} {::return [data_item $s_args];} public method _COMMENT3 {s_args} {::return [data_item $s_args];} public method _COMMENT4 {s_args} {::return [data_item $s_args];} public method _COMMENT5 {s_args} {::return [data_item $s_args];} public method _COMMENT6 {s_args} {::return [data_item $s_args];} public method _COMMENT7 {s_args} {::return [data_item $s_args];} public method _COMMENT8 {s_args} {::return [data_item $s_args];} public method _COMMENT9 {s_args} {::return [data_item $s_args];} public method _COMMENT10 {s_args} {::return [data_item $s_args];} public method documentStart {} { ::set _roe_data [::sargs::get [[[$_reference odb_master] ".clientdata"] odb_get] ".roe"]; ::set _ie_periods_to_report [::sargs::get $_roe_data ".employee.15_insurable_earnings.periods_to_report"]; ::set _ie_periods_with_earnings [::sargs::get $_roe_data ".employee.15_insurable_earnings.periods_with_earnings"]; ::return [chain]; } method data_item {s_args} { ::set Name [::sargs::get $s_args ".name"]; ::set Path $_name_map_array($Name); ::if {$Path eq ""} { ::return ""; } ::set Result [::sargs::get $_roe_data $Path]; ::if {$Path eq ".employer.4_address"} { ::set S_Args [::sargs::get $_roe_data ".employer.4_address"]; ::sargs::var::set S_Args ".zipcode" ""; ::return [assemble_address $S_Args]; } ::if {$Path eq ".employee.9_address"} { ::return [assemble_address [::sargs::get $_roe_data ".employee.9_address"]] } ::if {$Path eq ".other.14_recall.code_not_returning"} { ::if {[::string tolower [::string index [::sargs::get $_roe_data ".other.14_recall.code"] 0]] eq "n"} {::return "X";} ::return ""; } ::if {$Path eq ".other.14_recall.code_unknown"} { ::if {[::string tolower [::string index [::sargs::get $_roe_data ".other.14_recall.code"] 0]] eq "u"} {::return "X";} ::return ""; } ::if {$Path eq ".employee.15_insurable_earnings.total"} { ::return [::expr $Result+[box_17_amounts_total]]; } ::if {$Path eq ".employer.16_contact_name"} { ::set Result ""; ::append Result [::sargs::get $_roe_data ".employer.16_contact_name.first"]; ::append Result " "; ::append Result [::sargs::get $_roe_data ".employer.16_contact_name.last"]; ::return [::string trim $Result]; } ::if {$Path eq ".employer.16_contact_phone"} { ::set Result ""; ::append Result [::sargs::get $_roe_data ".employer.16_contact_phone.area_code"]; ::append Result " "; ::append Result [::string range [::sargs::get $_roe_data ".employer.16_contact_phone.number"] 0 2]; ::append Result "-"; ::append Result [::string range [::sargs::get $_roe_data ".employer.16_contact_phone.number"] 3 6]; ::append Result " "; ::append Result [::sargs::get $_roe_data ".employer.16_contact_phone.extension"]; ::return [::string trim $Result]; } ::if {[::regexp {^(\.employee\.15_insurable_earnings\.amount_by_pay_period/)([0-9]+)(\.amount)$} $Path match Head PayPeriodNumber Tail]} { ::if {$_ie_periods_to_report==$_ie_periods_with_earnings} { } ::if {$PayPeriodNumber>$_ie_periods_to_report} { ::return ""; } ::if {$PayPeriodNumber==1} { ::return [::expr $Result+[box_17_amounts_total]]; } ::return $Result; } ::foreach AmountPath { ".employee.17a_vacation_pay" ".other.17b_statutory_holidays/1.amount" ".other.17b_statutory_holidays/2.amount" ".other.17b_statutory_holidays/3.amount" ".other.17c_other/1.amount" ".other.17c_other/2.amount" ".other.17c_other/3.amount" ".other.19_sick_leave.amount" } { ::if {$AmountPath eq $Path} { ::if {$Result eq ""} {::return "";} ::if {[::string is double $Result] && $Result!=0.0} {::return $Result;} ::return ""; } } ::if {$Path eq ".employee.8_social_insurance_number"} { ::return "[::string range $Result 0 2] [::string range $Result 3 5] [::string range $Result 6 8]"; } ::if {$Path eq ".other.19_sick_leave.per_day"} { ::if {[::string tolower [::string index [::sargs::get $_roe_data ".other.19_sick_leave.per"] 0]] eq "d"} {::return "X";} ::return ""; } ::if {$Path eq ".other.19_sick_leave.per_week"} { ::if {[::string tolower [::string index [::sargs::get $_roe_data ".other.19_sick_leave.per"] 0]] eq "w"} {::return "X";} ::return ""; } ::if {$Path eq ".other.20_language_english"} { ::if {[::string tolower [::sargs::get $_roe_data ".other.20_language"]] eq "english"} {::return "X"} ::return ""; } ::if {$Path eq ".other.20_language_french"} { ::if {[::string tolower [::sargs::get $_roe_data ".other.20_language"]] eq "french"} {::return "X"} ::return ""; } ::if {$Path eq ".employer.21_employer_phone"} { ::set Result ""; ::append Result [::sargs::get $_roe_data ".employer.21_employer_phone.area_code"]; ::append Result " "; ::append Result [::string range [::sargs::get $_roe_data ".employer.21_employer_phone.number"] 0 2]; ::append Result "-"; ::append Result [::string range [::sargs::get $_roe_data ".employer.21_employer_phone.number"] 3 6]; ::append Result " "; ::append Result [::sargs::get $_roe_data ".employer.21_employer_phone.extension"]; ::return [::string trim $Result]; } ::if {$Path eq ".date"} {::return [[[$_reference odb_master] ".date"] odb_get];} ::if {$Path eq ".name"} {::return [[[$_reference odb_master] ".name"] odb_get];} ::return $Result; } method assemble_address {s_args} { ::set Result ""; ::foreach Field {street street2 city state country zipcode} { ::set Value($Field) [::sargs::get $s_args ".$Field"]; } ::if {$Value(street) ne ""} {::append Result "$Value(street)\n";} ::if {$Value(street2) ne ""} {::append Result "$Value(street2)\n";} ::set Flag 0; ::if {$Value(city) ne ""} {::append Result "$Value(city), ";::set Flag 1;} ::if {$Value(state) ne ""} {::append Result "$Value(state)";::set Flag 1;} ::if {$Flag} {::append Result "\n"} ::if {$Value(zipcode) ne ""} {::append Result "$Value(zipcode)\n";} ::set Result [::string trim $Result]; ::return $Result; } method box_17_amounts_total {} { ::set Result 0.0; ::foreach Path { ".employee.17a_vacation_pay" ".other.17b_statutory_holidays/1.amount" ".other.17b_statutory_holidays/2.amount" ".other.17b_statutory_holidays/3.amount" ".other.17c_other/1.amount" ".other.17c_other/2.amount" ".other.17c_other/3.amount" } { ::set Result [::expr $Result+[::sargs::get $_roe_data $Path]]; } ::return $Result; } } ::itcl::class ::qw::print::windows::template::t4 { inherit ::qw::print::windows::template; public variable t4_data ""; public variable settings ""; public method _VOID {s_args} {::return [data_item $s_args];} public method _YEAR {s_args} {::return [data_item $s_args];} public method _EMPLOYERNAME {s_args} {::return [data_item $s_args];} public method _EMPLOYERADDRESS1 {s_args} {::return [data_item $s_args];} public method _EMPLOYERADDRESS2 {s_args} {::return [data_item $s_args];} public method _EMPLOYERADDRESS3 {s_args} {::return [data_item $s_args];} public method _EMPLOYERADDRESS4 {s_args} {::return [data_item $s_args];} public method _EMPLOYERSTREET {s_args} {::return [data_item $s_args];} public method _EMPLOYERSTREET2 {s_args} {::return [data_item $s_args];} public method _EMPLOYERCITY {s_args} {::return [data_item $s_args];} public method _EMPLOYERSTATE {s_args} {::return [data_item $s_args];} public method _EMPLOYERCOUNTRY {s_args} {::return [data_item $s_args];} public method _EMPLOYERPOSTAL {s_args} {::return [data_item $s_args];} public method _EMPLOYERCITYSTATEZIP {s_args} {::return [data_item $s_args];} public method _EMPLOYEEADDRESS {s_args} {::return [data_item $s_args];} public method _EMPLOYEENAME {s_args} {::return [data_item $s_args];} public method _BOX10 {s_args} {::return [data_item $s_args];} public method _BOX12 {s_args} {::return [data_item $s_args];} public method _BOX14 {s_args} {::return [data_item $s_args];} public method _BOX16 {s_args} {::return [data_item $s_args];} public method _BOX17 {s_args} {::return [data_item $s_args];} public method _BOX16A {s_args} {::return [data_item $s_args];} public method _BOX17A {s_args} {::return [data_item $s_args];} public method _BOX18 {s_args} {::return [data_item $s_args];} public method _BOX20 {s_args} {::return [data_item $s_args];} public method _BOX22 {s_args} {::return [data_item $s_args];} public method _BOX24 {s_args} {::return [data_item $s_args];} public method _BOX26 {s_args} {::return [data_item $s_args];} public method _BOX28CPP {s_args} {::return [data_item $s_args];} public method _BOX28EI {s_args} {::return [data_item $s_args];} public method _BOX28PPIP {s_args} {::return [data_item $s_args];} public method _BOX29 {s_args} {::return [data_item $s_args];} public method _BOX44 {s_args} {::return [data_item $s_args];} public method _BOX45 {s_args} {::return [data_item $s_args];} public method _BOX46 {s_args} {::return [data_item $s_args];} public method _BOX50 {s_args} {::return [data_item $s_args];} public method _BOX52 {s_args} {::return [data_item $s_args];} public method _BOX54 {s_args} {::return [data_item $s_args];} public method _BOX55 {s_args} {::return [data_item $s_args];} public method _BOX56 {s_args} {::return [data_item $s_args];} public method _OTHERBOX1 {s_args} {::return [data_item $s_args];} public method _OTHERBOX2 {s_args} {::return [data_item $s_args];} public method _OTHERBOX3 {s_args} {::return [data_item $s_args];} public method _OTHERBOX4 {s_args} {::return [data_item $s_args];} public method _OTHERBOX5 {s_args} {::return [data_item $s_args];} public method _OTHERBOX6 {s_args} {::return [data_item $s_args];} public method _OTHERBOX7 {s_args} {::return [data_item $s_args];} public method _OTHERBOX8 {s_args} {::return [data_item $s_args];} public method _OTHERBOX9 {s_args} {::return [data_item $s_args];} public method _OTHERBOX1AMOUNT {s_args} {::return [data_item $s_args];} public method _OTHERBOX2AMOUNT {s_args} {::return [data_item $s_args];} public method _OTHERBOX3AMOUNT {s_args} {::return [data_item $s_args];} public method _OTHERBOX4AMOUNT {s_args} {::return [data_item $s_args];} public method _OTHERBOX5AMOUNT {s_args} {::return [data_item $s_args];} public method _OTHERBOX6AMOUNT {s_args} {::return [data_item $s_args];} public method _OTHERBOX7AMOUNT {s_args} {::return [data_item $s_args];} public method _OTHERBOX8AMOUNT {s_args} {::return [data_item $s_args];} public method _OTHERBOX9AMOUNT {s_args} {::return [data_item $s_args];} constructor {args} { ::eval ::qw::print::windows::template::constructor $args; } { } destructor { } public method load {Src} { ::set _references $Src; other_boxes_setup; chain [::lindex $_references 0]; } public method documentStart {} { chain; addressSourceSet; } method other_boxes_setup {} { ::for {::set i 0;} {$i<[::llength $t4_data]} {::incr i;} { ::set T4Structure [::lindex $t4_data $i]; ::set BoxNumber 1; ::foreach OtherNumber {30 31 32 33 34 36 37 38 39 40 41 42 43 53 57 58 59 60 66 67 68 69 70 71 72 73 74 75 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 94 95 97 98 99} { ::if {![::sargs::exists $T4Structure ".$OtherNumber"]} { ::continue; } ::set OtherAmount [::sargs::get $T4Structure ".$OtherNumber"]; ::sargs::var::set T4Structure ".other/$BoxNumber.box_number" $OtherNumber; ::sargs::var::set T4Structure ".other/$BoxNumber.amount" $OtherAmount; ::incr BoxNumber; } ::set t4_data [::lreplace $t4_data $i $i $T4Structure]; } } method data_item {s_args} { ::set Name [::sargs::get $s_args ".name"]; ::set Suffix [::sargs::get $s_args ".suffix"]; ::if {$Suffix eq ""} {::set Suffix 1;} ::incr Suffix -1; ::set Data [::lindex $t4_data $Suffix]; ::set Reference [::lindex $_references $Suffix]; ::if {$Data eq ""} { ::if {$Name eq "VOID"} {::return "X";} ::return ""; } ::switch -- $Name { "BOX10" {::return [::sargs::get $Data ".10"];} "BOX12" { ::set Sin [::sargs::get $Data ".12"]; ::return "[::string range $Sin 0 2] [::string range $Sin 3 5] [::string range $Sin 6 8]"; } "BOX14" {::return [::sargs::get $Data ".14"];} "BOX16" {::return [::sargs::get $Data ".16"];} "BOX17" {::return [::sargs::get $Data ".17"];} "BOX16A" { ::return [::sargs::get $Data ".16A"]; } "BOX17A" { ::return [::sargs::get $Data ".17A"]; } "BOX18" {::return [::sargs::get $Data ".18"];} "BOX20" {::return [::sargs::get $Data ".20"];} "BOX22" {::return [::sargs::get $Data ".22"];} "BOX24" { ::set Result [::sargs::get $Data ".24"]; ::return $Result; } "BOX26" { ::set Result [::sargs::get $Data ".26"]; ::return $Result; } "BOX29" {::return [::sargs::get $Data ".29"];} "BOX44" {::return [::sargs::get $Data ".44"];} "BOX45" { ::return [::expr {[::sargs::get $Data ".45"] eq ""?1:[::sargs::get $Data ".45"]}]; } "BOX46" {::return [::sargs::get $Data ".46"];} "BOX50" {::return [::sargs::get $settings ".pension_plan_registration_number"];} "BOX52" {::return [::sargs::get $Data ".52"];} "BOX54" { ::if {[::sargs::get $settings ".copies"]==2} {::return "";} ::return [::sargs::get $settings ".business_number"]; } "BOX55" { ::return [::sargs::get $Data ".55"]; } "BOX56" { ::return [::sargs::get $Data ".56"]; } "BOX28CPP" { ::set Result [::sargs::get $Data ".28/cpp"]; ::if {$Result} {::return "X";} ::return ""; } "BOX28EI" { ::set Result [::sargs::get $Data ".28/ei"]; ::if {$Result} {::return "X";} ::return ""; } "BOX28PPIP" { ::set Result [::sargs::get $Data ".28/ppip"]; ::if {$Result} {::return "X";} ::return ""; } "EMPLOYEEADDRESS" {::return [address_printable [[$Reference odb_master] ".address"]];} "EMPLOYEENAME" { ::set Result ""; ::append Result [::sargs::get $Data ".name.last"]; ::append Result " "; ::append Result [::sargs::get $Data ".name.first"]; ::append Result " "; ::append Result [::sargs::get $Data ".name.initial"]; ::return [::string trim $Result]; } "OTHERBOX1" {::return [::sargs::get $Data ".other/1.box_number"];} "OTHERBOX2" {::return [::sargs::get $Data ".other/2.box_number"];} "OTHERBOX3" {::return [::sargs::get $Data ".other/3.box_number"];} "OTHERBOX4" {::return [::sargs::get $Data ".other/4.box_number"];} "OTHERBOX5" {::return [::sargs::get $Data ".other/5.box_number"];} "OTHERBOX6" {::return [::sargs::get $Data ".other/6.box_number"];} "OTHERBOX7" {::return [::sargs::get $Data ".other/7.box_number"];} "OTHERBOX8" {::return [::sargs::get $Data ".other/8.box_number"];} "OTHERBOX9" {::return [::sargs::get $Data ".other/9.box_number"];} "OTHERBOX1AMOUNT" {::return [::sargs::get $Data ".other/1.amount"];} "OTHERBOX2AMOUNT" {::return [::sargs::get $Data ".other/2.amount"];} "OTHERBOX3AMOUNT" {::return [::sargs::get $Data ".other/3.amount"];} "OTHERBOX4AMOUNT" {::return [::sargs::get $Data ".other/4.amount"];} "OTHERBOX5AMOUNT" {::return [::sargs::get $Data ".other/5.amount"];} "OTHERBOX6AMOUNT" {::return [::sargs::get $Data ".other/6.amount"];} "OTHERBOX7AMOUNT" {::return [::sargs::get $Data ".other/7.amount"];} "OTHERBOX8AMOUNT" {::return [::sargs::get $Data ".other/8.amount"];} "OTHERBOX9AMOUNT" {::return [::sargs::get $Data ".other/9.amount"];} "YEAR" {::return [::sargs::get $Data ".year"];} "EMPLOYERNAME" {::return [::sargs::get $settings ".filers_name"];} "EMPLOYERADDRESS1" { ::return [::sargs::get $settings ".filers_street"]; } "EMPLOYERADDRESS2" { ::if {[::sargs::get $settings ".filers_street2"] ne ""} { ::return [::sargs::get $settings ".filers_street2"]; } ::return [city_state_zipcode_printable_from_qw_structure [::list \ .city "[::sargs::get $settings .filers_city]" \ .state "[::sargs::get $settings .filers_state]" \ .zipcode "[::sargs::get $settings .filers_zipcode]" \ ]]; } "EMPLOYERADDRESS3" { ::if {[::sargs::get $settings ".filers_street2"] eq ""} { ::return ""; } ::return [city_state_zipcode_printable_from_qw_structure [::list \ .city "[::sargs::get $settings .filers_city]" \ .state "[::sargs::get $settings .filers_state]" \ .zipcode "[::sargs::get $settings .filers_zipcode]" \ ]]; } "EMPLOYERADDRESS4" { } "EMPLOYERSTREET" {::return [::sargs::get $settings ".filers_street"];} "EMPLOYERSTREET2" {::return [::sargs::get $settings ".filers_street2"];} "EMPLOYERCITY" {::return [::sargs::get $settings ".filers_city"];} "EMPLOYERSTATE" {::return [::sargs::get $settings ".filers_state"];} "EMPLOYERCOUNTRY" {::return [::sargs::get $settings ".filers_country"];} "EMPLOYERPOSTAL" {::return [::sargs::get $settings ".filers_zipcode"];} "EMPLOYERCITYSTATEZIP" { ::return [city_state_zipcode_printable_from_qw_structure [::list \ .city "[::sargs::get $settings .filers_city]" \ .state "[::sargs::get $settings .filers_state]" \ .zipcode "[::sargs::get $settings .filers_zipcode]" \ ]]; } "VOID" {::return "";} } ::return ""; } } ::itcl::class ::qw::print::windows::template::t4_summary { inherit ::qw::print::windows::template; public variable t4_data ""; public variable settings ""; public method _VOID {s_args} {::return [data_item $s_args];} public method _PREPDATE {s_args} {::return [data_item $s_args];} public method _PREPPOSITION {s_args} {::return [data_item $s_args];} public method _FYEDATE {s_args} {::return [data_item $s_args];} public method _BEGINREMITDATE {s_args} {::return [data_item $s_args];} public method _ENDREMITDATE {s_args} {::return [data_item $s_args];} public method _BUSINESSNUMBER {s_args} {::return [data_item $s_args];} public method _PLANNUMBER {s_args} {::return [data_item $s_args];} public method _P1SIN {s_args} {::return [data_item $s_args];} public method _P2SIN {s_args} {::return [data_item $s_args];} public method _CONTACT {s_args} {::return [data_item $s_args];} public method _PHONEAREA {s_args} {::return [data_item $s_args];} public method _PHONENUMBER {s_args} {::return [data_item $s_args];} public method _PHONEEXTENSION {s_args} {::return [data_item $s_args];} public method _EMAIL {s_args} {::return [data_item $s_args];} public method _YEAR {s_args} {::return [data_item $s_args];} public method _EMPLOYERNAME {s_args} {::return [data_item $s_args];} public method _EMPLOYERSTREET {s_args} {::return [data_item $s_args];} public method _EMPLOYERSTREET2 {s_args} {::return [data_item $s_args];} public method _EMPLOYERCITY {s_args} {::return [data_item $s_args];} public method _EMPLOYERSTATE {s_args} {::return [data_item $s_args];} public method _EMPLOYERCOUNTRY {s_args} {::return [data_item $s_args];} public method _EMPLOYERPOSTAL {s_args} {::return [data_item $s_args];} public method _BOX14 {s_args} {::return [data_item $s_args];} public method _BOX16 {s_args} {::return [data_item $s_args];} public method _BOX18 {s_args} {::return [data_item $s_args];} public method _BOX19 {s_args} {::return [data_item $s_args];} public method _BOX20 {s_args} {::return [data_item $s_args];} public method _BOX22 {s_args} {::return [data_item $s_args];} public method _BOX27 {s_args} {::return [data_item $s_args];} public method _BOX52 {s_args} {::return [data_item $s_args];} public method _BOX80 {s_args} {::return [data_item $s_args];} public method _BOX82 {s_args} {::return [data_item $s_args];} public method _BOX84 {s_args} {::return [data_item $s_args];} public method _BOX86 {s_args} {::return [data_item $s_args];} public method _BOX88 {s_args} {::return [data_item $s_args];} public method _BOX89 {s_args} {::return [data_item $s_args];} public method _BOX16W {s_args} {::return [data_item $s_args];} public method _BOX16R {s_args} {::return [data_item $s_args];} public method _BOX16D {s_args} {::return [data_item $s_args];} public method _BOX18W {s_args} {::return [data_item $s_args];} public method _BOX18R {s_args} {::return [data_item $s_args];} public method _BOX18D {s_args} {::return [data_item $s_args];} public method _BOX19W {s_args} {::return [data_item $s_args];} public method _BOX19R {s_args} {::return [data_item $s_args];} public method _BOX19D {s_args} {::return [data_item $s_args];} public method _BOX22W {s_args} {::return [data_item $s_args];} public method _BOX22R {s_args} {::return [data_item $s_args];} public method _BOX22D {s_args} {::return [data_item $s_args];} public method _BOX27W {s_args} {::return [data_item $s_args];} public method _BOX27R {s_args} {::return [data_item $s_args];} public method _BOX27D {s_args} {::return [data_item $s_args];} public method _BOX16A {s_args} {::return [data_item $s_args];} public method _BOX16AW {s_args} {::return [data_item $s_args];} public method _BOX16AR {s_args} {::return [data_item $s_args];} public method _BOX16AD {s_args} {::return [data_item $s_args];} public method _BOX27A {s_args} {::return [data_item $s_args];} public method _BOX27AW {s_args} {::return [data_item $s_args];} public method _BOX27AR {s_args} {::return [data_item $s_args];} public method _BOX27AD {s_args} {::return [data_item $s_args];} public method _DIFFERENCE {s_args} {::return [data_item $s_args];} constructor {args} { ::eval ::qw::print::windows::template::constructor $args; } { } destructor { } public method load {Src} { chain $Src; } method data_item {s_args} { ::set Name [::sargs::get $s_args ".name"]; ::set Data $t4_data; ::switch -- $Name { "BOX14" {::return [::sargs::get $Data ".14"];} "BOX16" {::return [::sargs::get $Data ".16"];} "BOX18" {::return [::sargs::get $Data ".18"];} "BOX19" {::return [::sargs::get $Data ".19"];} "BOX20" {::return [::sargs::get $Data ".20"];} "BOX22" {::return [::sargs::get $Data ".22"];} "BOX27" {::return [::sargs::get $Data ".27"];} "BOX52" {::return [::sargs::get $Data ".52"];} "BOX80" {::return [::sargs::get $Data ".80"];} "BOX82" {::return [::sargs::get $Data ".82"];} "BOX84" {::return [::sargs::get $Data ".84"];} "BOX86" {::return [::sargs::get $Data ".86"];} "BOX88" {::return [::sargs::get $Data ".88"];} "BOX89" {::return [::sargs::get $Data ".89"];} YEAR {::return [::string range [::sargs::get $Data ".year"] 2 3];} "BOX16W" {::return [::sargs::get $Data ".16W"];} "BOX16R" {::return [::sargs::get $Data ".16R"];} "BOX16D" {::return [::sargs::get $Data ".16D"];} "BOX18W" {::return [::sargs::get $Data ".18W"];} "BOX18R" {::return [::sargs::get $Data ".18R"];} "BOX18D" {::return [::sargs::get $Data ".18D"];} "BOX19W" {::return [::sargs::get $Data ".19W"];} "BOX19R" {::return [::sargs::get $Data ".19R"];} "BOX19D" {::return [::sargs::get $Data ".19D"];} "BOX22W" {::return [::sargs::get $Data ".22W"];} "BOX22R" {::return [::sargs::get $Data ".22R"];} "BOX22D" {::return [::sargs::get $Data ".22D"];} "BOX27W" {::return [::sargs::get $Data ".27W"];} "BOX27R" {::return [::sargs::get $Data ".27R"];} "BOX27D" {::return [::sargs::get $Data ".27D"];} "EMPLOYERNAME" {::return [::sargs::get $settings ".filers_name"];} "EMPLOYERSTREET" {::return [::sargs::get $settings ".filers_street"];} "EMPLOYERSTREET2" {::return [::sargs::get $settings ".filers_street2"];} "EMPLOYERCITY" {::return [::sargs::get $settings ".filers_city"];} "EMPLOYERSTATE" {::return [::sargs::get $settings ".filers_state"];} "EMPLOYERCOUNTRY" {::return [::sargs::get $settings ".filers_country"];} "EMPLOYERPOSTAL" {::return [::sargs::get $settings ".filers_zipcode"];} "VOID" {::return "";} "DIFFERENCE" {::return [::sargs::get $Data ".difference"];} "PREPDATE" {::return [::sargs::get $Data ".date_prepared"];} "PREPPOSITION" {::return [::sargs::get $Data ".preparer_position"];} "FYEDATE" {::return [::sargs::get $Data ".summary_year_end_date"];} "BEGINREMITDATE" {::return [::sargs::get $Data ".begin_remittance_date"];} "ENDREMITDATE" {::return [::sargs::get $Data ".end_remittance_date"];} "BUSINESSNUMBER" {::return [::sargs::get $Data ".business_number"];} "PLANNUMBER" {::return [::sargs::get $Data ".pension_plan_registration_number"];} "P1SIN" {::return [::sargs::get $Data ".proprietor_1_sin"];} "P2SIN" {::return [::sargs::get $Data ".proprietor_2_sin"];} "CONTACT" {::return [::sargs::get $Data ".filers_contact_name"];} "PHONEAREA" {::return [::sargs::get $Data ".filers_phone_area_code"];} "PHONENUMBER" {::return [::sargs::get $Data ".filers_phone_number"];} "PHONEEXTENSION" {::return [::sargs::get $Data ".filers_phone_extension"];} "EMAIL" {::return [::sargs::get $Data ".filers_email"];} } ::switch -- $Name { "BOX16A" {::return [::sargs::get $Data ".16A"];} "BOX16AW" {::return [::sargs::get $Data ".16AW"];} "BOX16AR" {::return [::sargs::get $Data ".16AR"];} "BOX16AD" {::return [::sargs::get $Data ".16AD"];} "BOX27A" {::return [::sargs::get $Data ".27A"];} "BOX27AW" {::return [::sargs::get $Data ".27AW"];} "BOX27AR" {::return [::sargs::get $Data ".27AR"];} "BOX27AD" {::return [::sargs::get $Data ".27AD"];} } ::return ""; } } ::itcl::class ::qw::print::windows::template::t4a { inherit ::qw::print::windows::template; public variable t4a_data ""; public variable settings ""; public method _VOID {s_args} {::return [data_item $s_args];} public method _YEAR {s_args} {::return [data_item $s_args];} public method _PAYERNAME {s_args} {::return [data_item $s_args];} public method _RECIPIENTLASTNAME {s_args} {::return [data_item $s_args];} public method _RECIPIENTFIRSTNAME {s_args} {::return [data_item $s_args];} public method _RECIPIENTINITIAL {s_args} {::return [data_item $s_args];} public method _RECIPIENTADDRESS {s_args} {::return [data_item $s_args];} public method _BOX015 {s_args} {::return [data_item $s_args];} public method _BOX012 {s_args} {::return [data_item $s_args];} public method _BOX013 {s_args} {::return [data_item $s_args];} public method _BOX016 {s_args} {::return [data_item $s_args];} public method _BOX018 {s_args} {::return [data_item $s_args];} public method _BOX020 {s_args} {::return [data_item $s_args];} public method _BOX022 {s_args} {::return [data_item $s_args];} public method _BOX024 {s_args} {::return [data_item $s_args];} public method _BOX048 {s_args} {::return [data_item $s_args];} public method _BOX061 {s_args} {::return [data_item $s_args];} public method _BOX076 {s_args} {::return [data_item $s_args];} public method _OTHERBOX1 {s_args} {::return [data_item $s_args];} public method _OTHERBOX2 {s_args} {::return [data_item $s_args];} public method _OTHERBOX3 {s_args} {::return [data_item $s_args];} public method _OTHERBOX4 {s_args} {::return [data_item $s_args];} public method _OTHERBOX5 {s_args} {::return [data_item $s_args];} public method _OTHERBOX6 {s_args} {::return [data_item $s_args];} public method _OTHERBOX7 {s_args} {::return [data_item $s_args];} public method _OTHERBOX8 {s_args} {::return [data_item $s_args];} public method _OTHERBOX9 {s_args} {::return [data_item $s_args];} public method _OTHERBOX10 {s_args} {::return [data_item $s_args];} public method _OTHERBOX11 {s_args} {::return [data_item $s_args];} public method _OTHERBOX12 {s_args} {::return [data_item $s_args];} public method _OTHERBOX1AMOUNT {s_args} {::return [data_item $s_args];} public method _OTHERBOX2AMOUNT {s_args} {::return [data_item $s_args];} public method _OTHERBOX3AMOUNT {s_args} {::return [data_item $s_args];} public method _OTHERBOX4AMOUNT {s_args} {::return [data_item $s_args];} public method _OTHERBOX5AMOUNT {s_args} {::return [data_item $s_args];} public method _OTHERBOX6AMOUNT {s_args} {::return [data_item $s_args];} public method _OTHERBOX7AMOUNT {s_args} {::return [data_item $s_args];} public method _OTHERBOX8AMOUNT {s_args} {::return [data_item $s_args];} public method _OTHERBOX9AMOUNT {s_args} {::return [data_item $s_args];} public method _OTHERBOX10AMOUNT {s_args} {::return [data_item $s_args];} public method _OTHERBOX11AMOUNT {s_args} {::return [data_item $s_args];} public method _OTHERBOX12AMOUNT {s_args} {::return [data_item $s_args];} constructor {args} { ::eval ::qw::print::windows::template::constructor $args; } { } destructor { } public method documentStart {} { chain; addressSourceSet; } public method load {Src} { ::set _references $Src; other_boxes_setup; chain [::lindex $_references 0]; } method other_boxes_setup {} { ::for {::set i 0;} {$i<[::llength $t4a_data]} {::incr i;} { ::set T4Structure [::lindex $t4a_data $i]; ::set ExcludeList "016 018 020 022 024 048"; ;#// these are pre-coded boxes on the slip - all remaining boxes train wreck through 12 other slots ::set BoxNumber 1; ::foreach {Box Description} [::QW::NEWVIEWS::PAYROLL::CANADA::t4a_box_number_and_description_list] { ::if {[::lsearch -exact $ExcludeList $Box]>=0} { ::continue; } ::if {![::sargs::exists $T4Structure ".$Box"]} { ::continue; } ::sargs::var::set T4Structure ".other/$BoxNumber.box_number" $Box; ::sargs::var::set T4Structure ".other/$BoxNumber.amount" [::sargs::get $T4Structure .$Box]; ::incr BoxNumber; } ::set t4a_data [::lreplace $t4a_data $i $i $T4Structure]; } } method data_item {s_args} { ::set Name [::sargs::get $s_args ".name"]; ::set Suffix [::sargs::get $s_args ".suffix"]; ::if {$Suffix eq ""} {::set Suffix 1;} ::incr Suffix -1; ::set Data [::lindex $t4a_data $Suffix]; ::set Reference [::lindex $_references $Suffix]; ::if {$Data eq ""} { ::if {$Name eq "VOID"} {::return "X";} ::return ""; } ::switch -- $Name { "VOID" {::return "";} "YEAR" {::return [::sargs::get $Data ".year"];} "PAYERNAME" { ::return [::sargs::get $settings ".filers_name"]; } "BOX012" { ::set Sin [::sargs::get $Data "/cra.social_insurance_number"]; ;#// this is a vendor account ::if {$Sin eq ""} { ::set Sin [::sargs::get $Data ".012"]; ;#// this is a payroll employee } ::return "[::string range $Sin 0 2] [::string range $Sin 3 5] [::string range $Sin 6 8]"; } "BOX013" { ::return [::sargs::get $Data "/cra.business_number"]; ;#// the recipient's } "BOX015" { ::return [::expr {[::sargs::get $Data ".015"] eq ""?1:[::sargs::get $Data ".015"]}]; } "BOX016" {::return [::sargs::get $Data ".016"];} "BOX018" {::return [::sargs::get $Data ".018"];} "BOX020" {::return [::sargs::get $Data ".020"];} "BOX022" {::return [::sargs::get $Data ".022"];} "BOX024" {::return [::sargs::get $Data ".024"];} "BOX048" {::return [::sargs::get $Data ".048"];} "BOX061" { ::if {[::sargs::get $settings ".copies"]==2} {::return "";} ::return [::sargs::get $Data ".business_number"]; } "BOX076" { ::return [::sargs::get $Data ".filers_contact_name"]; ;#// the filer's } "RECIPIENTADDRESS" {::return [address_printable [[$Reference odb_master] ".address"]];} "RECIPIENTNAME" { ::set Result ""; ::append Result [::sargs::get $Data ".name.last"]; ::append Result " "; ::append Result [::sargs::get $Data ".name.first"]; ::append Result " "; ::append Result [::sargs::get $Data ".name.initial"]; ::return [::string trim $Result]; } "RECIPIENTFIRSTNAME" {::return [::sargs::get $Data ".name.first"];} "RECIPIENTLASTNAME" {::return [::sargs::get $Data ".name.last"];} "RECIPIENTINITIAL" {::return [::sargs::get $Data ".name.initial"];} "OTHERBOX1" {::return [::sargs::get $Data ".other/1.box_number"];} "OTHERBOX2" {::return [::sargs::get $Data ".other/2.box_number"];} "OTHERBOX3" {::return [::sargs::get $Data ".other/3.box_number"];} "OTHERBOX4" {::return [::sargs::get $Data ".other/4.box_number"];} "OTHERBOX5" {::return [::sargs::get $Data ".other/5.box_number"];} "OTHERBOX6" {::return [::sargs::get $Data ".other/6.box_number"];} "OTHERBOX7" {::return [::sargs::get $Data ".other/7.box_number"];} "OTHERBOX8" {::return [::sargs::get $Data ".other/8.box_number"];} "OTHERBOX9" {::return [::sargs::get $Data ".other/9.box_number"];} "OTHERBOX10" {::return [::sargs::get $Data ".other/10.box_number"];} "OTHERBOX11" {::return [::sargs::get $Data ".other/11.box_number"];} "OTHERBOX12" {::return [::sargs::get $Data ".other/12.box_number"];} "OTHERBOX1AMOUNT" {::return [::sargs::get $Data ".other/1.amount"];} "OTHERBOX2AMOUNT" {::return [::sargs::get $Data ".other/2.amount"];} "OTHERBOX3AMOUNT" {::return [::sargs::get $Data ".other/3.amount"];} "OTHERBOX4AMOUNT" {::return [::sargs::get $Data ".other/4.amount"];} "OTHERBOX5AMOUNT" {::return [::sargs::get $Data ".other/5.amount"];} "OTHERBOX6AMOUNT" {::return [::sargs::get $Data ".other/6.amount"];} "OTHERBOX7AMOUNT" {::return [::sargs::get $Data ".other/7.amount"];} "OTHERBOX8AMOUNT" {::return [::sargs::get $Data ".other/8.amount"];} "OTHERBOX9AMOUNT" {::return [::sargs::get $Data ".other/9.amount"];} "OTHERBOX10AMOUNT" {::return [::sargs::get $Data ".other/10.amount"];} "OTHERBOX11AMOUNT" {::return [::sargs::get $Data ".other/11.amount"];} "OTHERBOX12AMOUNT" {::return [::sargs::get $Data ".other/12.amount"];} } ::return ""; } } ::itcl::class ::qw::print::windows::template::t4a_summary { inherit ::qw::print::windows::template; public variable t4a_data ""; public variable settings ""; public method _VOID {s_args} {::return [data_item $s_args];} public method _YEAR {s_args} {::return [data_item $s_args];} public method _PREPDATE {s_args} {::return [data_item $s_args];} public method _PREPPOSITION {s_args} {::return [data_item $s_args];} public method _FYEDATE {s_args} {::return [data_item $s_args];} public method _BEGINREMITDATE {s_args} {::return [data_item $s_args];} public method _ENDREMITDATE {s_args} {::return [data_item $s_args];} public method _BUSINESSNUMBER {s_args} {::return [data_item $s_args];} public method _PLANNUMBER {s_args} {::return [data_item $s_args];} public method _P1SIN {s_args} {::return [data_item $s_args];} public method _P2SIN {s_args} {::return [data_item $s_args];} public method _CONTACT {s_args} {::return [data_item $s_args];} public method _PHONEAREA {s_args} {::return [data_item $s_args];} public method _PHONENUMBER {s_args} {::return [data_item $s_args];} public method _PHONEEXTENSION {s_args} {::return [data_item $s_args];} public method _EMAIL {s_args} {::return [data_item $s_args];} public method _PAYERNAME {s_args} {::return [data_item $s_args];} public method _PAYERLEGALNAME {s_args} {::return [data_item $s_args];} public method _PAYERSTREET {s_args} {::return [data_item $s_args];} public method _PAYERSTREET2 {s_args} {::return [data_item $s_args];} public method _PAYERCITY {s_args} {::return [data_item $s_args];} public method _PAYERSTATE {s_args} {::return [data_item $s_args];} public method _PAYERCOUNTRY {s_args} {::return [data_item $s_args];} public method _PAYERPOSTAL {s_args} {::return [data_item $s_args];} public method _PAYERCITYPROVINCEPOSTAL {s_args} {::return [data_item $s_args];} public method _BOX016 {s_args} {::return [data_item $s_args];} public method _BOX018 {s_args} {::return [data_item $s_args];} public method _BOX020 {s_args} {::return [data_item $s_args];} public method _BOX022 {s_args} { ::return [data_item $s_args]; } public method _BOX024 {s_args} {::return [data_item $s_args];} public method _BOX028 {s_args} {::return [data_item $s_args];} public method _BOX030 {s_args} {::return [data_item $s_args];} public method _BOX032 {s_args} {::return [data_item $s_args];} public method _BOX034 {s_args} {::return [data_item $s_args];} public method _BOX040 {s_args} {::return [data_item $s_args];} public method _BOX042 {s_args} {::return [data_item $s_args];} public method _BOX048 {s_args} {::return [data_item $s_args];} public method _BOX071 {s_args} { ::return [data_item $s_args]; } public method _BOX072 {s_args} {::return [data_item $s_args];} public method _BOX073 {s_args} {::return [data_item $s_args];} public method _BOX074 {s_args} {::return [data_item $s_args];} public method _BOX075 {s_args} {::return [data_item $s_args];} public method _BOX076 {s_args} {::return [data_item $s_args];} public method _BOX082 {s_args} { ::return [data_item $s_args]; } public method _BOX022W {s_args} {::return [data_item $s_args];} public method _BOX022R {s_args} {::return [data_item $s_args];} public method _BOX022D {s_args} {::return [data_item $s_args];} public method _BOX084 {s_args} {::return [data_item $s_args];} public method _BOX086 {s_args} {::return [data_item $s_args];} public method _BOX088 {s_args} {::return [data_item $s_args];} public method _BOX101 {s_args} {::return [data_item $s_args];} public method _DIFFERENCE {s_args} { ::return [data_item $s_args]; } constructor {args} { ::eval ::qw::print::windows::template::constructor $args; } { } destructor { } public method load {Src} { chain $Src; } method data_item {s_args} { ::set Name [::sargs::get $s_args ".name"]; ::set Data $t4a_data; ::switch -glob -- $Name { VOID {::return "";} YEAR {::return [::string range [::sargs::get $Data ".year"] 2 3];} PREPPOSITION {::return [::sargs::get $Data ".preparer_position"];} PAYERNAME {::return [::sargs::get $settings ".filers_name"];} PAYERLEGALNAME {::return [::sargs::get $settings ".filers_name"];} PAYERSTREET {::return [::sargs::get $settings ".filers_street"];} PAYERSTREET2 {::return [::sargs::get $settings ".filers_street2"];} PAYERCITY {::return [::sargs::get $settings ".filers_city"];} PAYERSTATE {::return [::sargs::get $settings ".filers_state"];} PAYERCOUNTRY {::return [::sargs::get $settings ".filers_country"];} PAYERPOSTAL {::return [::sargs::get $settings ".filers_zipcode"];} PAYERCITYPROVINCEPOSTAL { ::return "[::sargs::get $settings .filers_city] [::sargs::get $settings .filers_state] [::sargs::get $settings .filers_zipcode]"; } DIFFERENCE {::return [::sargs::get $Data ".difference"];} PREPDATE {::return [::sargs::get $Data ".date_prepared"];} FYEDATE {::return [::sargs::get $Data ".summary_year_end_date"];} BEGINREMITDATE {::return [::sargs::get $Data ".begin_remittance_date"];} ENDREMITDATE {::return [::sargs::get $Data ".end_remittance_date"];} BUSINESSNUMBER {::return [::sargs::get $Data ".business_number"];} PLANNUMBER {::return [::sargs::get $Data ".pension_plan_registration_number"];} P1SIN {::return [::sargs::get $Data ".proprietor_1_sin"];} P2SIN {::return [::sargs::get $Data ".proprietor_2_sin"];} CONTACT {::return [::sargs::get $Data ".filers_contact_name"];} PHONEAREA {::return [::sargs::get $Data ".filers_phone_area_code"];} PHONENUMBER {::return [::sargs::get $Data ".filers_phone_number"];} PHONEEXTENSION {::return [::sargs::get $Data ".filers_phone_extension"];} EMAIL {::return [::sargs::get $Data ".filers_email"];} BOX071 {::return [::lindex [::sargs::get $Data .pension_plan_registration_number] 0];} BOX072 {::return [::lindex [::sargs::get $Data .pension_plan_registration_number] 1];} BOX073 {::return [::lindex [::sargs::get $Data .pension_plan_registration_number] 2];} BOX074 {::return [::sargs::get $Data ".proprietor_1_sin"];} BOX075 {::return [::sargs::get $Data ".proprietor_2_sin"];} BOX076 {::return [::sargs::get $Data ".filers_contact_name"];} BOX101 {::return [::sargs::get $Data ".total_all_remaining_boxes"];} BOX* { ::return [::sargs::get $Data ".[::string map {BOX ""} $Name]"]; } } ::return ""; } } ::itcl::class ::qw::print::windows::template::t5018 { inherit ::qw::print::windows::template; public variable t5018_data ""; public variable settings ""; public method _VOID {s_args} {::return [data_item $s_args];} public method _RIN {s_args} {::return [data_item $s_args];} public method _BOX12 {s_args} {::return [data_item $s_args];} public method _BOX20 {s_args} {::return [data_item $s_args];} public method _BOX22 {s_args} {::return [data_item $s_args];} public method _BOX54 {s_args} {::return [data_item $s_args];} public method _RECIPIENTNAME {s_args} {::return [data_item $s_args];} public method _RECIPIENTADDRESS {s_args} {::return [data_item $s_args];} public method _PAYERNAME {s_args} {::return [data_item $s_args];} public method _YEAR {s_args} {::return [data_item $s_args];} constructor {args} { ::eval ::qw::print::windows::template::constructor $args; } { } destructor { } public method documentStart {} { chain; addressSourceSet; } public method load {Src} { ::set _references $Src; chain [::lindex $_references 0]; } method data_item {s_args} { ::set Name [::sargs::get $s_args ".name"]; ::set Suffix [::sargs::get $s_args ".suffix"]; ::if {$Suffix eq ""} {::set Suffix 1;} ::incr Suffix -1; ::set Data [::lindex $t5018_data $Suffix]; ::if {$Data eq ""} { ::if {$Name eq "VOID"} {::return "X";} ::return ""; } ::set Reference [::lindex $_references $Suffix]; ::set Master [$Reference odb_master]; ::switch -- $Name { "VOID" {::return "";} "RIN" { ::return [::sargs::get $Data "/cra.business_number"]; } "BOX12" { ::return [::string map {" " ""} [::sargs::get $Data "/cra.social_insurance_number"]]; } "BOX20" { ::return [::sargs::get $settings ".for_the_year_ending"]; } "BOX22" {::return [::sargs::get $Data ".t5018_amount"];} "BOX54" { ::if {[::sargs::get $settings ".copies"]==2} { ::return ""; } ::return [::sargs::get $settings ".business_number"]; } "RECIPIENTADDRESS" {::return [address_printable [$Master ".address"]];} "RECIPIENTNAME" { ::return [::sargs::get $Data "/t5018.recipient_name"]; ;#// provided by t5018_amounts (respecting /t0518.recipient_type) } "PAYERNAME" {::return [::sargs::get $settings ".filers_name"];} } ::return ""; } } ::itcl::class ::qw::print::windows::template::t5018_summary { inherit ::qw::print::windows::template; public variable t5018_summary_data ""; public variable settings ""; public method _VOID {s_args} {::return [data_item $s_args];} public method _PREPDATE {s_args} {::return [data_item $s_args];} public method _PREPPOSITION {s_args} {::return [data_item $s_args];} public method _PERIODENDING {s_args} {::return [data_item $s_args];} public method _BUSINESSNUMBER {s_args} {::return [data_item $s_args];} public method _ENGLISH {s_args} {::return [data_item $s_args];} public method _FRENCH {s_args} {::return [data_item $s_args];} public method _PAYERNAME {s_args} {::return [data_item $s_args];} public method _PAYERLEGALNAME {s_args} {::return [data_item $s_args];} public method _PAYERTRADENAME {s_args} {::return [data_item $s_args];} public method _PAYERSTREET {s_args} {::return [data_item $s_args];} public method _PAYERSTREET2 {s_args} {::return [data_item $s_args];} public method _PAYERCITY {s_args} {::return [data_item $s_args];} public method _PAYERSTATE {s_args} {::return [data_item $s_args];} public method _PAYERCOUNTRY {s_args} {::return [data_item $s_args];} public method _PAYERPOSTAL {s_args} {::return [data_item $s_args];} public method _CONTACT {s_args} {::return [data_item $s_args];} public method _CONTACTLASTNAME {s_args} {::return [data_item $s_args];} public method _CONTACTFIRSTNAME {s_args} {::return [data_item $s_args];} public method _PHONEAREA {s_args} {::return [data_item $s_args];} public method _PHONENUMBER {s_args} {::return [data_item $s_args];} public method _PHONEEXTENSION {s_args} {::return [data_item $s_args];} public method _EMAIL {s_args} {::return [data_item $s_args];} public method _BOX80 {s_args} {::return [data_item $s_args];} public method _BOX82 {s_args} {::return [data_item $s_args];} constructor {args} { ::eval ::qw::print::windows::template::constructor $args; } { } destructor { } public method load {Src} { chain $Src; } method data_item {s_args} { ::set Name [::sargs::get $s_args ".name"]; ::set Data $t5018_summary_data; ::switch -- $Name { "VOID" {::return "";} "PREPDATE" {::return [::sargs::get $settings ".date_prepared"];} "PREPPOSITION" {::return [::sargs::get $settings ".position_of_preparer"];} "BOX80" {::return [::sargs::get $Data ".slip_count"];} "BOX82" {::return [::sargs::get $Data ".slip_amount_total"];} "PERIODENDING" { ::return [::sargs::get $settings ".for_the_year_ending"]; } "PAYERLEGALNAME" {::return [::sargs::get $settings ".payers_legal_name"];} "PAYERTRADENAME" {::return [::sargs::get $settings ".payers_trade_name"];} "PAYERNAME" {::return [::sargs::get $settings ".filers_name"];} "PAYERSTREET" {::return [::sargs::get $settings ".filers_street"];} "PAYERSTREET2" {::return [::sargs::get $settings ".filers_street2"];} "PAYERCITY" {::return [::sargs::get $settings ".filers_city"];} "PAYERSTATE" {::return [::sargs::get $settings ".filers_state"];} "PAYERCOUNTRY" {::return [::sargs::get $settings ".filers_country"];} "PAYERPOSTAL" {::return [::sargs::get $settings ".filers_zipcode"];} "BUSINESSNUMBER" {::return [::sargs::get $settings ".business_number"];} "CONTACT" {::return [::sargs::get $settings ".filers_contact_name"];} "CONTACTFIRSTNAME" {::return [::sargs::get $settings ".filers_contact_name"];} "CONTACTLASTNAME" {::return [::sargs::get $settings ".filers_contact_name"];} "PHONEAREA" {::return [::sargs::get $settings ".filers_phone_area_code"];} "PHONENUMBER" {::return [::sargs::get $settings ".filers_phone_number"];} "PHONEEXTENSION" {::return [::sargs::get $settings ".filers_phone_extension"];} "ENGLISH" { ::if {[::sargs::get $settings ".language"] eq "english"} {::return "X";} ::return ""; } "FRENCH" { ::if {[::sargs::get $settings ".language"] eq "french"} {::return "X";} ::return ""; } } ::return ""; } } ::itcl::class ::qw::print::windows::template::t5 { inherit ::qw::print::windows::template; public variable t5_data ""; public variable settings ""; public method _VOID {s_args} {::return [data_item $s_args];} public method _CITYSTATEZIP {s_args} {::return [data_item $s_args];} public method _RIN {s_args} {::return [data_item $s_args];} public method _BOX10 {s_args} {::return [data_item $s_args];} public method _BOX11 {s_args} {::return [data_item $s_args];} public method _BOX12 {s_args} {::return [data_item $s_args];} public method _BOX13 {s_args} {::return [data_item $s_args];} public method _BOX18 {s_args} {::return [data_item $s_args];} public method _BOX21 {s_args} {::return [data_item $s_args];} public method _BOX22 {s_args} {::return [data_item $s_args];} public method _BOX23 {s_args} {::return [data_item $s_args];} public method _BOX24 {s_args} {::return [data_item $s_args];} public method _BOX25 {s_args} {::return [data_item $s_args];} public method _BOX26 {s_args} {::return [data_item $s_args];} public method _BOX27 {s_args} {::return [data_item $s_args];} public method _BOX28 {s_args} {::return [data_item $s_args];} public method _BOX29 {s_args} {::return [data_item $s_args];} public method _RECIPIENTNAME {s_args} {::return [data_item $s_args];} public method _RECIPIENTLASTNAME {s_args} {::return [data_item $s_args];} public method _RECIPIENTFIRSTNAME {s_args} {::return [data_item $s_args];} public method _RECIPIENTINITIAL {s_args} {::return [data_item $s_args];} public method _RECIPIENTADDRESS {s_args} {::return [data_item $s_args];} public method _PAYERNAME {s_args} {::return [data_item $s_args];} public method _PAYERADDRESS {s_args} {::return [data_item $s_args];} public method _YEAR {s_args} {::return [data_item $s_args];} public method _OTHERBOX1 {s_args} {::return [data_item $s_args];} public method _OTHERBOX2 {s_args} {::return [data_item $s_args];} public method _OTHERBOX3 {s_args} {::return [data_item $s_args];} public method _OTHERBOX1AMOUNT {s_args} {::return [data_item $s_args];} public method _OTHERBOX2AMOUNT {s_args} {::return [data_item $s_args];} public method _OTHERBOX3AMOUNT {s_args} {::return [data_item $s_args];} constructor {args} { ::eval ::qw::print::windows::template::constructor $args; } { } destructor { } public method documentStart {} { chain; addressSourceSet; } public method load {Src} { ::set _references $Src; other_boxes_setup; chain [::lindex $_references 0]; } method other_boxes_setup {} { ::for {::set i 0;} {$i<[::llength $t5_data]} {::incr i;} { ::set t5Structure [::lindex $t5_data $i]; ::set BoxNumber 1; ::foreach OtherNumber {14 15 16 17 19 20 30 34 40 41} { ::if {![::sargs::exists $t5Structure ".$OtherNumber"]} { ::continue; } ::set OtherAmount [::sargs::get $t5Structure ".$OtherNumber"]; ::sargs::var::set t5Structure ".other/$BoxNumber.box_number" $OtherNumber; ::sargs::var::set t5Structure ".other/$BoxNumber.amount" $OtherAmount; ::incr BoxNumber; } ::set t5_data [::lreplace $t5_data $i $i $t5Structure]; } } method data_item {s_args} { ::set Name [::sargs::get $s_args ".name"]; ::set Suffix [::sargs::get $s_args ".suffix"]; ::if {$Suffix eq ""} {::set Suffix 1;} ::incr Suffix -1; ::set Data [::lindex $t5_data $Suffix]; ::if {$Data eq ""} { ::if {$Name eq "VOID"} {::return "X";} ::return ""; } ::set Reference [::lindex $_references $Suffix]; ::set Master [$Reference odb_master]; ::switch -- $Name { "VOID" {::return "";} "CITYSTATEZIP" { ::return [city_state_zipcode_printable [$Master .address]]; } "YEAR" { ::return [::qw::date::get [::sargs::get $settings ".for_the_year_ending"] year]; } "BOX21" { ::switch [::sargs::get $Data ".settings_prompt.report_type"] { original {::return "O";} amended {::return "A";} cancelled {::return "C";} } } "BOX22" - "RIN" { ::switch [::sargs::get $Data /t5.recipient_type] { individual - joint { ::return [::sargs::get $Data "/cra.social_insurance_number"]; } corporation - partnership - government { ::return [::sargs::get $Data "/cra.business_number"]; ;#// the recipient's } } } "BOX23" { ::switch [::sargs::get $Data /t5.recipient_type] { individual {::return 1;} joint {::return 2;} corporation {::return 3;} partnership {::return 4;} government {::return 5;} } } "BOX10" {::return [::sargs::get $Data ".10"];} "BOX11" {::return [::sargs::get $Data ".11"];} "BOX12" {::return [::sargs::get $Data ".12"];} "BOX13" {::return [::sargs::get $Data ".13"];} "BOX18" {::return [::sargs::get $Data ".18"];} "BOX24" {::return [::sargs::get $Data ".24"];} "BOX25" {::return [::sargs::get $Data ".25"];} "BOX26" {::return [::sargs::get $Data ".26"];} "BOX27" {::return [::sargs::get $Data /t5.foreign_currency_indicator];} "BOX28" {::return [::sargs::get $Data /eft.bank_transit];} "BOX29" {::return [::sargs::get $Data /eft.bank_account];} "BOX54" { ::if {[::sargs::get $settings ".copies"]==2} { ::return ""; } ::return [::sargs::get $settings ".business_number"]; ;#// the filer's } "RECIPIENTADDRESS" {::return [address_printable [$Master ".address"]];} "RECIPIENTNAME" { ::set Result ""; ::append Result [[$Master .address.name.last] odb_get]; ::append Result " "; ::append Result [[$Master .address.name.first] odb_get]; ::append Result " "; ::append Result [::string range [[$Master .address.name.middle] odb_get] 0 0]; ::return [::string trim $Result]; } "RECIPIENTFIRSTNAME" { ::return [::sargs::get $Data ".address.name.first"]; } "RECIPIENTLASTNAME" {::return [::sargs::get $Data ".address.name.last"];} "RECIPIENTINITIAL" {::return [::string range [::sargs::get $Data ".address.name.middle"] 0 0];} "PAYERNAME" {::return [::sargs::get $settings ".filers_name"];} "PAYERADDRESS" {::return [::QW::NEWVIEWS::PAYROLL::CANADA::cra_setup_address_printable $settings];} "OTHERBOX1" {::return [::sargs::get $Data ".other/1.box_number"];} "OTHERBOX2" {::return [::sargs::get $Data ".other/2.box_number"];} "OTHERBOX3" {::return [::sargs::get $Data ".other/3.box_number"];} "OTHERBOX1AMOUNT" {::return [::sargs::get $Data ".other/1.amount"];} "OTHERBOX2AMOUNT" {::return [::sargs::get $Data ".other/2.amount"];} "OTHERBOX3AMOUNT" {::return [::sargs::get $Data ".other/3.amount"];} } ::return ""; } } ::itcl::class ::qw::print::windows::template::t5_summary { inherit ::qw::print::windows::template; public variable t5_summary_data ""; public variable settings ""; public method _VOID {s_args} {::return [data_item $s_args];} public method _FILERIDNUMBER {s_args} {::return [data_item $s_args];} public method _FILEDBEFOREYES {s_args} {::return [data_item $s_args];} public method _FILEDBEFORENO {s_args} {::return [data_item $s_args];} public method _ADDITIONALT5 {s_args} {::return [data_item $s_args];} public method _YEAR {s_args} {::return [data_item $s_args];} public method _PREPDATE {s_args} {::return [data_item $s_args];} public method _PREPPOSITION {s_args} {::return [data_item $s_args];} public method _PERIODENDING {s_args} {::return [data_item $s_args];} public method _BUSINESSNUMBER {s_args} {::return [data_item $s_args];} public method _ENGLISH {s_args} {::return [data_item $s_args];} public method _FRENCH {s_args} {::return [data_item $s_args];} public method _PAYERNAME {s_args} {::return [data_item $s_args];} public method _PAYERLEGALNAME {s_args} {::return [data_item $s_args];} public method _PAYERTRADENAME {s_args} {::return [data_item $s_args];} public method _PAYERSTREET {s_args} {::return [data_item $s_args];} public method _PAYERSTREET2 {s_args} {::return [data_item $s_args];} public method _PAYERCITY {s_args} {::return [data_item $s_args];} public method _PAYERSTATE {s_args} {::return [data_item $s_args];} public method _PAYERCOUNTRY {s_args} {::return [data_item $s_args];} public method _PAYERPOSTAL {s_args} {::return [data_item $s_args];} public method _CONTACT {s_args} {::return [data_item $s_args];} public method _CONTACTLASTNAME {s_args} {::return [data_item $s_args];} public method _CONTACTFIRSTNAME {s_args} {::return [data_item $s_args];} public method _PHONEAREA {s_args} {::return [data_item $s_args];} public method _PHONENUMBER {s_args} {::return [data_item $s_args];} public method _PHONEEXTENSION {s_args} {::return [data_item $s_args];} public method _EMAIL {s_args} {::return [data_item $s_args];} public method _BOX10 {s_args} {::return [data_item $s_args];} public method _BOX11 {s_args} {::return [data_item $s_args];} public method _BOX12 {s_args} {::return [data_item $s_args];} public method _BOX13 {s_args} {::return [data_item $s_args];} public method _BOX14 {s_args} {::return [data_item $s_args];} public method _BOX15 {s_args} {::return [data_item $s_args];} public method _BOX16 {s_args} {::return [data_item $s_args];} public method _BOX17 {s_args} {::return [data_item $s_args];} public method _BOX18 {s_args} {::return [data_item $s_args];} public method _BOX19 {s_args} {::return [data_item $s_args];} public method _BOX20 {s_args} {::return [data_item $s_args];} public method _BOX24 {s_args} {::return [data_item $s_args];} public method _BOX25 {s_args} {::return [data_item $s_args];} public method _BOX26 {s_args} {::return [data_item $s_args];} public method _BOX31 {s_args} {::return [data_item $s_args];} public method _BOX32 {s_args} {::return [data_item $s_args];} public method _BOX33 {s_args} {::return [data_item $s_args];} public method _BOX40 {s_args} {::return [data_item $s_args];} public method _BOX41 {s_args} {::return [data_item $s_args];} public method _BOX42 {s_args} {::return [data_item $s_args];} constructor {args} { ::eval ::qw::print::windows::template::constructor $args; } { } destructor { } public method load {Src} { chain $Src; } method data_item {s_args} { ::set Name [::sargs::get $s_args ".name"]; ::set Data $t5_summary_data; ::switch -- $Name { "VOID" {::return "";} "FILERIDNUMBER" {::return [::sargs::get $settings ".business_number"];} "FILEDBEFOREYES" { ::if {[::sargs::get $settings ".filed_before"] eq "yes"} { ::return "X"; } ::return ""; } "FILEDBEFORENO" { ::if {[::sargs::get $settings ".filed_before"] eq "no"} { ::return "X"; } ::return ""; } "ADDITIONALT5" { ::if {[::sargs::get $settings ".additional_summary"] eq "yes"} { ::return "X"; } ::return ""; } "YEAR" { ::return [::qw::date::get [::sargs::get $settings ".for_the_year_ending"] year]; } "PREPDATE" {::return [::sargs::get $settings ".date_prepared"];} "PREPPOSITION" {::return [::sargs::get $settings ".position_of_preparer"];} "PERIODENDING" { ::return [::sargs::get $settings ".for_the_year_ending"]; } "PAYERLEGALNAME" {::return [::sargs::get $settings ".payers_legal_name"];} "PAYERTRADENAME" {::return [::sargs::get $settings ".payers_trade_name"];} "PAYERNAME" {::return [::sargs::get $settings ".filers_name"];} "PAYERSTREET" {::return [::sargs::get $settings ".filers_street"];} "PAYERSTREET2" {::return [::sargs::get $settings ".filers_street2"];} "PAYERCITY" {::return [::sargs::get $settings ".filers_city"];} "PAYERSTATE" {::return [::sargs::get $settings ".filers_state"];} "PAYERCOUNTRY" {::return [::sargs::get $settings ".filers_country"];} "PAYERPOSTAL" {::return [::sargs::get $settings ".filers_zipcode"];} "BUSINESSNUMBER" {::return [::sargs::get $settings ".business_number"];} "CONTACT" {::return [::sargs::get $settings ".filers_contact_name"];} "CONTACTFIRSTNAME" {::return [::sargs::get $settings ".filers_contact_name"];} "CONTACTLASTNAME" {::return [::sargs::get $settings ".filers_contact_name"];} "PHONEAREA" {::return [::sargs::get $settings ".filers_phone_area_code"];} "PHONENUMBER" {::return [::sargs::get $settings ".filers_phone_number"];} "PHONEEXTENSION" {::return [::sargs::get $settings ".filers_phone_extension"];} "ENGLISH" { ::if {[::sargs::get $settings ".language"] eq "english"} {::return "X";} ::return ""; } "FRENCH" { ::if {[::sargs::get $settings ".language"] eq "french"} {::return "X";} ::return ""; } "BOX31" {::return [::sargs::get $Data ".slip_count"];} "BOX32" { ::return 0.0; } "BOX33" { ::return 0.0; } "BOX10" {::return [::sargs::get $Data ".10"];} "BOX11" {::return [::sargs::get $Data ".11"];} "BOX12" {::return [::sargs::get $Data ".12"];} "BOX13" {::return [::sargs::get $Data ".13"];} "BOX14" {::return [::sargs::get $Data ".14"];} "BOX15" {::return [::sargs::get $Data ".15"];} "BOX16" {::return [::sargs::get $Data ".16"];} "BOX17" {::return [::sargs::get $Data ".17"];} "BOX18" {::return [::sargs::get $Data ".18"];} "BOX19" {::return [::sargs::get $Data ".19"];} "BOX20" {::return [::sargs::get $Data ".20"];} "BOX24" {::return [::sargs::get $Data ".24"];} "BOX25" {::return [::sargs::get $Data ".25"];} "BOX26" {::return [::sargs::get $Data ".26"];} "BOX40" {::return [::sargs::get $Data ".40"];} "BOX41" { ::return [::sargs::get $settings ".filers_contact_name"]; ::return [::sargs::get $Data ".41"]; } "BOX42" { ::set Result ""; ::append Result [::sargs::get $settings ".filers_phone_area_code"]; ::append Result "-"; ::append Result [::sargs::get $settings ".filers_phone_number"]; ::append Result "-"; ::append Result [::sargs::get $settings ".filers_phone_area_extension"]; ::return $Result; } } ::return ""; } } ::itcl::class ::qw::print::windows::template::releve1 { inherit ::qw::print::windows::template; constructor {args} { ::eval ::qw::print::windows::template::constructor $args; } { } destructor { } public variable releve1_data ""; public variable settings ""; public method _BOXA {s_args} {::return [data_item $s_args];} public method _BOXB {s_args} {::return [data_item $s_args];} public method _BOXBA {s_args} {::return [data_item $s_args];} public method _BOXBB {s_args} {::return [data_item $s_args];} public method _BOXC {s_args} {::return [data_item $s_args];} public method _BOXD {s_args} {::return [data_item $s_args];} public method _BOXE {s_args} {::return [data_item $s_args];} public method _BOXF {s_args} {::return [data_item $s_args];} public method _BOXG {s_args} {::return [data_item $s_args];} public method _BOXH {s_args} {::return [data_item $s_args];} public method _BOXI {s_args} {::return [data_item $s_args];} public method _BOXJ {s_args} {::return [data_item $s_args];} public method _BOXK {s_args} {::return [data_item $s_args];} public method _BOXL {s_args} {::return [data_item $s_args];} public method _BOXM {s_args} {::return [data_item $s_args];} public method _BOXN {s_args} {::return [data_item $s_args];} public method _BOXO {s_args} {::return [data_item $s_args];} public method _BOXP {s_args} {::return [data_item $s_args];} public method _BOXQ {s_args} {::return [data_item $s_args];} public method _BOXR {s_args} {::return [data_item $s_args];} public method _BOXS {s_args} {::return [data_item $s_args];} public method _BOXT {s_args} {::return [data_item $s_args];} public method _BOXU {s_args} {::return [data_item $s_args];} public method _BOXV {s_args} {::return [data_item $s_args];} public method _BOXW {s_args} {::return [data_item $s_args];} public method _CODE {s_args} {::return [data_item $s_args];} public method _EMPLOYEEADDRESS {s_args} {::return [data_item $s_args];} public method _EMPLOYEENAME {s_args} {::return [data_item $s_args];} public method _EMPLOYERADDRESS1 {s_args} {::return [data_item $s_args];} public method _EMPLOYERADDRESS2 {s_args} {::return [data_item $s_args];} public method _EMPLOYERADDRESS3 {s_args} {::return [data_item $s_args];} public method _EMPLOYERADDRESS4 {s_args} {::return [data_item $s_args];} public method _EMPLOYERNAME {s_args} {::return [data_item $s_args];} public method _REFERENCENUMBER {s_args} {::return [data_item $s_args];} public method _SIN {s_args} {::return [data_item $s_args];} public method _UNKNOWN1 {s_args} {::return [data_item $s_args];} public method _UNKNOWN2 {s_args} {::return [data_item $s_args];} public method _YEAR {s_args} {::return [data_item $s_args];} public method documentStart {} { chain; addressSourceSet; } public method load {Src} { ::set _references $Src; chain [::lindex $_references 0]; } method data_item {s_args} { ::set Name [::sargs::get $s_args ".name"]; ::set Suffix [::sargs::get $s_args ".suffix"]; ::if {$Suffix eq ""} {::set Suffix 1;} ::incr Suffix -1; ::set Data [::lindex $releve1_data $Suffix]; ::set Reference [::lindex $_references $Suffix]; ::if {$Data eq ""} { ::return ""; } ::switch -- $Name { "BOXA" {::return [::sargs::get $Data ".a"];} "BOXB" {::return [::sargs::get $Data ".b"];} "BOXBA" {::return [::sargs::get $Data ".ba"];} "BOXBB" {::return [::sargs::get $Data ".bb"];} "BOXC" {::return [::sargs::get $Data ".c"];} "BOXD" {::return [::sargs::get $Data ".d"];} "BOXE" {::return [::sargs::get $Data ".e"];} "BOXF" {::return [::sargs::get $Data ".f"];} "BOXG" { ::set Result [::sargs::get $Data ".g"]; ::if {$Result eq ""} {::return "";} ::set BoxA [::sargs::get $Data ".a"];::if {$BoxA eq ""} {::set BoxA 0.0;} ::set BoxQ [::sargs::get $Data ".q"];::if {$BoxQ eq ""} {::set BoxQ 0.0;} ::set BoxU [::sargs::get $Data ".u"];::if {$BoxU eq ""} {::set BoxU 0.0;} ::set Total [::expr $BoxA+$BoxQ+$BoxU]; ::if {$Result==$Total} {::return "";} ::return $Result; } "BOXH" {::return [::sargs::get $Data ".h"];} "BOXI" {::return [::sargs::get $Data ".i"];} "BOXJ" {::return [::sargs::get $Data ".j"];} "BOXK" {::return [::sargs::get $Data ".k"];} "BOXL" {::return [::sargs::get $Data ".l"];} "BOXM" {::return [::sargs::get $Data ".m"];} "BOXN" {::return [::sargs::get $Data ".n"];} "BOXO" {::return [::sargs::get $Data ".o"];} "BOXP" {::return [::sargs::get $Data ".p"];} "BOXQ" {::return [::sargs::get $Data ".q"];} "BOXR" {::return [::sargs::get $Data ".r"];} "BOXS" {::return [::sargs::get $Data ".s"];} "BOXT" {::return [::sargs::get $Data ".t"];} "BOXU" {::return [::sargs::get $Data ".u"];} "BOXV" { ::return [::sargs::get $Data ".v"]; } "BOXW" { ::return [::sargs::get $Data ".w"]; } "CODE" {::return [::sargs::get $Data ".code"];} "EMPLOYEEADDRESS" {::return [address_printable [[$Reference odb_master] ".address"]];} "EMPLOYEENAME" { ::set Result ""; ::append Result [::sargs::get $Data ".name.last"]; ::append Result " "; ::append Result [::sargs::get $Data ".name.first"]; ::append Result " "; ::append Result [::sargs::get $Data ".name.initial"]; ::return [::string trim $Result]; } "EMPLOYERNAME" {::return [::sargs::get $settings ".employers_name"];} "EMPLOYERADDRESS1" {::return [::sargs::get $settings .employers_address_1];} "EMPLOYERADDRESS2" {::return [::sargs::get $settings .employers_address_2];} "EMPLOYERADDRESS3" {::return [::sargs::get $settings .employers_address_3];} "EMPLOYERADDRESS4" {::return [::sargs::get $settings .employers_address_4];} "REFERENCENUMBER" {::return [::sargs::get $Data ".employee_id"];} "SIN" {::return [::sargs::get $Data ".social_insurance_number"];} "UNKNOWN1" {::return [::sargs::get $Data ".unknown1"];} "UNKNOWN2" {::return [::sargs::get $Data ".unknown2"];} "YEAR" {::return [::sargs::get $Data ".year"];} } ::return ""; } } ::itcl::class ::qw::print::windows::template::w2 { inherit ::qw::print::windows::template; public variable w2_data ""; public variable settings ""; public method _BOX1 {s_args} {::return [data_item $s_args];} public method _BOX2 {s_args} {::return [data_item $s_args];} public method _BOX3 {s_args} {::return [data_item $s_args];} public method _BOX4 {s_args} {::return [data_item $s_args];} public method _BOX5 {s_args} {::return [data_item $s_args];} public method _BOX6 {s_args} {::return [data_item $s_args];} public method _BOX7 {s_args} {::return [data_item $s_args];} public method _BOX8 {s_args} {::return [data_item $s_args];} public method _BOX9 {s_args} {::return [data_item $s_args];} public method _BOX10 {s_args} {::return [data_item $s_args];} public method _BOX11 {s_args} {::return [data_item $s_args];} public method _BOX12ACODE {s_args} {::return [data_item $s_args];} public method _BOX12A {s_args} {::return [data_item $s_args];} public method _BOX12BCODE {s_args} {::return [data_item $s_args];} public method _BOX12B {s_args} {::return [data_item $s_args];} public method _BOX12CCODE {s_args} {::return [data_item $s_args];} public method _BOX12C {s_args} {::return [data_item $s_args];} public method _BOX12DCODE {s_args} {::return [data_item $s_args];} public method _BOX12D {s_args} {::return [data_item $s_args];} public method _BOX13A {s_args} {::return [data_item $s_args];} public method _BOX13B {s_args} {::return [data_item $s_args];} public method _BOX13C {s_args} {::return [data_item $s_args];} public method _BOX14A {s_args} {::return [data_item $s_args];} public method _BOX14B {s_args} {::return [data_item $s_args];} public method _BOX14C {s_args} {::return [data_item $s_args];} public method _BOX14D {s_args} {::return [data_item $s_args];} public method _BOX15ASTATE {s_args} {::return [data_item $s_args];} public method _BOX15A {s_args} {::return [data_item $s_args];} public method _BOX15BSTATE {s_args} {::return [data_item $s_args];} public method _BOX15B {s_args} {::return [data_item $s_args];} public method _BOX16A {s_args} {::return [data_item $s_args];} public method _BOX16B {s_args} {::return [data_item $s_args];} public method _BOX17A {s_args} {::return [data_item $s_args];} public method _BOX17B {s_args} {::return [data_item $s_args];} public method _BOX18A {s_args} {::return [data_item $s_args];} public method _BOX18B {s_args} {::return [data_item $s_args];} public method _BOX19A {s_args} {::return [data_item $s_args];} public method _BOX19B {s_args} {::return [data_item $s_args];} public method _BOX20A {s_args} {::return [data_item $s_args];} public method _BOX20B {s_args} {::return [data_item $s_args];} public method _BOXA {s_args} {::return [data_item $s_args];} public method _BOXB {s_args} {::return [data_item $s_args];} public method _EMPLOYERADDRESS1 {s_args} {::return [data_item $s_args];} public method _EMPLOYERADDRESS2 {s_args} {::return [data_item $s_args];} public method _EMPLOYERADDRESS3 {s_args} {::return [data_item $s_args];} public method _EMPLOYERADDRESS4 {s_args} {::return [data_item $s_args];} public method _EMPLOYERNAME {s_args} {::return [data_item $s_args];} public method _BOXD {s_args} {::return [data_item $s_args];} public method _BOXE {s_args} {::return [data_item $s_args];} public method _EMPLOYEEADDRESS {s_args} {::return [data_item $s_args];} public method _LASTNAME {s_args} {::return [data_item $s_args];} public method _YEAR {s_args} {::return [data_item $s_args];} public method _VOID {s_args} {::return [data_item $s_args];} constructor {args} { ::eval ::qw::print::windows::template::constructor $args; } { } destructor { } public method documentStart {} { addressSourceSet; ::return [chain]; } public method load {Src} { ::set _references $Src; chain [::lindex $_references 0]; } method data_item {s_args} { ::set Name [::sargs::get $s_args ".name"]; ::set Suffix [::sargs::get $s_args ".suffix"]; ::if {$Suffix eq ""} { ::set Suffix 1; } ::incr Suffix -1; ::set Data [::lindex $w2_data $Suffix]; ::set Reference [::lindex $_references $Suffix]; ::if {$Data eq ""} { ::if {$Name eq "VOID"} {::return "X";} ::return ""; } ::switch -- $Name { "BOX1" {::return [number_or_blank_if_zero [::sargs::get $Data ".1"]];} "BOX2" {::return [number_or_blank_if_zero [::sargs::get $Data ".2"]];} "BOX3" {::return [number_or_blank_if_zero [::sargs::get $Data ".3"]];} "BOX4" {::return [number_or_blank_if_zero [::sargs::get $Data ".4"]];} "BOX5" {::return [number_or_blank_if_zero [::sargs::get $Data ".5"]];} "BOX6" {::return [number_or_blank_if_zero [::sargs::get $Data ".6"]];} "BOX7" {::return [number_or_blank_if_zero [::sargs::get $Data ".7"]];} "BOX8" {::return [number_or_blank_if_zero [::sargs::get $Data ".8"]];} "BOX9" {::return [number_or_blank_if_zero [::sargs::get $Data ".9"]];} "BOX10" {::return [number_or_blank_if_zero [::sargs::get $Data ".10"]];} "BOX11" {::return [number_or_blank_if_zero [::sargs::get $Data ".11"]];} "BOX12ACODE" {::return [::sargs::get $Data ".12/a.code"];} "BOX12BCODE" {::return [::sargs::get $Data ".12/b.code"];} "BOX12CCODE" {::return [::sargs::get $Data ".12/c.code"];} "BOX12DCODE" {::return [::sargs::get $Data ".12/d.code"];} "BOX12A" {::return [number_or_blank_if_zero [::sargs::get $Data ".12/a.amount"]];} "BOX12B" {::return [number_or_blank_if_zero [::sargs::get $Data ".12/b.amount"]];} "BOX12C" {::return [number_or_blank_if_zero [::sargs::get $Data ".12/c.amount"]];} "BOX12D" {::return [number_or_blank_if_zero [::sargs::get $Data ".12/d.amount"]];} "BOX13A" { ::if {[::sargs::get $Data ".13stat"] eq "yes"} { ::return "X"; } ::return ""; } "BOX13B" { ::if {[::sargs::get $Data ".13retire"] eq "yes"} { ::return "X"; } ::return ""; } "BOX13C" { ::if {[::sargs::get $Data ".13sick"] eq "yes"} { ::return "X"; } ::return ""; } "BOX14A" {::return [::sargs::get $Data ".14"];} "BOX14B" {::return "";} "BOX14C" {::return "";} "BOX14D" {::return "";} "BOX15ASTATE" {::return [::sargs::get $Data ".15/1.state"];} "BOX15A" {::return [::sargs::get $Data ".15/1.id"];} "BOX15BSTATE" {::return [::sargs::get $Data ".15/2.state"];} "BOX15B" {::return [::sargs::get $Data ".15/2.id"];} "BOX16A" {::return [number_or_blank_if_zero [::sargs::get $Data ".16/1"]];} "BOX16B" {::return [number_or_blank_if_zero [::sargs::get $Data ".16/2"]];} "BOX17A" {::return [number_or_blank_if_zero [::sargs::get $Data ".17/1"]];} "BOX17B" {::return [number_or_blank_if_zero [::sargs::get $Data ".17/2"]];} "BOX18A" {::return [number_or_blank_if_zero [::sargs::get $Data ".18/1"]];} "BOX18B" {::return [number_or_blank_if_zero [::sargs::get $Data ".18/2"]];} "BOX19A" {::return [number_or_blank_if_zero [::sargs::get $Data ".19/1"]];} "BOX19B" {::return [number_or_blank_if_zero [::sargs::get $Data ".19/2"]];} "BOX20A" {::return [::sargs::get $Data ".20/1"];} "BOX20B" {::return [::sargs::get $Data ".20/2"];} "BOXA" { ::set Result [::sargs::get $Data ".d"]; ::set Result [::regsub -all \[^0-9\] $Result ""]; ::if {$Result eq ""} {::return "";} ::return "[::string range $Result 0 2] [::string range $Result 3 4] [::string range $Result 5 8]"; } "BOXB" {::return [::sargs::get $settings ".federal_id_number"];} "EMPLOYERNAME" {::return [::sargs::get $settings ".employers_name"];} "EMPLOYERADDRESS1" {::return [::sargs::get $settings ".employers_address_1"];} "EMPLOYERADDRESS2" {::return [::sargs::get $settings ".employers_address_2"];} "EMPLOYERADDRESS3" {::return [::sargs::get $settings ".employers_address_3"];} "EMPLOYERADDRESS4" {::return [::sargs::get $settings ".employers_address_4"];} "BOXD" { ::return [::sargs::get $Data ".a"]; } "BOXE" { ::set Result ""; ::append Result [::sargs::get $Data ".name.first"]; ::append Result " "; ::append Result [::string index [::sargs::get $Data ".name.initial"] 0]; ::return [::string trim $Result]; } "EMPLOYEEADDRESS" {::return [address_printable [[$Reference odb_master] ".address"]];} "LASTNAME" {::return [::sargs::get $Data ".name.last"];} } ::return ""; } } ::itcl::class ::qw::print::windows::template::1099 { inherit ::qw::print::windows::template; public variable 1099_data ""; public variable settings ""; public method _VOID {s_args} {::return [data_item $s_args];} public method _BOX1 {s_args} {::return [data_item $s_args];} public method _BOX2 {s_args} {::return [data_item $s_args];} public method _BOX3 {s_args} {::return [data_item $s_args];} public method _BOX4 {s_args} {::return [data_item $s_args];} public method _BOX5 {s_args} {::return [data_item $s_args];} public method _BOX6 {s_args} {::return [data_item $s_args];} public method _BOX7 {s_args} {::return [data_item $s_args];} public method _BOX8 {s_args} {::return [data_item $s_args];} public method _BOX9 {s_args} {::return [data_item $s_args];} public method _BOX10 {s_args} {::return [data_item $s_args];} public method _BOX11 {s_args} {::return [data_item $s_args];} public method _BOX12 {s_args} {::return [data_item $s_args];} ::if {1||$::qw_version>=2.37} { public method _BOX14 {s_args} {::return [data_item $s_args];} public method _BOX15 {s_args} {::return [data_item $s_args];} public method _BOX16A {s_args} {::return [data_item $s_args];} public method _BOX16B {s_args} {::return [data_item $s_args];} public method _BOX17 {s_args} {::return [settings_item [::sargs::set $s_args .field ".payers_state_id"]];} ;#//nv2.34.5 public method _BOX18A {s_args} {::return [data_item $s_args];} public method _BOX18B {s_args} {::return [data_item $s_args];} } else { public method _BOX13 {s_args} {::return [data_item $s_args];} public method _BOX14 {s_args} {::return [data_item $s_args];} public method _BOX15A {s_args} { ::return [data_item $s_args]; } public method _BOX15B {s_args} {::return [data_item $s_args];} public method _BOX16 {s_args} {::return [settings_item [::sargs::set $s_args .field ".payers_state_id"]];} ;#//nv2.34.5 public method _BOX17A {s_args} {::return [data_item $s_args];} public method _BOX17B {s_args} {::return [data_item $s_args];} } public method _CORRECTED {s_args} { ::set Result [settings_item [::sargs::set $s_args .field ".corrected"]]; ::if {$Result eq "yes"} { ::return "X"; } ::return ""; } public method _PAYERNAME {s_args} {::return [settings_item [::sargs::set $s_args .field ".payers_name"]];} public method _PAYERADDRESS1 {s_args} {::return [settings_item [::sargs::set $s_args .field ".payers_address_1"]];} public method _PAYERADDRESS2 {s_args} {::return [settings_item [::sargs::set $s_args .field ".payers_address_2"]];} public method _PAYERADDRESS3 {s_args} {::return [settings_item [::sargs::set $s_args .field ".payers_address_3"]];} public method _PAYERADDRESS4 {s_args} {::return [settings_item [::sargs::set $s_args .field ".payers_address_4"]];} public method _RECIDNUM {s_args} { ::return [data_item $s_args]; } public method _SECONDTIN {s_args} {::return "";} public method _FEDIDNUM {s_args} {::return [settings_item [::sargs::set $s_args .field ".payers_federal_id"]];} public method _ACCOUNTNUMBER {s_args} {::return [data_item $s_args];} ;#// not supported constructor {args} { ::eval ::qw::print::windows::template::constructor $args; } { } destructor { } public method documentStart {} { chain; addressSourceSet; } public method load {Src} { ::set _references $Src; chain [::lindex $_references 0]; } method data_item {s_args} { ::set Name [::sargs::get $s_args ".name"]; ::set Suffix [::sargs::get $s_args ".suffix"]; ::if {$Suffix eq ""} { ::set Suffix 1; } ::incr Suffix -1; ::set Data [::lindex $1099_data $Suffix]; ::set Reference [::lindex $_references $Suffix]; ::if {$Data eq ""} { ::if {$Name eq "VOID"} {::return "X";} ::return ""; } ::set Master [$Reference odb_master]; ::switch -glob -- $Name { "BOX*" { ::return [number_or_blank_if_zero [::sargs::get $Data .[::string tolower [::string map [::list BOX ""] $Name]]]]; } "RECIDNUM" { ::return [[$Master ".trade_tax/1.registration_id"] odb_get]; } } ::return ""; } method settings_item {s_args} { ::set Name [::sargs::get $s_args ".name"]; ::set Field [::sargs::get $s_args ".field"]; ::set Suffix [::sargs::get $s_args ".suffix"]; ::if {$Suffix ne ""} { ::incr Suffix -1; ::set AddressSource [::lindex $_references $Suffix]; ::if {$AddressSource eq ""} { ::return ""; } } ::return [::sargs::get $settings $Field]; } } ::itcl::class ::qw::print::windows::template::statement { inherit ::qw::print::windows::template; public variable settings ""; public variable statement_data; protected variable _opening_balance 0.0; protected variable _closing_balance 0.0; protected variable _amount_1 0.0; protected variable _amount_2 0.0; protected variable _amount_3 0.0; protected variable _amount_4 0.0; protected variable _current_due 0.0; protected variable _past_due_1 0.0; protected variable _past_due_2 0.0; protected variable _past_due_3 0.0; protected variable _past_due_4 0.0; protected variable _past_due_0 0.0; protected variable _item_age_pastdue 0; protected variable _item_age_pastdiscount 0; protected variable _current_discount 0.0; protected variable _past_discount_0 0.0; protected variable _past_discount_1 0.0; protected variable _past_discount_2 0.0; protected variable _past_discount_3 0.0; protected variable _past_discount_4 0.0; protected variable _item_date ""; protected variable _item_description ""; protected variable _item_amount 0.0; protected variable _item_balance 0.0; protected variable _item_age 0; protected variable _address ""; protected variable _account ""; protected variable _statement_details_information ""; protected variable _item -1; protected variable _item_amounts; protected variable _item_posting_reference ""; protected variable _item_master_shipping_address ""; protected variable _prior_closed_balance ""; protected variable _prior_ledger_balance ""; constructor {args} { ::eval ::qw::print::windows::template::constructor $args; ::array set _item_amounts {}; } { } destructor { } public method _CUSTOMERNAME {s_args} { ::set Result [[$_account ".address.company"] odb_get]; ::if {$Result ne ""} {::return $Result;} ::return [[$_account ".description"] odb_get]; } public method _BILLINGADDRESS {s_args} {::return [address_printable [$_account ".address"]];} public method _ACCOUNT {s_args} {::return [[$_account ".name"] odb_get];} public method _PHONE {s_args} {::return [[$_account ".address.phone.freeform"] odb_get];} public method _FAX {s_args} {::return [[$_account ".address.phone/fax.freeform"] odb_get];} public method _DISCDAYS {s_args} {::return [terms ".terms.discount_days"];} public method _DISCRATE {s_args} {::return [terms ".terms.discount_rate"];} public method _DUEDAYS {s_args} {::return [terms ".terms.due_days"];} public method _INTRATE {s_args} {::return [terms ".terms.interest_rate"];} public method _TAX1CHARGED {s_args} {::return [terms ".trade_tax/1.is_charged"];} public method _TAX1NUMBER {s_args} {::return [terms ".trade_tax/1.registration_id"];} public method _TAX2CHARGED {s_args} {::return [terms ".trade_tax/2.is_charged"];} public method _TAX2NUMBER {s_args} {::return [terms ".trade_tax/2.registration_id"];} public method _AGE1 {s_args} {::return "0-[::sargs::get $settings .days_1] days";} public method _AGE2 {s_args} {::return "[::expr [::sargs::get $settings .days_1]+1]-[::sargs::get $settings .days_2] days";} public method _AGE3 {s_args} {::return "[::expr [::sargs::get $settings .days_2]+1]-[::sargs::get $settings .days_3] days";} public method _AGE4 {s_args} {::return "Over [::sargs::get $settings .days_3] days";} public method _AMOUNTAGE1 {s_args} {::return "0-[::sargs::get $settings .days_1] days";} public method _AMOUNTAGE2 {s_args} {::return "[::expr [::sargs::get $settings .days_1]+1]-[::sargs::get $settings .days_2] days";} public method _AMOUNTAGE3 {s_args} {::return "[::expr [::sargs::get $settings .days_2]+1]-[::sargs::get $settings .days_3] days";} public method _AMOUNTAGE4 {s_args} {::return "Over [::sargs::get $settings .days_3] days";} public method _AMOUNT1 {s_args} {::if {[moreItemsQuery]} {::return "";};::return $_amount_1;} public method _AMOUNT2 {s_args} {::if {[moreItemsQuery]} {::return "";};::return $_amount_2;} public method _AMOUNT3 {s_args} {::if {[moreItemsQuery]} {::return "";};::return $_amount_3;} public method _AMOUNT4 {s_args} {::if {[moreItemsQuery]} {::return "";};::return $_amount_4;} public method _CURRENTDUE {s_args} {::if {[moreItemsQuery]} {::return "";};::return $_past_due_0;} public method _PASTDUE1 {s_args} {::if {[moreItemsQuery]} {::return "";};::return $_past_due_1;} public method _PASTDUE2 {s_args} {::if {[moreItemsQuery]} {::return "";};::return $_past_due_2;} public method _PASTDUE3 {s_args} {::if {[moreItemsQuery]} {::return "";};::return $_past_due_3;} public method _PASTDUE4 {s_args} {::if {[moreItemsQuery]} {::return "";};::return $_past_due_4;} public method _OPENBALANCE {s_args} {::if {$_page_number>1} {::return "";};::return $_opening_balance;} public method _CLOSEBALANCE {s_args} {::if {[moreItemsQuery]} {::return "";};::return $_closing_balance;} public method _PRIORCLOSEDBALANCE {s_args} {::if {[moreItemsQuery]} {::return "";};::return $_prior_closed_balance;} public method _PRIORLEDGERBALANCE {s_args} {::if {[moreItemsQuery]} {::return "";};::return $_prior_ledger_balance;} public method _MESSAGE {s_args} { ::if {[moreItemsQuery]} { ::return ""; } ::if {$_past_due_4!=0.0} {::return [::sargs::get $settings ".message_4"]} ::if {$_past_due_3!=0.0} {::return [::sargs::get $settings ".message_3"]} ::if {$_past_due_2!=0.0} {::return [::sargs::get $settings ".message_2"]} ::return [::sargs::get $settings ".message_1"]; } public method _DATE {s_args} {::return [::sargs::get $settings ".statement_date"];} public method _ITEM_DATE {s_args} {::return $_item_date;} public method _ITEM_REF {s_args} {::return $_item_reference;} public method _ITEM_AMOUNT {s_args} {::return $_item_amount;} public method _ITEM_BALANCE {s_args} {::return $_item_balance;} public method _ITEM_DESCRIPTION {s_args} {::return $_item_description;} public method _ITEM_AGE {s_args} {::return $_item_age;} public method _PASTDUE0 {s_args} {::if {[moreItemsQuery]} {::return "";};::return $_past_due_0;} public method _PASTDISCOUNT0 {s_args} {::if {[moreItemsQuery]} {::return "";};::return $_past_discount_0;} public method _PASTDISCOUNT1 {s_args} {::if {[moreItemsQuery]} {::return "";};::return $_past_discount_1;} public method _PASTDISCOUNT2 {s_args} {::if {[moreItemsQuery]} {::return "";};::return $_past_discount_2;} public method _PASTDISCOUNT3 {s_args} {::if {[moreItemsQuery]} {::return "";};::return $_past_discount_3;} public method _PASTDISCOUNT4 {s_args} {::if {[moreItemsQuery]} {::return "";};::return $_past_discount_4;} public method _ITEM_AMOUNTAGE1 {s_args} {::return $_item_amounts(age1);} public method _ITEM_AMOUNTAGE2 {s_args} {::return $_item_amounts(age2);} public method _ITEM_AMOUNTAGE3 {s_args} {::return $_item_amounts(age3);} public method _ITEM_AMOUNTAGE4 {s_args} {::return $_item_amounts(age4);} public method _ITEM_AGEPASTDUE {s_args} {::return $_item_age_pastdue;} public method _ITEM_AMOUNTPASTDUE0 {s_args} {::return $_item_amounts(pastdue0);} public method _ITEM_AMOUNTPASTDUE1 {s_args} {::return $_item_amounts(pastdue1);} public method _ITEM_AMOUNTPASTDUE2 {s_args} {::return $_item_amounts(pastdue2);} public method _ITEM_AMOUNTPASTDUE3 {s_args} {::return $_item_amounts(pastdue3);} public method _ITEM_AMOUNTPASTDUE4 {s_args} {::return $_item_amounts(pastdue4);} public method _ITEM_AGEPASTDISCOUNT {s_args} {::return $_item_age_pastdiscount;} public method _ITEM_AMOUNTPASTDISCOUNT0 {s_args} {::return $_item_amounts(pastdiscount0);} public method _ITEM_AMOUNTPASTDISCOUNT1 {s_args} {::return $_item_amounts(pastdiscount1);} public method _ITEM_AMOUNTPASTDISCOUNT2 {s_args} {::return $_item_amounts(pastdiscount2);} public method _ITEM_AMOUNTPASTDISCOUNT3 {s_args} {::return $_item_amounts(pastdiscount3);} public method _ITEM_AMOUNTPASTDISCOUNT4 {s_args} {::return $_item_amounts(pastdiscount4);} public method _ITEM_SHIPADDRESS {s_args} { ::return ""; ;#// do we do multi-line cell content in item area? } public method _ITEM_SHIPCOMPANY {s_args} {::return [address_field [::sargs::set $s_args .field /shipping.company]];} public method _ITEM_SHIPCONTACTNAME {s_args} { ::return [address_field [::sargs::set $s_args .field /shipping.name.freeform]]; } public method _ITEM_SHIPCONTACTSALUTATION {s_args} {::return [address_field [::sargs::set $s_args .field /shipping.name.salutation]];} public method _ITEM_SHIPCONTACTFIRST {s_args} {::return [address_field [::sargs::set $s_args .field /shipping.name.first]];} public method _ITEM_SHIPCONTACTMIDDLE {s_args} {::return [address_field [::sargs::set $s_args .field /shipping.name.middle]];} public method _ITEM_SHIPCONTACTLAST {s_args} {::return [address_field [::sargs::set $s_args .field /shipping.name.last]];} public method _ITEM_SHIPSTREET {s_args} {::return [address_field [::sargs::set $s_args .field /shipping.street]];} public method _ITEM_SHIPSTREET2 {s_args} {::return [address_field [::sargs::set $s_args .field /shipping.street2]];} public method _ITEM_SHIPCITY {s_args} {::return [address_field [::sargs::set $s_args .field /shipping.city]];} public method _ITEM_SHIPSTATE {s_args} {::return [address_field [::sargs::set $s_args .field /shipping.state]];} public method _ITEM_SHIPCOUNTRY {s_args} {::return [address_field [::sargs::set $s_args .field /shipping.country]];} public method _ITEM_SHIPZIPCODE {s_args} {::return [address_field [::sargs::set $s_args .field /shipping.zipcode]];} public method _ITEM_SHIPCITYSTATEZIPCODE {s_args} { ::if {$_extra_ship_address_object ne ""} { ::return [city_state_zipcode_printable [$_extra_ship_address_object ".address"]]; } ::return [city_state_zipcode_printable [addressSourceGet [::sargs::set $s_args .field .address/shipping]]]; } public method _ITEM_SHIPPHONE {s_args} {::return [address_field [::sargs::set $s_args .field /shipping.phone.freeform]];} public method _ITEM_SHIPPHONECOUNTRYCODE {s_args} {::return [address_field [::sargs::set $s_args .field /shipping.phone.country_code]];} public method _ITEM_SHIPPHONEAREACODE {s_args} {::return [address_field [::sargs::set $s_args .field /shipping.phone.area_code]];} public method _ITEM_SHIPPHONEPREFIX {s_args} {::return [address_field [::sargs::set $s_args .field /shipping.phone.prefix]];} public method _ITEM_SHIPPHONESUFFIX {s_args} {::return [address_field [::sargs::set $s_args .field /shipping.phone.suffix]];} public method _ITEM_SHIPPHONEEXTENSION {s_args} {::return [address_field [::sargs::set $s_args .field /shipping.phone.extension]];} public method _ITEM_SHIPFAX {s_args} {::return [address_field [::sargs::set $s_args .field /shipping.phone/fax.freeform]];} public method _ITEM_SHIPFAXCOUNTRYCODE {s_args} {::return [address_field [::sargs::set $s_args .field /shipping.phone/fax.country_code]];} public method _ITEM_SHIPFAXAREACODE {s_args} {::return [address_field [::sargs::set $s_args .field /shipping.phone/fax.area_code]];} public method _ITEM_SHIPFAXPREFIX {s_args} {::return [address_field [::sargs::set $s_args .field /shipping.phone/fax.prefix]];} public method _ITEM_SHIPFAXSUFFIX {s_args} {::return [address_field [::sargs::set $s_args .field /shipping.phone/fax.suffix]];} public method _ITEM_SHIPFAXEXTENSION {s_args} {::return [address_field [::sargs::set $s_args .field /shipping.phone/fax.extension]];} public method _ITEM_SHIPEMAIL {s_args} {::return [address_field [::sargs::set $s_args .field /shipping.email]];} public method _ITEM_SHIPWEBSITE {s_args} {::return [address_field [::sargs::set $s_args .field /shipping.website]];} public method terms {Src} { ::switch -glob -- [$_account odb_path] { "/OBJECT/NEWVIEWS/ACCOUNT/AP*" - "/OBJECT/NEWVIEWS/ACCOUNT/AR*" { ::return [[$_account $Src] odb_get]; } } ::return ""; } public method load {Src} { ::set _account [$Src odb_master]; ::set _statement_details_information $statement_data; ::set _prior_closed_balance [::sargs::get $_statement_details_information ".prior_closed_balance"]; ::set _prior_ledger_balance [::sargs::get $_statement_details_information ".prior_ledger_balance"]; ::set _opening_balance [::sargs::get $_statement_details_information ".opening_balance"]; ::set _closing_balance $_opening_balance; ::set _item_balance $_opening_balance; ::set _amount_1 0.0; ::set _amount_2 0.0; ::set _amount_3 0.0; ::set _amount_4 0.0; ::set _current_due 0.0; ::set _past_due_1 0.0; ::set _past_due_2 0.0; ::set _past_due_3 0.0; ::set _past_due_4 0.0; ::set _current_discount 0.0; ::set _past_due_0 0.0; ::set _past_discount_0 0.0; ::set _past_discount_1 0.0; ::set _past_discount_2 0.0; ::set _past_discount_3 0.0; ::set _past_discount_4 0.0; ::set _item -1; ::return [chain $Src]; } method nextItemLoad_shipping_address_load {} { ::if {$_addressSource eq ""} { ::return $this; } ::if {$_item_master eq ""} { ::return $this; } ::set _extra_ship_address_object ""; ::switch -glob -- [$_item_master odb_path] { /OBJECT/NEWVIEWS/SYSTEM/TRANSACTION/PURCHASE_NO_FIELD_AND_NOT_SUPPORTED* - /OBJECT/NEWVIEWS/SYSTEM/TRANSACTION/SALES* { ::set Sto [[$_item_master .ship_to_address] odb_get]; ::if {$Sto ne ""&&[[$_item_master odb_database] cpp_find_from_address $Sto] ne ""} { ::set _extra_ship_address_object $Sto; } } } ::return; } public method documentStart {} { chain; addressSourceSet; ::set _item_reference ""; ::set _item_master ""; } method itemStart {} { chain; ;#// base resets _itemInfo to NULL ::return $this; } method nextItemLoad {} { ::incr _item; ::set _item_master [::sargs::get $_statement_details_information ".transactions/$_item.master"]; ::if {$::qw::control(address_objects_is_enabled)} {} nextItemLoad_shipping_address_load; ::set _item_date [::sargs::get $_statement_details_information ".transactions/$_item.date"]; ::set _item_reference [::sargs::get $_statement_details_information ".transactions/$_item.reference"]; ::set _item_description [::sargs::get $_statement_details_information ".transactions/$_item.description"]; ::set _item_amount [::sargs::get $_statement_details_information ".transactions/$_item.amount"]; ::set _item_balance [::qw::number::add $_item_balance $_item_amount]; ::set _closing_balance [::qw::number::add $_closing_balance $_item_amount]; ::foreach Name [::list age1 age2 age3 age4 pastdue0 pastdue1 pastdue2 pastdue3 pastdue4 pastdiscount0 pastdiscount1 pastdiscount2 pastdiscount3 pastdiscount4] { ::set _item_amounts($Name) ""; } ::set _item_age [::qw::date::difference [::sargs::get $settings ".statement_date"] $_item_date "day"]; ::while {1} { ::if {$_item_age>[::sargs::get $settings ".days_3"]} { ::set _amount_4 [::qw::number::add $_amount_4 $_item_amount]; ::set _item_amounts(age4) $_item_amount; ::break; } ::if {$_item_age>[::sargs::get $settings ".days_2"]} { ::set _amount_3 [::qw::number::add $_amount_3 $_item_amount]; ::set _item_amounts(age3) $_item_amount; ::break; } ::if {$_item_age>[::sargs::get $settings ".days_1"]} { ::set _amount_2 [::qw::number::add $_amount_2 $_item_amount]; ::set _item_amounts(age2) $_item_amount; ::break; } ::set _amount_1 [::qw::number::add $_amount_1 $_item_amount]; ::set _item_amounts(age1) $_item_amount; ::break; } ::set DueDate [::qw::date::add $_item_date "day" [terms ".terms.due_days"]]; ::set _item_age_pastdue [::qw::date::difference [::sargs::get $settings ".statement_date"] $DueDate "day"]; ::while {1} { ::if {$_item_age_pastdue>[::sargs::get $settings ".days_3"]} { ::set _past_due_4 [::qw::number::add $_past_due_4 $_item_amount]; ::set _item_amounts(pastdue4) $_item_amount; ::break; } ::if {$_item_age_pastdue>[::sargs::get $settings ".days_2"]} { ::set _past_due_3 [::qw::number::add $_past_due_3 $_item_amount]; ::set _item_amounts(pastdue3) $_item_amount; ::break; } ::if {$_item_age_pastdue>[::sargs::get $settings ".days_1"]} { ::set _past_due_2 [::qw::number::add $_past_due_2 $_item_amount]; ::set _item_amounts(pastdue2) $_item_amount; ::break; } ::if {$_item_age_pastdue>0} { ::set _past_due_1 [::qw::number::add $_past_due_1 $_item_amount]; ::set _item_amounts(pastdue1) $_item_amount; ::break; } ::set _past_due_0 [::qw::number::add $_past_due_0 $_item_amount]; ::set _item_amounts(pastdue0) $_item_amount; ::break; } ::set DiscountDate [::qw::date::add $_item_date "day" [terms ".terms.discount_days"]]; ::set _item_age_pastdiscount [::qw::date::difference [::sargs::get $settings ".statement_date"] $DiscountDate "day"]; ::while {1} { ::if {$_item_age_pastdiscount>[::sargs::get $settings ".days_3"]} { ::set _past_discount_4 [::qw::number::add $_past_discount_4 $_item_amount]; ::set _item_amounts(pastdiscount4) $_item_amount; ::break; } ::if {$_item_age_pastdiscount>[::sargs::get $settings ".days_2"]} { ::set _past_discount_3 [::qw::number::add $_past_discount_3 $_item_amount]; ::set _item_amounts(pastdiscount3) $_item_amount; ::break; } ::if {$_item_age_pastdiscount>[::sargs::get $settings ".days_1"]} { ::set _past_discount_2 [::qw::number::add $_past_discount_2 $_item_amount]; ::set _item_amounts(pastdiscount2) $_item_amount; ::break; } ::if {$_item_age_pastdiscount>0} { ::set _past_discount_1 [::qw::number::add $_past_discount_1 $_item_amount]; ::set _item_amounts(pastdiscount1) $_item_amount; ::break; } ::set _past_discount_0 [::qw::number::add $_past_discount_0 $_item_amount]; ::set _item_amounts(pastdiscount0) $_item_amount; ::break; } ::return $this; } method numberOfItemsSet {} { ::set _itemsToDo [::sargs::get $_statement_details_information ".transaction_count"]; ::return $this; } method moreItemsQuery {} { ::return [chain]; } } ::itcl::class ::qw::print::windows::template::invoice { inherit ::qw::print::windows::template; private variable _shippingAddress ""; private variable _billingAddress ""; private variable _customerName ""; private variable _shippingName ""; private variable _journal_type "/OBJECT/NEWVIEWS/SYSTEM/TRANSACTION/GENERAL"; protected variable _item_notes {}; protected variable _item_account_object {}; protected variable _item_balance {}; protected variable _item_description {}; protected variable _item_account {}; protected variable _item_accountdescription {}; protected variable _item_adpluscomment {}; ;#// item account description and item description concatinated protected variable _item_quantity {}; protected variable _item_price {}; protected variable _item_net {}; protected variable _item_tax1ind {}; protected variable _item_tax1rate {}; protected variable _item_tax1amount {}; protected variable _item_tax2ind {}; protected variable _item_tax2rate {}; protected variable _item_tax2amount {}; protected variable _item_total {}; protected variable _item_total1 {}; protected variable _item_total2 {}; protected variable _unit_of_measure_name {}; protected variable _unit_of_measure_quantity {}; protected variable _unit_of_measure_price {}; protected variable _unit_of_measure_conversion_rate {}; protected variable _quantity_original_order {}; protected variable _quantity_total_ship {}; protected variable _quantity_backorder {}; constructor {args} { ::eval ::qw::print::windows::template::constructor $args; } { } destructor { } public method _ACCOUNTBALANCE {s_args} { ::set Account [customer_or_supplier_account]; ::if {$Account eq ""} { ::return ""; } ::set Range [::qw::odb::factory range]; ::qw::finally [::list $Range cpp_destroy]; $Range cpp_configure -index "$Account.postings.index/date" -begin [::list .tag financial] -end [::list .tag financial]; ::return [[$Range odb_master] history_file_odb_total [::sargs .range $Range .rb_name .amount .priority foreground]]; } public method _CUSTOMERNAME {s_args} {::return $_customerName;} public method _BILLINGADDRESS {s_args} {::return $_billingAddress;} public method _SHIPPINGNAME {s_args} {::return $_shippingName;} public method _SHIPPINGADDRESS {s_args} {::return $_shippingAddress;} public method account_field {Src} { ::if {$_addressSource eq ""} { ::return ""; } ::switch -glob -- [$_addressSource odb_path] { "/OBJECT/NEWVIEWS/ACCOUNT/AR*" { ::switch -glob -- $Src { "*.registration_id" { } } } "/OBJECT/NEWVIEWS/ACCOUNT/AP*" { ::switch -glob -- $Src { "*.price_percent" {::return "";} } } default { ::return ""; } } ::return [[$_addressSource "$Src"] odb_get]; } public method _TAX1CHARGED {s_args} {::return [account_field ".trade_tax/1.is_charged"];} public method _TAX1NUMBER {s_args} {::return [account_field ".trade_tax/1.registration_id"];} public method _TAX2CHARGED {s_args} {::return [account_field ".trade_tax/2.is_charged"];} public method _TAX2NUMBER {s_args} {::return [account_field ".trade_tax/2.registration_id"];} public method _DISCDAYS {s_args} {::return [account_field ".terms.discount_days"];} public method _DISCRATE {s_args} {::return [account_field ".terms.discount_rate"];} public method _DUEDAYS {s_args} {::return [account_field ".terms.due_days"];} public method _INTRATE {s_args} {::return [account_field ".terms.interest_rate"];} public method _SALESPRICEPERCENT {s_args} {::return [account_field ".price_percent"];} public method _INVOICEDATE {s_args} { ::set Result [[[$_reference odb_master] ".date"] odb_get]; ::return $Result; } public method _INVOICEDATE_save {s_args} {::return [[[$_reference odb_master] ".date"] odb_get];} public method _INVOICENUMBER {s_args} {::return [[[$_reference odb_master] ".reference"] odb_get];} public method _INVOICEDESCRIPTION {s_args} {::return [[[$_reference odb_master] ".description"] odb_get];} public method _ORDERNUMBER {s_args} {::return [[[$_reference odb_master] ".reference1"] odb_get];} public method _ORDERDATE {s_args} {::return [[[$_reference odb_master] ".date1"] odb_get];} public method _INVOICETOTAL {s_args} { ::if {[moreItemsQuery]} {::return "";} ::set Transaction [$_reference odb_master]; ::switch -glob -- $_journal_type { /OBJECT/NEWVIEWS/SYSTEM/TRANSACTION/SALES* { ::return [[$Transaction ".posting/debit/customer.amount"] odb_get]; } /OBJECT/NEWVIEWS/SYSTEM/TRANSACTION/PURCHASE* { ::return [::qw::number::negative [[$Transaction ".posting/credit.amount"] odb_get]]; } default { ::return [::qw::number::negative [[$Transaction ".posting/credit.amount"] odb_get]]; } } } public method _ACCOUNT {s_args} { ::switch -glob -- $_journal_type { /OBJECT/NEWVIEWS/SYSTEM/TRANSACTION/SALES* { ::set Path ".posting/debit/customer.account"; } /OBJECT/NEWVIEWS/SYSTEM/TRANSACTION/PURCHASE* { ::set Path ".posting/credit.account"; } default { ::set Path ".posting/debit.account"; } } ::set Account [[[$_reference odb_master] $Path] odb_get]; ::if {$Account eq ""} { ::return ""; } ::return [[[$Account odb_master] ".name"] odb_get]; } public method _ACCOUNTDESCRIPTION {s_args} { ::switch -glob -- $_journal_type { /OBJECT/NEWVIEWS/SYSTEM/TRANSACTION/SALES* { ::set Path ".posting/debit/customer.account"; } /OBJECT/NEWVIEWS/SYSTEM/TRANSACTION/PURCHASE* { ::set Path ".posting/credit.account"; } default { ::set Path ".posting/debit.account"; } } ::set Account [[[$_reference odb_master] $Path] odb_get]; ::if {$Account eq ""} { ::return ""; } ::return [[[$Account odb_master] ".description"] odb_get]; } public method _WOACCOUNTWITHDESCRIPTION {s_args} { ::switch -glob -- $_journal_type { /OBJECT/NEWVIEWS/SYSTEM/TRANSACTION/PURCHASE* { ::set Path ".posting/debit/ar.account"; } default { ::return ""; } } ::set Account [[[$_reference odb_master] $Path] odb_get]; ::if {$Account eq ""} { ::return ""; } ::set Name [[[$Account odb_master] ".name"] odb_get]; ::set Description [[[$Account odb_master] ".description"] odb_get]; ::return "$Name ($Description)"; } public method _TOTALNET {s_args} { ::if {[moreItemsQuery]} {::return "";} ::set Transaction [$_reference odb_master]; ::switch -glob -- $_journal_type { /OBJECT/NEWVIEWS/SYSTEM/TRANSACTION/SALES* { ::return [::qw::number::negative [[$Transaction ".posting/credit/charge.amount"] odb_get]]; } /OBJECT/NEWVIEWS/SYSTEM/TRANSACTION/PURCHASE* { ::return [[$Transaction ".posting/debit/charge.amount"] odb_get]; } default { ::return [::qw::number::negative [[$Transaction ".posting/credit.amount"] odb_get]]; } } } public method _TOTALTAX1 {s_args} { ::if {[moreItemsQuery]} {::return "";} ::set Transaction [$_reference odb_master]; ::switch -glob -- $_journal_type { /OBJECT/NEWVIEWS/SYSTEM/TRANSACTION/SALES* { ::return [::qw::number::negative [[$Transaction ".posting/credit/tax1.amount"] odb_get]]; } "PURCHASE_OLD*" { ::return [::qw::number::negative [[$Transaction ".posting/debit/tax1.amount"] odb_get]]; } /OBJECT/NEWVIEWS/SYSTEM/TRANSACTION/PURCHASE* { ::return [[$Transaction ".posting/debit/tax1.amount"] odb_get]; } } ::return 0.0; } public method _TOTALTAX2 {s_args} { ::if {[moreItemsQuery]} {::return "";} ::set Transaction [$_reference odb_master]; ::switch -glob -- $_journal_type { /OBJECT/NEWVIEWS/SYSTEM/TRANSACTION/SALES* { ::return [::qw::number::negative [[$Transaction ".posting/credit/tax2.amount"] odb_get]]; } "PURCHASE_OLD*" { ::return [::qw::number::negative [[$Transaction ".posting/debit/tax2.amount"] odb_get]]; } /OBJECT/NEWVIEWS/SYSTEM/TRANSACTION/PURCHASE* { ::return [[$Transaction ".posting/debit/tax2.amount"] odb_get]; } } ::return 0.0; } public method invoice_information {Src} { ::set Structure [[[$_reference odb_master] ".invoice_information"] odb_get]; ::return [::sargs::get $Structure "/$Src.value"]; } public method _INFO1 {s_args} {::return [invoice_information 1];} public method _INFO2 {s_args} {::return [invoice_information 2];} public method _INFO3 {s_args} {::return [invoice_information 3];} public method _INFO4 {s_args} {::return [invoice_information 4];} public method _INFO5 {s_args} {::return [invoice_information 5];} public method _INFO6 {s_args} {::return [invoice_information 6];} public method _INFO7 {s_args} {::return [invoice_information 7];} public method _INFO8 {s_args} {::return [invoice_information 8];} public method _INFO9 {s_args} {::return [invoice_information 9];} public method _INFO10 {s_args} {::return [invoice_information 10];} public method _INFO11 {s_args} {::return [invoice_information 11];} public method _INFO12 {s_args} {::return [invoice_information 12];} public method _INFO13 {s_args} {::return [invoice_information 13];} public method _INFO14 {s_args} {::return [invoice_information 14];} public method _INFO15 {s_args} {::return [invoice_information 15];} ::if {$::qw::control(crm_include)} {} public method _INFO16 {s_args} {::return [invoice_information 16];} public method _INFO17 {s_args} {::return [invoice_information 17];} public method _INFO18 {s_args} {::return [invoice_information 18];} public method _INFO19 {s_args} {::return [invoice_information 19];} public method _INFO20 {s_args} {::return [invoice_information 20];} public method _ITEM_NOTES {s_args} {::return $_item_notes;} public method _ITEM_BALANCE {s_args} {::return $_item_balance;} public method _ITEM_DESCRIPTION {s_args} {::return $_item_description;} public method _ITEM_CUSTOMERSALESCODE {s_args} { ::switch -glob -- $_journal_type { /OBJECT/NEWVIEWS/SYSTEM/TRANSACTION/SALES* { ::return [[$_item_master .customer_sales_code] odb_get]; } default { ::return ""; } } } public method _ITEM_INVACCOUNT {s_args} { ::switch -glob -- $_journal_type { /OBJECT/NEWVIEWS/SYSTEM/TRANSACTION/SALES* { ::set Account [[$_item_master .posting/credit/inventory.account] odb_get]; ::if {$Account eq ""} { ::return ""; } ::return [[[$Account odb_master] .name] odb_get]; } default { ::return ""; } } } public method _ITEM_INVLB {s_args} { ::switch -glob -- $_journal_type { /OBJECT/NEWVIEWS/SYSTEM/TRANSACTION/SALES* { ::set Account [[$_item_master .posting/credit/inventory.account] odb_get]; ::if {$Account eq ""} { ::return ""; } ::set Crate [[$Account odb_master] unit_of_measure_matrix_cell_get [::sargs .row_name [[[$Account odb_master] .primary_unit_of_measure_name] odb_get] .column_name "LB"]]; ::if {$Crate eq ""} { ::return ""; } ::return [::expr {[::qw::number::negative [[$_item_master .posting/credit/inventory.quantity] odb_get]]*$Crate}]; } default { ::return ""; } } } public method _ITEM_UPC {s_args} { ::switch -glob -- $_journal_type { /OBJECT/NEWVIEWS/SYSTEM/TRANSACTION/SALES* { ::set Account [[$_item_master .posting/credit/charge.account] odb_get]; ::if {$Account eq ""} { ::return ""; } ::set Data [[[$Account odb_master] .structure_data] odb_get]; ::return [::sargs::get $Data .newviews.additional_info_string_1]; } default { ::return ""; } } } public method _ITEM_ACCOUNT {s_args} { ::return $_item_account; } public method _ITEM_ACCOUNTDESCRIPTION {s_args} {::return $_item_accountdescription;} public method _ITEM_DESCRIPTIONACCOUNT {s_args} {::return $_item_accountdescription;} public method _ITEM_DESCRIPTIONPLUSAD {s_args} {::return "$_item_accountdescription $_item_description";} public method _ITEM_QUANTITY {s_args} {::return $_item_quantity;} public method _ITEM_PRICE {s_args} {::return $_item_price;} public method _ITEM_NET {s_args} {::return $_item_net;} public method _ITEM_TAX1IND {s_args} {::return $_item_tax1ind;} public method _ITEM_TAX1RATE {s_args} {::return $_item_tax1rate;} public method _ITEM_TAX1AMOUNT {s_args} {::return $_item_tax1amount;} public method _ITEM_TAX2IND {s_args} {::return $_item_tax2ind;} public method _ITEM_TAX2RATE {s_args} {::return $_item_tax2rate;} public method _ITEM_TAX2AMOUNT {s_args} {::return $_item_tax2amount;} public method _ITEM_TOTAL {s_args} {::return $_item_total;} public method _ITEM_TOTAL1 {s_args} {::return $_item_total1;} public method _ITEM_TOTAL2 {s_args} {::return $_item_total2;} public method _ITEM_TAXAMOUNT {s_args} { ::if {$_item_account_object eq ""} { ::return ""; } ::return [::qw::number::add $_item_tax1amount $_item_tax2amount]; } public method _ITEM_UNITNAME {s_args} {::return $_unit_of_measure_name;} public method _ITEM_UNITQUANTITY {s_args} {::return $_unit_of_measure_quantity;} public method _ITEM_UNITPRICE {s_args} {::return $_unit_of_measure_price;} public method _ITEM_UNITRATE {s_args} {::return $_unit_of_measure_conversion_rate;} public method _ITEM_ORDERQUANTITY {s_args} {::return $_quantity_original_order;} public method _ITEM_TOTALSHIPQUANTITY {s_args} {::return $_quantity_total_ship;} public method _ITEM_BACKORDERQUANTITY {s_args} {::return $_quantity_backorder;} public method customer_or_supplier_account {{s_args ""}} { ::switch -glob -- $_journal_type { /OBJECT/NEWVIEWS/SYSTEM/TRANSACTION/SALES* { ::set Path ".posting/debit/customer.account"; } /OBJECT/NEWVIEWS/SYSTEM/TRANSACTION/PURCHASE* { ::set Path ".posting/credit.account"; ::set JournalName [[[[[[$_reference odb_master] .journal] odb_get] odb_master] .name] odb_get]; ::if {[::string first "UI" $JournalName]==0} { ::set Reference [[[$_reference odb_master] ".posting/debit/ar.account"] odb_get]; ::if {$Reference ne ""} { ::set Path ".posting/debit/ar.account"; } } } default { ::set Path ".posting/debit.account"; } } ::set Reference [[[$_reference odb_master] $Path] odb_get]; ::if {$Reference eq ""} { ::return ""; } ::return [$Reference odb_master]; } public method clientdata_field {Src} { ::set Account [customer_or_supplier_account]; ::if {$Account eq ""} {::return "";} ::set ClientData [[$Account ".structure_data"] odb_get]; ::return [::sargs::get $ClientData $Src]; } public method _EFTBANKID {s_args} {::return [clientdata_field "/eft.bank_id"];} public method _EFTBANKTRANSIT {s_args} {::return [clientdata_field "/eft.bank_transit"];} public method _EFTBANKACCOUNT {s_args} {::return [clientdata_field "/eft.bank_account"];} public method _EFTTRANSCODE {s_args} {::return [clientdata_field "/eft.transaction_code"];} public method init {} { chain; ::return $this; } public method documentStart {} { chain; addressSourceSet; address_load; ::set _item_reference ""; ::set _item_master ""; } public method load {Src} { ::set _journal_type [[$Src odb_master] odb_path]; ::return [chain $Src]; } public method documentEnd {} { ::return [chain]; } method itemStart {} { chain; #// base resets _itemInfo to NULL ::return $this; } method nextItemLoad {} { ::set Index [[$_reference odb_master] ".odb_deriveds.index/interactive"]; ::if {$_item_reference eq ""} { ::set _item_reference [$Index odb_first]; } else { ::set _item_reference [$Index odb_next $_item_reference]; } ::if {$_item_reference eq ""} { ::qw::throw "Ran off the end of the items."; } ::set _item_master [$_item_reference odb_master]; ::set _item_notes [[$_item_master ".notes"] odb_get]; ::set _item_account_object ""; ::set _item_description [[$_item_master ".description"] odb_get]; ::set _item_balance ""; ::set _item_account ""; ::set _item_accountdescription ""; ::set _item_adpluscomment ""; ::set _item_quantity ""; ::set _item_price ""; ::set _item_net ""; ::set _item_tax1ind ""; ::set _item_tax1rate ""; ::set _item_tax1amount ""; ::set _item_tax2ind ""; ::set _item_tax2rate ""; ::set _item_tax2amount ""; ::set _item_total ""; ::set _item_total1 ""; ::set _item_total2 ""; ::set _unit_of_measure_name ""; ::set _unit_of_measure_quantity ""; ::set _unit_of_measure_price ""; ::set _unit_of_measure_conversion_rate ""; ::set _quantity_original_order ""; ::set _quantity_total_ship ""; ::set _quantity_backorder ""; ::switch -glob -- $_journal_type { /OBJECT/NEWVIEWS/SYSTEM/TRANSACTION/SALES* { ::set Account [[$_item_master ".posting/credit/charge.account"] odb_get]; } /OBJECT/NEWVIEWS/SYSTEM/TRANSACTION/PURCHASE* { ::set Account [[$_item_master ".posting/debit/charge.account"] odb_get]; } default { ::set Account [[$_item_master ".posting/credit.account"] odb_get]; } } ::if {$Account eq ""} { ::return; } ::set Account [$Account odb_master]; ::set _item_account_object $Account; ::set _item_account [[$Account ".name"] odb_get]; ::set _item_accountdescription [[$Account ".description"] odb_get]; ::switch -glob -- [$Account odb_path] { /OBJECT/NEWVIEWS/ACCOUNT/INVENTORY* - /OBJECT/NEWVIEWS/ACCOUNT/EXPENSE* - /OBJECT/NEWVIEWS/ACCOUNT/SALES* { ::set _item_tax1rate [[$Account ".trade_tax/1.rate"] odb_get]; ::set _item_tax2rate [[$Account ".trade_tax/2.rate"] odb_get]; ::if {$_item_tax1rate!=0.0} {::set _item_tax1ind "*";} ::if {$_item_tax2rate!=0.0} {::set _item_tax2ind "*";} } } ::switch -glob -- $_journal_type { /OBJECT/NEWVIEWS/SYSTEM/TRANSACTION/SALES* { ::set _item_quantity [::qw::number::negative [[$_item_master ".posting/credit/charge.quantity"] odb_get]]; ::set _item_price [[$_item_master ".posting/credit/charge.rate"] odb_get]; ::if {$_item_quantity==0.0&&$_item_price==0.0} { ::set _item_quantity ""; ::set _item_price ""; } ::set _item_tax1amount [::qw::number::negative [[$_item_master ".posting/credit/tax1.amount"] odb_get]]; ::set _item_tax2amount [::qw::number::negative [[$_item_master ".posting/credit/tax2.amount"] odb_get]]; ::set _item_net [::qw::number::negative [[$_item_master ".posting/credit/charge.amount"] odb_get]]; ::set _item_total1 [::qw::number::add $_item_net $_item_tax1amount]; ::set _item_total2 [::qw::number::add $_item_net $_item_tax2amount]; ::set _item_total [::qw::number::add $_item_total1 $_item_tax2amount]; ::set _item_balance [::qw::number::negative [$Index odb_total [::sargs .path .posting/credit.amount .reference $_item_reference]]]; } /OBJECT/NEWVIEWS/SYSTEM/TRANSACTION/PURCHASE* { ::set _item_quantity [[$_item_master ".posting/debit/charge.quantity"] odb_get]; ::set _item_price [[$_item_master ".posting/debit/charge.rate"] odb_get]; ::if {$_item_quantity==0.0&&$_item_price==0.0} { ::set _item_quantity ""; ::set _item_price ""; } ::set _item_tax1amount [[$_item_master ".posting/debit/tax1.amount"] odb_get]; ::set _item_tax2amount [[$_item_master ".posting/debit/tax2.amount"] odb_get]; ::set _item_net [[$_item_master ".posting/debit/charge.amount"] odb_get]; ::set _item_total1 [::qw::number::add $_item_net $_item_tax1amount]; ::set _item_total2 [::qw::number::add $_item_net $_item_tax2amount]; ::set _item_total [::qw::number::add $_item_total1 $_item_tax2amount]; ::set _item_balance [$Index odb_total [::sargs .path .posting/credit.amount .reference $_item_reference]]; } default { ::set _item_quantity [::qw::number::negative [[$_item_master ".posting/credit.quantity"] odb_get]]; ::set _item_price [[$_item_master ".posting/credit.rate"] odb_get]; ::set _item_net [::qw::number::negative [[$_item_master ".posting/credit.amount"] odb_get]]; ::set _item_total [::qw::number::negative [[$_item_master ".posting/credit.amount"] odb_get]]; ::set _item_balance [::qw::number::negative [$Index odb_total [::sargs .path .posting/credit.amount .reference $_item_reference]]]; ::if {$_item_quantity==0.0&&$_item_price==0.0} { ::set _item_quantity ""; ::set _item_price ""; } } } ::switch -glob -- $_journal_type { /OBJECT/NEWVIEWS/SYSTEM/TRANSACTION/SALES* - /OBJECT/NEWVIEWS/SYSTEM/TRANSACTION/PURCHASE* { ::set _unit_of_measure_name [[$_item_master .unit_of_measure_name] odb_get]; ::set _unit_of_measure_quantity [[$_item_master .unit_of_measure_quantity] odb_get]; ::set _unit_of_measure_price [[$_item_master .unit_of_measure_price] odb_get]; ::set _unit_of_measure_conversion_rate [[$_item_master .unit_of_measure_conversion_rate] odb_get]; ::set _quantity_original_order [[$_item_master .quantity_original_order] odb_get]; ::set _quantity_total_ship [$_item_master quantity_total_ship_get]; ::set _quantity_backorder [$_item_master quantity_backorder_get]; } } ::return $this; } method addressSourceSet {} { ::set _addressSource [customer_or_supplier_account]; ::return; } method numberOfItemsSet {} { ::set Transaction [$_reference odb_master]; ::switch -glob -- [$Transaction odb_path] { "/OBJECT/NEWVIEWS/SYSTEM/TRANSACTION/PURCHASE*" {::set AmountPath ".posting/credit.amount";} "/OBJECT/NEWVIEWS/SYSTEM/TRANSACTION/SALES*" {::set AmountPath ".posting/debit/customer.amount";} default {::set AmountPath ".posting/debit.amount";} } ::set _itemsToDo 0; ::set RunningBalance 0.0; ::set HeaderAmount [[[$_reference odb_master] $AmountPath] odb_get]; ::set Index [$Transaction ".odb_deriveds.index/interactive"]; ::set LastRef ""; ::for {::set Ref [$Index odb_first];} {$Ref ne ""} {::set Ref [$Index odb_next $Ref];} { ::incr _itemsToDo; ::qw::number::var::add RunningBalance [[[$Ref odb_master] $AmountPath] odb_get]; ::if {$RunningBalance==$HeaderAmount} { ::set LastRef $Ref; ::break; } } ::set LastRef [$Index odb_next $LastRef]; ::while {$LastRef ne ""} { ::switch -- [::string tolower [[[$LastRef odb_master] ".description"] odb_get]] { "@printstop" - "@stopprint" - "@endprint" - "@printend" - "--- housekeeping ---" - "--- details not printed ---" { ::break; } } ::incr _itemsToDo; ::set LastRef [$Index odb_next $LastRef]; } ::return $this; } method moreItemsQuery {} { ::return [chain]; } public method address_load {} { ::set _billingAddress ""; ::set _shippingName ""; ::set _shippingAddress ""; ::if {$_addressSource eq ""} { ::return $this; } ::if {$::qw::control(address_objects_is_enabled)} { ::set Master [$_reference odb_master]; ::switch -glob -- $_journal_type { /OBJECT/NEWVIEWS/SYSTEM/TRANSACTION/SALES* { ::set Bto [[$Master .bill_to_address] odb_get]; } default {::set Bto "";} } ::set _extra_bill_address_object $Bto; ::set _extra_ship_address_object ""; ;#//just in case ::if {$Bto ne ""&&[[$Master odb_database] cpp_find_from_address $Bto] ne ""} { ::set _billingAddress [address_printable [$Bto ".address"]]; ::set _customerName [[$Bto ".address.company"] odb_get]; } else { ::set _billingAddress [address_printable [$_addressSource ".address"]]; ::set _customerName [[$_addressSource ".address.company"] odb_get]; } ::switch -glob -- [$_addressSource odb_path] { "/OBJECT/NEWVIEWS/ACCOUNT/AP/*" - "/OBJECT/NEWVIEWS/ACCOUNT/AR/*" { ::switch -glob -- $_journal_type { /OBJECT/NEWVIEWS/SYSTEM/TRANSACTION/SALES* { ::set Sto [[$Master .ship_to_address] odb_get]; } default {::set Sto "";} } ::set _extra_ship_address_object $Sto; ::if {$Sto ne ""&&[[$Master odb_database] cpp_find_from_address $Sto] ne ""} { ::set _shippingAddress [address_printable [$Sto ".address"]]; ::set _shippingName [[$Sto ".address.company"] odb_get]; } else { ::set _shippingAddress [address_printable [$_addressSource ".address/shipping"]]; ::set _shippingName [[$_addressSource ".address/shipping.company"] odb_get]; } } } ::if {$_customerName eq ""} { ::set _customerName [[$_addressSource ".description"] odb_get]; } ::if {$_shippingName eq ""} { ::set _shippingName [[$_addressSource ".description"] odb_get]; } ::return; } ::set _billingAddress [address_printable [$_addressSource ".address"]]; ::set _customerName [[$_addressSource ".address.company"] odb_get]; ::switch -glob -- [$_addressSource odb_path] { "/OBJECT/NEWVIEWS/ACCOUNT/AP/*" - "/OBJECT/NEWVIEWS/ACCOUNT/AR/*" { ::set _shippingAddress [address_printable [$_addressSource ".address/shipping"]]; ::set _shippingName [[$_addressSource ".address/shipping.company"] odb_get]; } } ::if {$_customerName eq ""} { ::set _customerName [[$_addressSource ".description"] odb_get]; } ::if {$_shippingName eq ""} { ::set _shippingName [[$_addressSource ".description"] odb_get]; } ::return; } } ::if {1} { ::itcl::class ::qw::print::windows::template::donor_receipt { inherit ::qw::print::windows::template; public variable settings ""; public variable donation_data; private variable _donorAddress ""; private variable _donorName ""; private variable _journal_type "/OBJECT/NEWVIEWS/SYSTEM/TRANSACTION/BANK/DEPOSIT/DONATION"; protected variable _item_balance {}; protected variable _item_description {}; protected variable _item_account {}; protected variable _item_accountdescription {}; protected variable _item_quantity {}; protected variable _item_percent {}; protected variable _item_amount {}; protected variable _item_clientdata {}; constructor {args} { ::eval ::qw::print::windows::template::constructor $args; } { } destructor { } public method address_field {Src} { ::if {$_addressSource eq ""} { ::return ""; } ::if {$Src eq "freeform"} { ::return [address_printable [$_addressSource ".address"]]; } ::return [[$_addressSource ".address.$Src"] odb_get]; } ::foreach {Name Field} { "_ADDRESS" "freeform" "_NAME" "company" "_CONTACTNAME" "name.freeform" "_CONTACTNAMESALUTATION" "name.salutation" "_CONTACTNAMEFIRST" "name.first" "_CONTACTNAMEMIDDLE" "name.middle" "_CONTACTNAMELAST" "name.last" "_STREET" "street" "_STREET2" "street2" "_CITY" "city" "_STATE" "state" "_COUNTRY" "country" "_ZIPCODE" "zipcode" "_PHONE" "phone.freeform" "_PHONECOUNTRYCODE" "phone.country_code" "_PHONEAREACODE" "phone.area_code" "_PHONEPREFIX" "phone.prefix" "_PHONESUFFIX" "phone.suffix" "_PHONEEXTENSION" "phone.extension" "_FAX" "phone/fax.freeform" "_FAXCOUNTRYCODE" "phone/fax.country_code" "_FAXAREACODE" "phone/fax.area_code" "_FAXPREFIX" "phone/fax.prefix" "_FAXSUFFIX" "phone/fax.suffix" "_FAXEXTENSION" "phone/fax.extension" "_EMAIL" "email" "_WEBSITE" "website" } { ::set Body [::string map "%_field $Field" {::return [address_field %_field];}] public method $Name {args} $Body; } public method _DONORNAME {s_args} {::return $_donorName;} public method _DONORADDRESS {s_args} {::return $_donorAddress;} public method _DONORPHONE {s_args} {::return [[$_addressSource ".address.phone.freeform"] odb_get];} public method _DONATIONDATE {s_args} {::return [[[$_reference odb_master] ".date"] odb_get];} public method _DONATIONNUMBER {s_args} {::return [[[$_reference odb_master] ".reference"] odb_get];} public method _DONATIONDESCRIPTION {s_args} {::return [[[$_reference odb_master] ".description"] odb_get];} public method _DONATIONTOTAL {s_args} { ::return [[[$_reference odb_master] ".posting/debit/donor.amount"] odb_get]; } public method _DONATIONADVANTAGE {s_args} {::return [::sargs::get $donation_data ".advantage"];} public method _DONATIONRECEIPT {s_args} {::return [::sargs::get $donation_data ".no_advantage"];} public method _ACCOUNT {s_args} { ::set Account [[[$_reference odb_master] ".posting/debit/donor.account"] odb_get]; ::if {$Account eq ""} {::return "";} ::return [[[$Account odb_master] ".name"] odb_get]; } public method _ACCOUNTDESCRIPTION {s_args} { ::set Account [[[$_reference odb_master] ".posting/debit/donor.account"] odb_get]; ::if {$Account eq ""} {::return "";} ::return [[[$Account odb_master] ".description"] odb_get]; } public method invoice_information {Src} { ::set Structure [[[$_reference odb_master] ".invoice_information"] odb_get]; ::return [::sargs::get $Structure "/$Src.value"]; } public method _INFO1 {s_args} {::return [invoice_information 1];} public method _INFO2 {s_args} {::return [invoice_information 2];} public method _INFO3 {s_args} {::return [invoice_information 3];} public method _INFO4 {s_args} {::return [invoice_information 4];} public method _INFO5 {s_args} {::return [invoice_information 5];} public method _INFO6 {s_args} {::return [invoice_information 6];} public method _INFO7 {s_args} {::return [invoice_information 7];} public method _INFO8 {s_args} {::return [invoice_information 8];} public method _INFO9 {s_args} {::return [invoice_information 9];} public method _INFO10 {s_args} {::return [invoice_information 10];} public method _INFO11 {s_args} {::return [invoice_information 11];} public method _INFO12 {s_args} {::return [invoice_information 12];} public method _INFO13 {s_args} {::return [invoice_information 13];} public method _INFO14 {s_args} {::return [invoice_information 14];} public method _INFO15 {s_args} {::return [invoice_information 15];} public method _ITEM_BALANCE {s_args} {::return $_item_balance;} public method _ITEM_DESCRIPTION {s_args} {::return $_item_description;} public method _ITEM_ACCOUNT {s_args} {::return $_item_account;} public method _ITEM_ACCOUNTDESCRIPTION {s_args} {::return $_item_accountdescription;} public method _ITEM_QUANTITY {s_args} {::return $_item_quantity;} public method _ITEM_PERCENT {s_args} {::return $_item_percent;} public method _ITEM_AMOUNT {s_args} {::return $_item_amount;} public method donor_account {{s_args {}}} { ::set Reference [[[$_reference odb_master] ".posting/debit/donor.account"] odb_get]; ::if {$Reference eq ""} {::return "";} ::return [$Reference odb_master]; } public method clientdata_field {Src} { ::set Account [donor_account]; ::if {$Account eq ""} {::return "";} ::set ClientData [[$Account ".structure_data"] odb_get]; ::return [::sargs::get $ClientData $Src]; } public method _EFTBANKID {s_args} {::return [clientdata_field "/eft.bank_id"];} public method _EFTBANKTRANSIT {s_args} {::return [clientdata_field "/eft.bank_transit"];} public method _EFTBANKACCOUNT {s_args} {::return [clientdata_field "/eft.bank_account"];} public method _EFTTRANSCODE {s_args} {::return [clientdata_field "/eft.transaction_code"];} public method init {} { chain; ::return $this; } public method documentStart {} { chain; addressSourceSet; address_load; ::set _item_reference ""; ::set _item_master ""; } public method load {Src} { ::set _journal_type [[$Src odb_master] odb_path]; ::return [chain $Src]; } public method documentEnd {} { ::return [chain]; } method itemStart {} { chain; #// base resets _itemInfo to NULL ::return $this; } method nextItemLoad {} { ::set Index [[$_reference odb_master] ".odb_deriveds.index/interactive"]; ::if {$_item_reference eq ""} { ::set _item_reference [$Index odb_first]; } else { ::set _item_reference [$Index odb_next $_item_reference]; } ::if {$_item_reference eq ""} { ::qw::throw "Ran off the end of the items."; } ::set _item_master [$_item_reference odb_master]; ::set Account [[$_item_master ".posting/credit/revenue.account"] odb_get]; ::if {$Account eq ""} { ::return; } ::set Account [$Account odb_master]; ::set _item_account [[$Account ".name"] odb_get]; ::set _item_accountdescription [[$Account ".description"] odb_get]; ::set _item_description [[$_item_master ".description"] odb_get]; ::set _item_quantity [::qw::number::negative [[$_item_master ".posting/credit/revenue.quantity"] odb_get]]; ::set _item_percent [[$_item_master ".posting/credit/revenue.rate"] odb_get]; ::set _item_amount [::qw::number::negative [[$_item_master ".posting/credit/revenue.amount"] odb_get]]; ::set _item_balance [::qw::number::negative [$Index odb_total [::sargs .path .posting/credit/revenue.amount .reference $_item_reference]]]; ::if {$_item_quantity==0.0&&$_item_percent==0.0} { ::set _item_quantity ""; ::set _item_percent ""; } ::set _item_clientdata [[$_item_master ".clientdata"] odb_get]; ::return $this; } method addressSourceSet {} { ::set _addressSource ""; ::set Master [$_reference odb_master]; ::set Account [[$Master ".posting/debit/donor.account"] odb_get]; ::if {$Account ne ""} { ::set _addressSource [$Account odb_master]; } } method numberOfItemsSet {} { ::set Index [[$_reference odb_master] ".odb_deriveds.index/id"]; ::set _itemsToDo [$Index odb_items]; ::return $this; } method moreItemsQuery {} { ::return [chain]; } public method address_load {} { ::set _donorAddress ""; ::if {$_addressSource eq ""} { ::return $this; } ::set _donorAddress [address_printable [$_addressSource ".address"]]; ::set _donorName [[$_addressSource ".address.company"] odb_get]; ::if {$_donorName eq ""} { ::set _donorName [[$_addressSource ".description"] odb_get]; } } } ::itcl::class ::qw::print::windows::template::donor_statement { inherit ::qw::print::windows::template; public variable settings ""; public variable statement_data; protected variable _item_date ""; protected variable _item_description ""; protected variable _item_amount 0.0; protected variable _item_balance 0.0; protected variable _reference_master ""; protected variable _address ""; protected variable _statement_details_information ""; protected variable _item -1; constructor {args} { ::eval ::qw::print::windows::template::constructor $args; } { } destructor { } public method _DONORNAME {s_args} { ::set Result [[$_reference_master ".address.company"] odb_get]; ::if {$Result ne ""} {::return $Result;} ::return [[$_reference_master ".description"] odb_get]; } public method _DONORADDRESS {s_args} {::return [address_printable [$_reference_master ".address"]];} public method _DONORPHONE {s_args} {::return [[$_reference_master ".address.phone.freeform"] odb_get];} public method _DONORFAX {s_args} {::return [[$_reference_master ".address.phone/fax.freeform"] odb_get];} public method _ACCOUNTNAME {s_args} {::return [[$_reference_master ".name"] odb_get];} public method _ACCOUNTDESCRIPTION {s_args} {::return [[$_reference_master ".description"] odb_get];} public method _RECEIPTDATE {s_args} {::return [::sargs::get $settings ".statement_date"];} public method _RECEIPTNUMBER {s_args} {::return [::sargs::get $_statement_details_information ".next_receipt_number"];} public method _BEGINDATE {s_args} {::return [::sargs::get $settings ".begin_date"];} public method _ENDDATE {s_args} {::return [::sargs::get $settings ".end_date"];} public method _DONORTOTAL {s_args} {::return [::sargs::get $_statement_details_information ".total"];} public method _ITEM_DATE {s_args} {::return $_item_date;} public method _ITEM_REF {s_args} {::return $_item_reference;} public method _ITEM_AMOUNT {s_args} {::return $_item_amount;} public method _ITEM_BALANCE {s_args} {::return $_item_balance;} public method _ITEM_DESCRIPTION {s_args} {::return $_item_description;} public method load {Src} { ::set _reference $Src; ::set _reference_master [$Src odb_master]; ::set _statement_details_information $statement_data; ::set _item_balance 0.0; ::set _item -1; ::return [chain $Src]; } public method documentStart {} { chain; } method itemStart {} { chain; ;#// base resets _itemInfo to NULL ::return $this; } method nextItemLoad {} { ::incr _item; ::set _item_date [::sargs::get $_statement_details_information ".transactions/$_item.date"]; ::set _item_reference [::sargs::get $_statement_details_information ".transactions/$_item.reference"]; ::set _item_description [::sargs::get $_statement_details_information ".transactions/$_item.description"]; ::set _item_amount [::sargs::get $_statement_details_information ".transactions/$_item.amount"]; ::set _item_balance [::qw::number::add $_item_balance $_item_amount]; ::return $this; } method numberOfItemsSet {} { ::set _itemsToDo [::sargs::get $_statement_details_information ".transaction_count"]; ::return $this; } method moreItemsQuery {} { ::return [chain]; } } } ::itcl::class ::qw::print::windows::template::nvnph_rent_receipt { inherit ::qw::print::windows::template; public variable settings ""; public variable statement_data; protected variable _item_month ""; protected variable _item_payment 0.0; protected variable _item_charge 0.0; protected variable _item_include 0.0; protected variable _item_exclude 0.0; protected variable _item_ouamt 0.0; protected variable _item_oubal 0.0; protected variable _reference_master ""; protected variable _address ""; protected variable _statement_details_information ""; protected variable _item -1; constructor {args} { ::eval ::qw::print::windows::template::constructor $args; } { } destructor { } public method _RECIPIENTNAME {s_args} { ::set Result [[$_reference_master ".address.company"] odb_get]; ::if {$Result ne ""} {::return $Result;} ::return [[$_reference_master ".description"] odb_get]; } public method _RECIPIENTADDRESS {s_args} {::return [address_printable [$_reference_master ".address"]];} public method _RECIPIENTPHONE {s_args} {::return [[$_reference_master ".address.phone.freeform"] odb_get];} public method _ACCOUNTNAME {s_args} {::return [[$_reference_master ".name"] odb_get];} public method _ACCOUNTDESCRIPTION {s_args} {::return [[$_reference_master ".description"] odb_get];} public method _RECEIPTDATE {s_args} {::return [::sargs::get $settings ".statement_date"];} public method _BEGINDATE {s_args} {::return [::sargs::get $_statement_details_information .begin_date];} public method _ENDDATE {s_args} {::return [::sargs::get $_statement_details_information .end_date];} public method _DATERANGE {s_args} {::return [::sargs::get $_statement_details_information .date_range];} public method _RECIPIENTTOTALTEXT {s_args} { ::if {[moreItemsQuery]} { ::return ""; } ::return "Total Rent Paid"; } public method _RECIPIENTTOTAL {s_args} { ::if {[moreItemsQuery]} { ::return ""; } ::return [::sargs::get $_statement_details_information ".rent_receipt_amount"]; } public method _TOTALCHARGE {s_args} {::return [::sargs::real_get $_statement_details_information .rent_receipt_charge];} public method _TOTALINCLUDE {s_args} {::return [::sargs::real_get $_statement_details_information .rent_receipt_include];} public method _TOTALEXCLUDE {s_args} {::return [::sargs::real_get $_statement_details_information .rent_receipt_exclude];} public method _TOTALPAYMENT {s_args} {::return [::sargs::real_get $_statement_details_information .rent_receipt_bank];} public method _TOTALAMOUNT {s_args} {::return [::sargs::real_get $_statement_details_information .rent_receipt_amount];} public method _OPENAMOUNT {s_args} { ::return [::sargs::real_get $_statement_details_information .transactions/0.over_under_rb.amount]; } public method _CLOSEAMOUNT {s_args} {::return [::sargs::real_get $_statement_details_information .transactions/12.over_under_rb.amount];} public method _TEXTAMOUNT {s_args} { ::return [checkTextAmount [::sargs::real_get $_statement_details_information .rent_receipt_amount]]; } public method _ITEM_MONTH {s_args} {::return $_item_month;} public method _ITEM_PAYMENT {s_args} {::return $_item_payment;} public method _ITEM_CHARGE {s_args} {::return $_item_charge;} public method _ITEM_INCLUDE {s_args} {::return $_item_include;} public method _ITEM_EXCLUDE {s_args} {::return $_item_exclude;} public method _ITEM_OUAMT {s_args} {::return $_item_ouamt;} public method _ITEM_OUBAL {s_args} {::return $_item_oubal;} public method load {Src} { ::set _reference $Src; ::set _reference_master [$Src odb_master]; ::set _statement_details_information $statement_data; ::set _item 0; ::return [chain $Src]; } public method documentStart {} { chain; addressSourceSet; } method itemStart {} { chain; ;#// base resets _itemInfo to NULL ::return $this; } method nextItemLoad {} { ::set _item_month [::sargs::get $_statement_details_information ".transactions/$_item.month"]; ::set _item_charge [::sargs::get $_statement_details_information ".transactions/$_item.charge.amount"]; ::set _item_include [::sargs::get $_statement_details_information ".transactions/$_item.include.amount"]; ::set _item_exclude [::sargs::get $_statement_details_information ".transactions/$_item.exclude.amount"]; ::set _item_payment [::sargs::get $_statement_details_information ".transactions/$_item.bank.amount"]; ::set _item_ouamt [::sargs::get $_statement_details_information ".transactions/$_item.over_under.amount"]; ::set _item_oubal [::sargs::get $_statement_details_information ".transactions/$_item.over_under_rb.amount"]; ::incr _item; ::return $this; } method numberOfItemsSet {} { ::set _itemsToDo [::sargs::get $_statement_details_information ".transaction_count"]; ::return $this; } method moreItemsQuery {} { ::return [chain]; } } ::itcl::class ::qw::print::windows::template::receipt { inherit ::qw::print::windows::template; public variable settings ""; protected variable _reference_master ""; protected variable _address ""; protected variable _item -1; constructor {args} { ::eval ::qw::print::windows::template::constructor $args; } { } destructor { } public method _TEXTAMOUNT {s_args} { ::set TransactionMaster [$_reference odb_master]; ::set Amount [[$TransactionMaster ".posting/debit.amount"] odb_get]; ::if {$Amount < 0} { ::set Amount [[$TransactionMaster ".posting/credit.amount"] odb_get]; } ::return [checkTextAmount $Amount]; } public method _ACCOUNTDESCRIPTION {s_args} { ::set TransactionMaster [$_reference odb_master]; ::set Account [[$TransactionMaster ".posting/credit.account"] odb_get]; ::set Description ""; ::if {$Account ne ""} { ::set Description [[[$Account odb_master] ".description"] odb_get]; } ::return $Description; } public method _ACCOUNTNAME {s_args} { ::set TransactionMaster [$_reference odb_master]; ::set Account [[$TransactionMaster ".posting/credit.account"] odb_get]; ::set Name ""; ::if {$Account ne ""} { ::set Name [[[$Account odb_master] ".name"] odb_get]; } ::return $Name; } public method _AMOUNT {s_args} { ::set TransactionMaster [$_reference odb_master]; ::set Amount [[$TransactionMaster ".posting/credit.amount"] odb_get]; ::if {$Amount < 0} { ::set Amount [[$TransactionMaster ".posting/debit.amount"] odb_get]; } ::return [::qw::number::format $Amount $currency_format]; } public method _RECEIPTDATE {s_args} { ::set TransactionMaster [$_reference odb_master]; ::set User [[database_Get] cpp_user_get]; ::set DateFormat [[$User .options.date.format] odb_get]; ::return [::qw::date::format [[$TransactionMaster ".date"] odb_get] $::qw::date::formats($DateFormat)]; } public method _RECEIPTDATE1 {s_args} { ::set TransactionMaster [$_reference odb_master]; ::set User [[database_Get] cpp_user_get]; ::set DateFormat [[$User .options.date.format] odb_get]; ::return [::qw::date::format [[$TransactionMaster ".date1"] odb_get] $::qw::date::formats($DateFormat)]; } public method _RECEIPTNUMBER {s_args} { ::set TransactionMaster [$_reference odb_master]; ::return [[$TransactionMaster ".reference"] odb_get]; } public method load {Src} { ::set _reference $Src; ::set _reference_master [$Src odb_master]; ::set _item 0; ::return [chain $Src]; } method addressSourceSet {} { ::set _addressSource ""; ::set Master [$_reference odb_master]; ::set Account [[$Master ".posting/credit.account"] odb_get]; ::if {$Account ne ""} { ::set _addressSource [$Account odb_master]; } } public method documentStart {} { chain; addressSourceSet; } method itemStart {} { chain; ;#// base resets _itemInfo to NULL ::return $this; } method nextItemLoad {} { ::incr _item; ::return $this; } method numberOfItemsSet {} { ::set _itemsToDo 0; ::return $this; } method moreItemsQuery {} { ::return [chain]; } } ::itcl::class ::qw::print::windows::template::manager { private variable _excel_is_running 0; private variable _owner ""; private variable _callback_command ""; private variable _visible 0; private variable _template_file_name ""; private variable _excel ""; private variable _printer ""; private variable _template_workbook ""; private variable _template_sheets ""; private variable _template_sheet1 ""; private variable _data_workbook ""; private variable _data_sheets ""; private variable _data_sheet1 ""; private variable _data_sheet2 ""; private variable _data_cell ""; private variable _dummy_range ""; private variable _printRangeObject ""; private variable _pageObject ""; private variable _printRangeSaveObject ""; private variable _templatePrintRangeObject ""; private variable _printRangeRectangle ""; private variable _abort 0; private variable _printRangeArray {}; private variable _itemAreas 0; private variable _itemAreaHeight -1; private variable _itemAreasArray ""; private variable _itemNamesList ""; private variable _headerNamesList ""; private variable _itemDataList ""; private variable _headerDataList ""; private variable _itemRangesArray ""; private variable _headerRangesArray ""; private variable _printRange ""; private variable _page_number 0; private variable _orphanItemArray {}; private variable _listOfKids ""; private variable _rangeErrorList ""; private variable _template_errors 0; private variable _ready 0; private variable _itemLinesUsed 0; private variable _infoRange ""; private variable _rowHeights ""; protected variable _is_destroying 0; protected variable _filename ""; protected variable _descriptionFontInfo ""; protected variable _descriptionWidth ""; public variable destination "display" {configure_destination $destination;} public variable filename "" {configure_filename $filename;} public variable printer "" {configure_printer $printer;} public variable prompt_settings ""; public variable template_print_speedup 1; method configure_destination {Src} { ::switch -- $Src { "email" - "display" - "preview" - "printer" - "file" {;} default {::qw::throw "Invalid destination \"$Src\". -destination must be one of \"display\", \"preview\", \"printer\", or \"file\".";} } } method configure_filename {Src} { ::if {$Src ne ""} { ::if {[::file exists $Src]} { ::if {[::file isdirectory $Src]} {::qw::throw "Cannot create file \"$Src\", a directory by that name already exists.";} ::if {![::file writable $Src]} {::qw::throw "Cannot overwrite existing file \"$Src\", permission denied.";} } } } method configure_printer {Src} { printer_Set $Src; } constructor {args} { ::set _is_destroying 0; ::set _ready 0; ::eval configure $args;#// (There aren't any configure options, but ...) printer_Set [$::nv2::print::printers default_Get]; } destructor { ::if {[is_being_destroyed]} { ::qw::throw "$this destructor called but object is already being destroyed."; } ::set _is_destroying 1; ::if {$_excel ne ""} { [::qw::get_com_applications] destroy $_excel; ::set _excel ""; } } public method is_being_destroyed {} { ::return $_is_destroying; } public method excel_get {} { ::return $_excel; } public method template_file_name_Set {Src} { ::set _template_file_name $Src; ::return $this; } public method template_file_name_Get {{Src {get}}} { ::return $_template_file_name; } public method visible_Set {Src} { ::if {$_excel ne ""} {$_excel visible_Set $Src;} ::set _visible $Src; ::return $this; } public method visible_Get {} { ::return $_visible; } public method owner_Set {Src} { ::if {$_owner ne ""&& $Src ne $_owner} { ::qw::throw "You can not change the owner once it has been set."; } ::set _owner $Src; ::return $this; } public method owner_Get {} { ::return $_owner; } public method callback_command {args} { ::if {![::llength $args]} {::return $_callback_command;} ::set _callback_command $args; ::return $this; } public method print_preview {} { ::if {!$_ready} { ::qw::throw "??????????????????"; } $_data_sheet1 print_preview; ::return $this; } public method printer_Set {Src} { ::set _printer $Src; ::return $this; } public method printer_Get {} { ::set PrinterName [$_excel active_printer_Get]; ::return [$::nv2::print::printers item_from_excel_name $PrinterName]; } public method print {} { ::if {!$_ready} { ::qw::throw "??????????????????"; } ::if {$_printer ne ""} { $_excel active_printer_Set [$_printer excelname]; } $_data_sheet1 print; ::return $this; } public method file_save {} { $_data_workbook name_Set [::file nativename $filename]; $_data_workbook file_save; } public method file_close {} { $_data_workbook mark_file_saved; $_data_workbook close; } public method deinit {} { $_data_workbook mark_file_saved; $_data_workbook close; [$_excel workbooks] destroy $_data_workbook; } public method init {} { ::qw::try { ::tcom::ref getactiveobject "Excel.Application"; ::set _excel_is_running 1; } catch Exception { ::set _excel_is_running 0; } ::if {$_excel eq ""} { ::qw::try { ::set _excel [[::qw::get_com_applications] factory -application "Excel"]; } catch Exception { ::set _excel ""; ::qw::throw $Exception; } } else { $_excel activate; } ::set template_print_speedup 0; ::if {$destination eq "file" && $filename ne ""} {::set template_print_speedup 1;} ::if {$destination eq "printer"} {::set template_print_speedup 1;} ::set template_print_speedup 0; ::set template_print_speedup 1; ::set template_print_speedup $::qw::control(template_print_speedup); ;#// defaults to 0 with command line switch to turn on ::if {$template_print_speedup} { init_fast; } else { init_standard; } } public method init_fast {} { ::if {[template_file_name_Get] eq ""} {::qw::throw "The template file name not been set.";} ::if {[owner_Get] eq ""} {::qw::throw "The owner has not been set.";} ::if {[callback_command] eq ""} {::qw::throw "The callback_command has not been set.";} qw::try { ::set Handle [::open [template_file_name_Get]]; } catch Exception { ::qw::throw "Error attempting to open template file [template_file_name_Get]" $Exception; } ::close $Handle; ::set Workbooks [$_excel workbooks]; ::if {$filename ne ""} { ::set TemporaryFileName [::file nativename $filename]; } else { ::set TemporaryFileName [::qw::fileutil::temporary_path]; } ::qw::try { ::file copy [template_file_name_Get] $TemporaryFileName; } catch Exception { [::qw::get_com_applications] destroy $_excel; ::qw::throw "Error creating temporary file $TemporaryFileName" $Exception; } qw::try { ::set _template_workbook [$Workbooks factory -filename [::file nativename $TemporaryFileName]]; } catch Exception { [::qw::get_com_applications] destroy $_excel; ::qw::throw "Error opening temporary file $TemporaryFileName" $Exception; } ::set _template_sheets [$_template_workbook "sheets"]; ::set _template_sheet1 [$_template_sheets item [::lindex [$_template_sheets names] 0]]; ::set _data_workbook $_template_workbook; ::set _data_sheets $_template_sheets; ::set _data_sheet1 $_template_sheet1; ::set _data_sheet2 [$_data_sheets factory]; ::set _pageObject [[$_data_sheet1 ranges] factory]; ;#// Create a data range on sheet 1 to represent the current page ::set _printRangeObject [[$_data_sheet1 ranges] factory]; ;#// Create a data range on sheet 1 to represent the print area ::set _printRangeSaveObject [[$_data_sheet2 ranges] factory]; ;#// Create a data range on sheet2 where we will save a copy of the template image ::set _dummy_range [[$_data_sheet1 ranges] factory]; ;#// Create a cell at 256.0 to avoid "The clipboard contains a lot of ..." warning. (See end of print_document method) $_dummy_range rectangle_Set {.position {.x 255 .y 0} .size {.x 1 .y 1}}; printRangesInit; printRangesCheck; reportRangeErrors; getRowHeights; ;#// sets variable _rowHeights to a tcl list of row heights (cell count) $_template_workbook mark_file_saved; ::set _data_cell [[$_data_sheet1 cells] factory]; ::set _pageObject [[$_data_sheet1 ranges] factory]; ::set _infoRange [[$_data_sheet2 ranges] factory]; $_pageObject rectangle_Set [$_printRangeObject rectangle_Get]; ::set _page_number 0; ::set _itemLinesUsed 0; $_data_workbook mark_file_saved; description_info_get; ;#// sets variables ::array set RangeInfo [rangeInformationGet description], and _descriptionFontInfo and _...Width ::if {$_printer ne ""} { $_excel active_printer_Set [$_printer excelname]; } ::set _ready 1; } public method init_standard {} { ::if {[template_file_name_Get] eq ""} {::qw::throw "The template file name not been set.";} ::if {[owner_Get] eq ""} {::qw::throw "The owner has not been set.";} ::if {[callback_command] eq ""} {::qw::throw "The callback_command has not been set.";} qw::try { ::set Handle [::open [template_file_name_Get]]; } catch Exception { ::qw::throw "Error attempting to open template file [template_file_name_Get]" $Exception; } ::close $Handle; ::set Workbooks [$_excel workbooks]; qw::try { ::set _template_workbook [$Workbooks factory -filename [::file nativename [template_file_name_Get]]]; } catch Exception { [::qw::get_com_applications] destroy $_excel; ::qw::throw "Error opening template file [template_file_name_Get]" $Exception; } ::set _template_sheets [$_template_workbook "sheets"]; ::set _template_sheet1 [$_template_sheets item [::lindex [$_template_sheets names] 0]]; ::set _data_workbook [$Workbooks factory]; ::set _data_sheets [$_data_workbook "sheets"]; ::set _data_sheet1 [$_data_sheets item [::lindex [$_data_sheets names] 0]]; ::if {[$_data_sheets items]>1} { ::set _data_sheet2 [$_data_sheets item [::lindex [$_data_sheets names] 1]]; } else { ::set _data_sheet2 [$_data_sheets factory]; $_data_sheet2 name_Set "Sheet2"; } ::set _pageObject [[$_data_sheet1 ranges] factory]; ;#// Create a data range on sheet 1 to represent the current page ::set _printRangeObject [[$_data_sheet1 ranges] factory]; ;#// Create a data range on sheet 1 to represent the print area ::set _printRangeSaveObject [[$_data_sheet2 ranges] factory]; ;#//# Create a data range on sheet2 where we will save a copy of the template image ::set _dummy_range [[$_data_sheet1 ranges] factory]; ;#// Create a cell at 256.0 to avoid "The clipboard contains a lot of ..." warning. (See end of print_document method) $_dummy_range rectangle_Set {.position {.x 255 .y 0} .size {.x 1 .y 1}}; printRangesInit; printRangesCheck; ;#// AND clipboard copy ranges from one workbook/sheet to another workbook/sheet reportRangeErrors; setColumnWidths; getRowHeights; copyPageSetup; $_template_workbook mark_file_saved; $_template_workbook close; $Workbooks destroy $_template_workbook; ::set _data_cell [[$_data_sheet1 cells] factory]; ::set _pageObject [[$_data_sheet1 ranges] factory]; ::set _infoRange [[$_data_sheet1 ranges] factory]; $_pageObject rectangle_Set [$_printRangeObject rectangle_Get]; ::set _page_number 0; ::set _itemLinesUsed 0; $_data_workbook mark_file_saved; description_info_get; ;#// sets variables ::array set RangeInfo [rangeInformationGet description], and _descriptionFontInfo and _...Width ::if {$_printer ne ""} { $_excel active_printer_Set [$_printer excelname]; } ::set _ready 1; } public method pageObject_get_for_bughunt {} { ::return $_pageObject; } public method load {} { ;#// original ::if {[::expr [$_pageObject y_Get]+[$_pageObject height_Get]]>65536} { ::qw::throw "Excel limit of 65,536 lines reached."; } $_excel calculation_mode "manual"; $_data_sheet2 visible 1; print_document; ;#// original ::if {($destination eq "file"||$destination eq "email") \ &&[::sargs::get [::qw::file::info "$filename"] .extension] eq ".pdf" \ &&[::string first %_ "[::sargs::get $prompt_settings .filename]"]<0 \ } { ::set Result [$_data_sheet1 create_pdf_file [::sargs .filename "$filename"]]; } $_data_sheet2 visible 0; $_excel calculation_mode "automatic"; $_data_workbook mark_file_saved; ::return $this; } public method abort {} { ::set _abort 1; ::return $this; } public method rangeInformationGet {Src} { ::set Range ""; ::foreach Name [::array names _headerRangesArray] { ::if {[rootName $Name] eq $Src} { ::set Range $_headerRangesArray($Name); ::break; } } ::if {$Range eq ""} { ::foreach Name [::array names _itemRangesArray] { ::if {[rootName $Name] eq $Src} { ::set Range $_itemRangesArray($Name); ::break; } } } ::if {$Range eq ""} { ::qw::throw "Attempt to get information on non-existent range name \"$Src\"."; } $_infoRange rectangle_Set $Range; ::set Result [$_infoRange properties ".rectangle 1 .font 1 .shrinktofit 1"]; ::return $Result; } public method itemAreaRows {} { ::return $_itemAreaHeight; } public method itemNames {} { ::return $_itemDataList; } public method headerNames {} { ::return $_headerDataList; } public method printRangeNames {} { ::return [::array names _printRangeArray]; } public method printRanges {} { ::return [::array get _printRangeArray]; } public method can_print {} { ::if {[$_excel active_printer_Get] eq ""} {::return 0;} ::return 1; } public method template_range_list {} { ::set Result ""; ::foreach {Name Range} [printRanges] { ::lappend Result [::list $Name [::qw::excel::toExcelRange $Range] ""]; } ::foreach {Name Range} [::array get _itemAreasArray] { ::lappend Result [::list ITEM_AREA_$Name [::qw::excel::toExcelRange $Range] ""]; } ::lappend Result [::list "print area" [::qw::excel::toExcelRange $_printRangeRectangle] ""]; ::return $Result; } private method printRangesInit {} { ::unset -nocomplain _printRangeArray; ::array set _printRangeArray {}; ::unset -nocomplain _itemAreasArray; ::array set _itemAreasArray {}; ::unset -nocomplain _itemRangesArray; ::array set _itemRangesArray {}; ::unset -nocomplain _headerRangesArray; ::array set _headerRangesArray {}; ::set _rangeErrorList ""; ::set _template_errors 0; ::set _rowHeights ""; ::set TemplateSheet1Ranges [$_template_sheet1 ranges]; ::for {::set RangeItem [$TemplateSheet1Ranges kidFirst]} {$RangeItem ne ""} {::set RangeItem [$TemplateSheet1Ranges kidNext $RangeItem]} { ::if {$template_print_speedup} { ::if {[$RangeItem name_Get] eq ""} {::continue;} } ::set _printRangeArray([$RangeItem name_Get]) [$RangeItem rectangle_Get]; } ::set _itemAreas 0; ::set _itemAreaHeight -1; ::array unset _itemAreasArray; ::set _itemNamesList ""; ::set _headerNamesList ""; ::foreach {Name Range} [::array get _printRangeArray] { ::set UName [::string toupper $Name]; ::if {[::string first "[::string toupper [::lindex [$_template_sheets names] 0]]!PRINT_AREA" $UName]>=0 \ ||[::string first "[::string toupper [::lindex [$_template_sheets names] 0]]!ZONE_D_IMPRESSION" $UName]>=0 \ } { ::set _printRangeRectangle [[$TemplateSheet1Ranges item $Name] rectangle_Get]; ::array unset _printRangeArray $Name; ::continue; } ::set NamePieces [::split $UName "_"]; ::if {[::lindex $NamePieces 0] eq "ITEM"} { ::if {[::lindex $NamePieces 1] eq "AREA"} { ::set Suffix [::lindex $NamePieces 2]; ::set _itemAreasArray($Suffix) $Range; ::incr _itemAreas; ::array unset _printRangeArray $Name; ::continue; } ::lappend _itemNamesList $UName; ::set _itemRangesArray($UName) $Range; ::continue; } ::lappend _headerNamesList $UName; ::set _headerRangesArray($UName) $Range; } ::return $this; } private method printRangesCheck {} { ::if {$_printRangeRectangle eq ""} { addRangeError "No print range has been set on Sheet1 of the template."; } else { ::foreach {Name Range} [::array get _printRangeArray] { ::if {[::QW::GUI::RECTANGLE::isRectangleInside $_printRangeRectangle $Range]} { ::continue; } addRangeError "Part or all of range $Name is outside the print range."; } $_pageObject rectangle_Set $_printRangeRectangle; ;#// i.e. _data_sheet1 $_printRangeObject rectangle_Set $_printRangeRectangle; ;#// i.e. _data_sheet1 $_printRangeSaveObject rectangle_Set $_printRangeRectangle; ;#// i.e. _data_sheet2 ::set TemplatePrintRangeObject [[$_template_sheet1 ranges] factory]; $TemplatePrintRangeObject rectangle_Set $_printRangeRectangle; rangeCopy $TemplatePrintRangeObject $_printRangeSaveObject; ;#// _template_sheet1 to _data_sheet2 rangeCopy $TemplatePrintRangeObject $_pageObject; ;#// _template_sheet1 to _data_sheet1 ::if {!$template_print_speedup} { rangeCopy $TemplatePrintRangeObject $_pageObject; ;#// _template_sheet1 to _data_sheet1 AGAIN? } [$_template_sheet1 ranges] destroy $TemplatePrintRangeObject; } ::set _itemAreaHeight -1; ::set FirstAreaName ""; ::foreach {Name Range} [::array get _itemAreasArray] { ::set AreaHeight [::sargs::get $Range ".size.y"]; ::if {$_itemAreaHeight == -1} { ::set _itemAreaHeight $AreaHeight; ::set FirstAreaName $Name; ::continue; } ::if {$AreaHeight==$_itemAreaHeight} {::continue;} addRangeError "Item area $Name is $AreaHeight rows, but item area $FirstAreaName is $_itemAreaHeight rows."; } ::foreach Name $_headerNamesList { ::set Range $_headerRangesArray($Name); ::foreach {ItemAreaSuffix ItemAreaRange} [::array get _itemAreasArray] { ::if {![::QW::GUI::RECTANGLE::isRectangleInside $ItemAreaRange $Range]} {::continue;} addRangeError "Part or all of header range $Name is inside ITEM_AREA_$ItemAreaSuffix."; } ::if {[::sargs::get $Range ".size.x"]>1} { addRangeError "Header range $Name is greater than one cell wide."; } } ::foreach Name $_itemNamesList { ::set Range $_itemRangesArray($Name); ::set Found 0; ::foreach {ItemAreaSuffix ItemAreaRange} [::array get _itemAreasArray] { ::if {[::QW::GUI::RECTANGLE::isRectangleInside $ItemAreaRange $Range]} { ::set Found 1; ::set ItemY [::sargs::get $Range ".position.y"]; ::set AreaY [::sargs::get $ItemAreaRange ".position.y"]; ::if {$ItemY!=$AreaY} { addRangeError "Item range $Name on row $ItemY is not at top of ITEM_AREA_$ItemAreaSuffix range (row $AreaY)."; } } } ::if {!$Found} { addRangeError "Item range $Name is not inside an ITEM_AREA range."; } ::if {[::sargs::get $Range ".size.x"]>1} { addRangeError "Item range $Name is greater than one cell wide."; } } ::unset -nocomplain TempArray; ::foreach RawName $_headerNamesList { ::set TempArray([rootName $RawName]) 1; } ::set _headerDataList [::array names TempArray]; ::unset -nocomplain TempArray; ::foreach RawName $_itemNamesList {::set TempArray([rootName $RawName]) 1;} ::set _itemDataList [::array names TempArray]; ::return $this; } public method description_info_get {} { ::if {[::lsearch -glob $_itemNamesList "ITEM_DESCRIPTIONPLUSAD*"]>=0} { ::array set RangeInfo [rangeInformationGet "ITEM_DESCRIPTIONPLUSAD"]; ::set _descriptionFontInfo $RangeInfo(-font); ::set _descriptionWidth [::sargs::get $RangeInfo(-size) ".x"]; ::return; } ::if {[::lsearch -glob $_itemNamesList "ITEM_DESCRIPTIONACCOUNT*"]>=0} { ::array set RangeInfo [rangeInformationGet "ITEM_DESCRIPTIONACCOUNT"]; ::set _descriptionFontInfo $RangeInfo(-font); ::set _descriptionWidth [::sargs::get $RangeInfo(-size) ".x"]; ::return; } ::if {[::lsearch -glob $_itemNamesList "ITEM_DESCRIPTION*"]>=0} { ::array set RangeInfo [rangeInformationGet "ITEM_DESCRIPTION"]; ::set _descriptionFontInfo $RangeInfo(-font); ::set _descriptionWidth [::sargs::get $RangeInfo(-size) ".x"]; } } private method setColumnWidths {} { ::set TemplateColumns [$_template_sheet1 columns]; ::set TemplateColumn [$TemplateColumns factory]; ::set DataColumns [$_data_sheet1 columns]; ::set DataColumn [$DataColumns factory]; ::set ColumnStart [::sargs::get [$_printRangeObject rectangle_Get] ".position.x"]; ::set Columns [::sargs::get [$_printRangeObject rectangle_Get] ".size.x"]; ::set ColumnEnd [::expr $ColumnStart+$Columns] ::for {::set Column $ColumnStart;} {$Column<$ColumnEnd} {::incr Column;} { $TemplateColumn column_Set $Column; $DataColumn column_Set $Column; $DataColumn width_characters_Set [$TemplateColumn width_characters_Get]; } $TemplateColumns destroy $TemplateColumn; $TemplateColumns destroy $DataColumn; ::return $this; } private method getRowHeights {} { ::set TemplateRows [$_template_sheet1 rows]; ::set TemplateRow [$TemplateRows factory]; ::set RowStart [::sargs::get [$_printRangeObject rectangle_Get] ".position.y"]; ::set Rows [::sargs::get [$_printRangeObject rectangle_Get] ".size.y"]; ::set RowEnd [::expr $RowStart+$Rows] ::for {::set Row $RowStart;} {$Row<$RowEnd} {::incr Row;} { $TemplateRow row_Set $Row; ::lappend _rowHeights [$TemplateRow height_Get]; } $TemplateRows destroy $TemplateRow; ::return $this; } private method setRowHeights {} { ::set DataRows [$_data_sheet1 rows]; ::set DataRow [$DataRows factory]; ::set RowStart [::sargs::get [$_pageObject rectangle_Get] ".position.y"]; ::set Rows [::sargs::get [$_pageObject rectangle_Get] ".size.y"]; ::set RowEnd [::expr $RowStart+$Rows] ::set Index 0; ::for {::set Row $RowStart;} {$Row<$RowEnd} {::incr Row;} { $DataRow row_Set $Row; ::set Height [::lindex $_rowHeights $Index]; ::if {[$DataRow height_Get]!=$Height} { $DataRow height_Set $Height; } else { } ::incr Index; } $DataRows destroy $DataRow; ::return $this; } private method copyPageSetup {} { ::eval [$_data_sheet1 pagesetup] settingsset [[$_template_sheet1 pagesetup] settingsget]; } private method addRangeError {Src} { ::lappend _rangeErrorList $Src; ::incr _template_errors; ::return $this; } private method reportRangeErrors {} { ::if {!$_template_errors} {::return $this;} ::set S [::expr $_template_errors>1?{s}:{}]; ::qw::throw [::sargs \ .text "$_template_errors error$S found in the template named range$S. Click Help for details." \ .help_id 907020060427112115 \ .error_list $_rangeErrorList \ .template_filename [template_file_name_Get] \ ]; ::return $this; } private method rootName {Src} { ::set NamePieces [::split $Src "_"]; ::if {[::llength $NamePieces]>3} { ::addRangeError "Invalid range name \"$Src\". (Contains more than 2 \"_\" characters.)"; } ::if {[::llength $NamePieces]>2} { ::return [::join [::lrange $NamePieces 0 end-1] "_"]; } ::if {[::lindex $NamePieces 0] eq "ITEM"} { ::return [::join $NamePieces "_"]; } ::return [::lindex $NamePieces 0]; } private method print_document {} { ;#// original $_owner template_callback ".command documentstart"; ::unset -nocomplain _orphanItemArray; ::array set _orphanItemArray {}; ::if {$_page_number} { ::if {($destination eq "file"||$destination eq "email") \ &&[::string first %_ "[::sargs::get $prompt_settings .filename]"]>=0 \ } { $_printRangeObject Clear; ;#// almost works, we end up with REALLY ALMOST empty template pages, which print preview thankfully ignores $_printRangeObject rectangle_Set [$_printRangeSaveObject rectangle_Get]; $_pageObject rectangle_Set [$_printRangeObject rectangle_Get]; ::set _page_number 0; ::set _itemLinesUsed 0; } } ::while {1 && !$_abort} { ::if {$template_print_speedup} { rangeCopy $_printRangeSaveObject $_pageObject; ;#// _data_sheet2 to _data_sheet1 setRowHeights; } else { rangeCopy $_printRangeSaveObject $_pageObject; ;#// _data_sheet2 to _data_sheet1 setRowHeights; } ::set ItemLinesRemaining $_itemAreaHeight; ::set LineOffset 0; ::set PageOffset [$_pageObject y_Get]; $_owner template_callback ".command pagestart"; ::while {[$_owner template_callback ".command moreitemsquery"] && !$_abort} { ::unset -nocomplain Data; ::if {[::llength [::array names _orphanItemArray]]} { ::foreach {N V} [::array get _orphanItemArray] { ::set Data($N) [::lindex $V 0]; } ::array unset _orphanItemArray; } else { $_owner template_callback ".command itemstart"; ::array set Data [$_owner template_callback [::sargs ".command" "item" ".names" $_itemNamesList]]; } ::set ItemHeight 1; ::foreach {Name Range} [::array get _itemRangesArray] { ::if {![::info exists Data($Name)]} { ::continue; } ::set Range [::QW::GUI::RECTANGLE::moveBy $Range ".x 0 .y [::expr $PageOffset+$LineOffset]"]; ::set Value $Data($Name); ::if {$Value eq ""} { ::continue; } ::set ItemLines 1; ::switch -glob -- $Name { "ITEM_DESCRIPTION*" - "ITEM_DESCRIPTIONACCOUNT*" - "ITEM_DESCRIPTIONPLUSAD*" { ::set Value \ [::qw::bob::WrapText [::qw::list { ".text" [::string trim $Value] ".font" $_descriptionFontInfo ".size" $_descriptionWidth }]] \ ; ::set ItemLines [::llength $Value]; ::if {$ItemLines>$ItemLinesRemaining} { ::set OrphanValue [::lrange $Value $ItemLinesRemaining end]; ::set _orphanItemArray($Name) $OrphanValue; ::set Value [::lrange $Value 0 [::expr $ItemLinesRemaining-1]]; ::set ItemLines $ItemLinesRemaining; } ::sargs::var::set Range ".size.y" $ItemLinesRemaining; cell_value_set_rows [::sargs ".range" $Range ".value" $Value]; } default { ::if {[::string first "DATE" $Name]>=0} { ::set Value [::qw::excel::ccyymmdd_to_excel_date $Value]; } $_data_cell point_Set [::sargs::get $Range ".position"]; $_data_cell value_Set $Value; } } ::if {$ItemLines>$ItemHeight} { ::set ItemHeight $ItemLines; } } ::if {$_itemAreaHeight<1} { ::continue; } ::incr LineOffset $ItemHeight; ::incr ItemLinesRemaining [::expr $ItemHeight*-1]; ::if {$ItemLinesRemaining<0} { ::qw::bug "907020031003072230" "Item area overflow 2"; } ::if {$ItemLinesRemaining==0} { ::break; } ::if {[$_owner template_callback ".command pagebreakquery"]} { ::break; } } ::unset -nocomplain Data; ::array set Data [$_owner template_callback [::sargs ".command" "data" ".names" $_headerNamesList]]; ::foreach {Name Range} [::array get _headerRangesArray] { ::set Range [::QW::GUI::RECTANGLE::moveBy $Range ".x 0 .y $PageOffset"]; #// Adjust y for current page ::set Value $Data($Name); ::if {$Value eq ""} { ::continue; } ::set Format ""; ::if {[::sargs::exists $Value ".format"]} { ::set Format [::sargs::get $Value ".format"]; ::set Value [::sargs::get $Value ".value"]; } ::if {$Format eq ""&&[::string first "DATE" $Name]>=0} { ::if {[::regsub -all {([^0-9])} $Value ""] ne ""} { ::set Value [::qw::excel::ccyymmdd_to_excel_date $Value]; } } ::set Value [::split $Value \n]; cell_value_set_rows [::sargs ".value" $Value ".range" $Range ".format" $Format]; } ::incr PageOffset [$_pageObject height_Get]; ::if {$_page_number} { $_printRangeObject heightIncrement [$_pageObject height_Get]; } $_pageObject yIncrement [$_pageObject height_Get]; ;#// Move the page object down $_data_sheet1 page_break_insert [$_pageObject y_Get]; ;#// Insert a page-break $_owner template_callback ".command pageend"; ::incr _page_number; ::if {![$_owner template_callback ".command moreitemsquery"]} { ::break; } } $_data_sheet1 print_range_Set [$_printRangeObject rectangle_Get]; $_data_sheet1 activate; $_data_workbook mark_file_saved; $_dummy_range rectangle_Set {.position {.x 0 .y 0} .size {.x 1 .y 1}}; ::while {[$_dummy_range merged]} { $_dummy_range yIncrement 1; } $_dummy_range activate; $_dummy_range select; $_dummy_range copy; ::clipboard clear; $_owner template_callback ".command documentend"; ::if {!($destination eq "file"||$destination eq "email")} { ::return $this; } $_excel calculation_mode "automatic"; ::set Fname "$filename"; ::if {[$_owner address_source_get] eq ""} { ::lappend Slist %_name "noname"; ::lappend Slist %_description "nodescription"; } else { ::switch -glob [[$_owner address_source_get] odb_path] { /OBJECT/NEWVIEWS/SYSTEM/EMPLOYEE* { ::set Tname [[[$_owner address_source_get] .employee_id] odb_get]; ::set Tdescription [[[$_owner address_source_get] .employee_name.print_as] odb_get]; } default { ::set Tname [[[$_owner address_source_get] .name] odb_get]; ::set Tdescription [[[$_owner address_source_get] .description] odb_get]; } } ::lappend Slist %_name "[::string map {" " _ , _ . _} $Tname]"; ::lappend Slist %_description "[::string map {" " _ , _ . _} $Tdescription]"; } ::lappend Slist %_clock [::qw::date::from_number clock_second [::clock seconds]]; ::set Fname [::string map $Slist $filename]; ::if {[::sargs::get [::qw::file::info $filename] .extension] eq ".pdf" \ &&[::string first %_ "[::sargs::get $prompt_settings .filename]"]>=0 \ } { ::set Result [$_data_sheet1 create_pdf_file [::sargs .filename $Fname]]; } ::if {[::string first ".xl" [::sargs::get [::qw::file::info "$filename"] .extension]]==0 \ &&[::string first %_ "[::sargs::get $prompt_settings .filename]"]>=0 \ } { $_data_workbook name_Set [::file nativename $Fname]; $_data_workbook file_save; } ::set SrcEmail [::sargs::get $prompt_settings .email_from]; ::set DstEmail [$_owner address_field [::sargs .name EMAIL .field .email]]; ::if {$destination eq "email" &&[::sargs::get $prompt_settings .email_status] eq "active" \ &&($SrcEmail ne ""||[::sargs::exists $prompt_settings .oauth]) \ &&$DstEmail ne "" \ &&[::string first %_ "[::sargs::get $prompt_settings .filename]"]>=0 \ } { ::set LogFileName [::sargs::get $prompt_settings .email_log_file]; ::if {$LogFileName ne ""} { ::qw::try { ::set LogFile [::open $LogFileName a+]; } catch Exception { ::qw::throw [::sargs \ .text "Could not open/create log file \"$LogFileName\", $Exception" \ .help_id 0 \ .tcl_error $Exception \ .filename $LogFileName \ ]; } } ::set Eerror 0; ::set Result ""; ::set LogEntry ""; ::set LogEntryId [::qw::date::from_number clock_second [::clock seconds]]_[[::sargs::get $prompt_settings .prompt_window] unique_id]; ::set DateStamp [::clock format [::clock seconds] -format $::qw::date::formats(yyyy-mm-dd hh:mm:ss am/pm)]; ::sargs::var::set LogEntry .date_stamp $DateStamp; ::set SArgs [[::sargs::get $prompt_settings .prompt_window] settings_prompt_validate_email_extend $prompt_settings]; ;#//#nv2.38.4 (oauth) - includes .email_settings_sub and .email_settings_name ::sargs::var::set SArgs .email_from "$SrcEmail"; ::sargs::var::set SArgs .email_to "$DstEmail"; ::sargs::var::set SArgs .email_attachment_file_list "$Fname"; ::qw::try { ::set Result [[::sargs::get $prompt_settings .prompt_window] email_send $SArgs]; } catch Exception { ::set Eerror 1; ::set Result "Exception"; } ::if {[::sargs::get $SArgs .email_tls_password] ne ""} { ::sargs::var::set SArgs .email_tls_password [::string repeat * 8]; } ::set Procedure [::string map {"/OBJECT/SYSTEM/WINDOW/SCROLLED/TABLE/NOTES/PROCEDURE" ""} [[::sargs::get $prompt_settings .prompt_window] odb_class_path]]; ::sargs::var::+= LogEntry [::sargs .options [::string map {.email_ .} $SArgs]]; ::sargs::var::+= LogEntry [::sargs .prompt_window $Procedure]; ;#// replace unreadable address in SArgs ::if {$Eerror} { ::sargs::var::+= LogEntry [::sargs .exception $Exception]; } ::if {$Result ne ""} { ::sargs::var::set LogEntry .result "failure"; ::sargs::var::set LogEntry .error $Result; } else { ::sargs::var::set LogEntry .result "success"; } ::if {[::sargs::get $SArgs .email_log_smtp] eq "yes"} { ::sargs::var::set LogEntry .smtp_log $::qw::control(smtp_log); } else { ::sargs::var::set LogEntry .smtp_log $::qw::control(smtp_log_id); } ::set LogEntry [::sargs .email_log_$LogEntryId $LogEntry]; ::set LogEntry [::sargs::format .structure $LogEntry]; ::if {$LogFileName ne ""} { ::puts $LogFile $LogEntry; ::close $LogFile; } ::if {$Eerror} { ::qw::throw $Exception; } } ::return $this; } private method cell_value_set_rows {s_args} { ::set Value [::sargs::get $s_args ".value"]; ::set Range [::sargs::get $s_args ".range"]; ::set Point [::sargs::get $Range ".position"]; ::set Format [::sargs::get $s_args ".format"]; ::set RowStart [::sargs::get $Point ".y"]; ::set RowEnd [::expr $RowStart+[::sargs::get $Range ".size.y"] -1]; ::for {::set Row $RowStart} {$Row<=$RowEnd} {::incr Row} { ::set Item [::lindex $Value 0]; ::set Value [::lrange $Value 1 end]; ::set Point [::sargs::set $Point ".y" $Row]; $_data_cell point_Set $Point; ::if {$Format ne ""} { $_data_cell format_Set $Format; } $_data_cell value_Set $Item; ::if {$Value eq ""} {::break;} } ::return $Value; } public method rangeCopy {Src Dst} { $Src properties [::list .rectangle 1 .font 1 .shrinktofit 1]; $Src copy; $Dst activate; $Dst select; $Dst paste; ::clipboard clear; ::return $this; } public method range_dump {Src} { ::set SrcName [::string range $Src [::string last :: $Src] end]; ::set Owner [$Src owner_Get]; ::while {$Owner ne ""} { ::if {[$Owner isa "::qw::com::collection"] \ &&![$Owner isa "::qw::com::applications"] \ } { ::set Owner [$Owner owner_Get]; } ::append SrcName [::string range $Owner [::string last :: $Owner] end]; ::set Owner [$Owner owner_Get]; } ::return $SrcName; } } ::itcl::class ::qw::print::windows::text { inherit ::qw::print::windows; private variable _word ""; private variable _documents ""; constructor {args} { ::eval ::qw::print::windows::constructor $args; } { } public method init {} { chain; ::if {$_word eq ""} { ::qw::try { ::set _word [[::qw::get_com_applications] factory -application "Word" -destination $destination]; } catch Exception { ::set _word ""; ::qw::throw $Exception; } } ::set _documents [$_word documents]; ::return $this; } destructor { ::if {$_word ne ""} { ::if {[$_word is_being_destroyed]} { ::qw::throw "$this attempted to destroy word $_word but it is already being destroyed."; } $_word destroy_application; ::itcl::delete object $_word; ::set _word ""; } } public method abort {} { chain; ::return $this; } public method printer_Set {Src} { ::return $this; } public method printer_Get {} { ::set PrinterName [$_word active_printer_Get]; ::return [$::nv2::print::printers item_from_excel_name $PrinterName]; } public method can_print {} { ::if {[$_word active_printer_Get] eq ""} {::return 0;} ::return 1; } } ::itcl::class ::qw::print::windows::text::document { inherit ::qw::print::windows::text; private variable _document ""; private variable _pagesetup ""; private variable _ranges ""; private variable _range ""; constructor {args} { ::eval ::qw::print::windows::constructor $args; } { } public method init {} { chain; ::set _document [$_documents factory]; $_document activate; ::set _ranges [$_document ranges] ::set _range [$_ranges factory] $_range position_Set {.start 0 .end 0}; ::return $this; } destructor { } public method abort {} { $_document mark_file_saved; chain; ::return $this; } public method printer_Set {Src} { ::return $this; } public method printer_Get {} { ::set PrinterName [$_word active_printer_Get]; ::return [$::nv2::print::printers item_from_excel_name $PrinterName]; } public method set_print_range {Src} { $_document print_range_Set $Src; ::return $this; } public method get_print_range {} { ::return [$_document print_range_Get]; } public method can_print {} { ::if {[$_word active_printer_Get] eq ""} {::return 0;} ::return 1; } public method print {} { abort_check; $_document print; ::return $this; } public method print_show {} { abort_check; $_document activate; $_word visible_Set 1; ::return $this; } public method print_preview {} { abort_check; $_document print_preview; ::return $this; } public method range_value_Set {Position Value} { abort_check; [$_range position_Set $Position] value_Set $Value; ::return $this; } public method mark_file_saved {} { abort_check; $_document mark_file_saved; } public method pagesetup {Name Value} { $_pagesetup $Name $Value; ::return $this; } } ::itcl::class ::qw::print::windows::text::mailmerge { inherit ::qw::print::windows::text; public variable mainfilename "" {configure_mainfilename $mainfilename;} public variable datafilename "" {configure_datafilename $datafilename;} public variable newfilename "" {configure_newfilename $newfilename;} protected variable _mailmerge_manager ""; constructor {args} { ::eval ::qw::print::windows::constructor $args; } { ::set _mailmerge_manager [::qw::print::windows::mailmerge::manager .#auto]; $_mailmerge_manager owner_Set [::itcl::code $this]; $_mailmerge_manager callback_command $this mailmerge_callback; ::eval configure $args; ::return $this; } destructor { ::if {$_mailmerge_manager ne ""} { ::if {[$_mailmerge_manager is_being_destroyed]} {::qw::throw "$this attempted to destroy _mailmerge_manager $_mailmerge_manager but it is already being destroyed.";} ::itcl::delete object $_mailmerge_manager; ::set _mailmerge_manager ""; } } protected method configure_destination {Src} { $_mailmerge_manager configure -destination $Src; } protected method configure_printer {Src} { chain $Src; $_mailmerge_manager configure -printer $printer; } protected method configure_mainfilename {Src} { $_mailmerge_manager configure -mainfilename $mainfilename; } protected method configure_datafilename {Src} { $_mailmerge_manager configure -datafilename $datafilename; } protected method configure_newfilename {Src} { $_mailmerge_manager configure -newfilename $newfilename; } public method merge {} { $_mailmerge_manager init; $_mailmerge_manager merge; } public method sections_per_pdf_file {} { ::return [$_mailmerge_manager sections_per_pdf_file]; } public method done {} { ::switch -- $destination { "display" { print_show; } "preview" { print_preview; } "printer" { print; file_close; } "file" { ::if {[::string first %_ $newfilename]<0 \ &&[::string first ".pdf" [::sargs::get [::qw::file::info "$newfilename"] .extension]]<0 \ } { file_save; } file_close; } "email" { file_close; } } chain; } public method abort {} { chain; ::return $this; } public method filename_Set {Src} { $_mailmerge_manager filename_Set $Src; ::return $this; } public method printer_Set {Src} { ::return $this; } public method printer_Get {} { ::return [$_mailmerge_manager printer_Get]; } public method can_print {} { ::return [$_mailmerge_manager can_print]; } public method print {} { $_mailmerge_manager print; ::return $this; } public method print_show {} { $_mailmerge_manager visible_Set 1; ::return $this; } public method print_preview {} { $_mailmerge_manager print_preview; ::return $this; } public method file_save {} { $_mailmerge_manager file_save; } public method file_close {} { $_mailmerge_manager file_close; } public method main_document_contents {} { ::return [$_mailmerge_manager main_document_contents]; } public method main_document_merge_fields {} { ::return [$_mailmerge_manager main_document_merge_fields]; } public method create_pdf_file {s_args} { ::set Result [$_mailmerge_manager create_pdf_file $s_args]; ::return $Result; } } ::itcl::class ::qw::print::windows::mailmerge::manager { private variable _owner ""; private variable _callback_command ""; private variable _visible 0; public variable mainfilename "" {configure_mainfilename $mainfilename;} public variable datafilename "" {configure_datafilename $datafilename;} public variable newfilename "" {configure_newfilename $newfilename;} public variable destination "display" {configure_destination $destination;} public variable printer "" {configure_printer $printer;} private variable _word ""; private variable _printer ""; private variable _main_document ""; private variable _new_document ""; private variable _mailmerge ""; private variable _abort 0; private variable _ready 0; protected variable _is_destroying 0; protected method configure_destination {Src} { ::switch -- $Src { "email" { } "file" - "display" - "printer" {} default {::qw::throw "Invalid destination \"$Src\". -destination must be one of \"display\", \"email\", \"file\", \"preview\", or \"printer\".";} } } protected method configure_mainfilename {Src} { ::if {$Src ne ""} { ::if {![::file exists $Src]} { ::qw::throw [::sargs \ .text "Main Document file \"$Src\" does not exist." \ .help_id 271820050404145920 \ ]; } } } protected method configure_datafilename {Src} { ::if {$Src ne ""} { ::if {![::file exists $Src]} { ::qw::throw [::sargs \ .text "Data file \"$Src\" does not exist." \ .help_id 271820050404145921 \ ]; } } } protected method configure_newfilename {Src} { ::if {$Src ne ""} { ::if {[::file exists $Src]} { ::if {[::file isdirectory $Src]} { ::qw::throw "Cannot create new file \"$Src\", a directory by that name already exists."; } ::if {![::file writable $Src]} { ::qw::throw "Cannot overwrite existing file \"$Src\", permission denied."; } } } } protected method configure_printer {Src} { printer_Set $Src; } constructor {args} { ::set _is_destroying 0; ::set _ready 0; ::eval configure $args;#// (There aren't any configure options, but ...) printer_Set [$::nv2::print::printers default_Get]; } destructor { ::if {[is_being_destroyed]} {::qw::throw "$this destructor called but object is already being destroyed.";} ::set _is_destroying 1; } public method is_being_destroyed {} { ::return $_is_destroying; } public method visible_Set {Src} { ::if {$_word ne ""} {$_word visible_Set $Src;} ::set _visible $Src; ::return $this; } public method visible_Get {} { ::return $_visible; } public method owner_Set {Src} { ::if {$_owner ne ""&& $Src ne $_owner} { ::qw::throw "You can not change the owner once it has been set."; } ::set _owner $Src; ::return $this; } public method owner_Get {} { ::return $_owner; } public method callback_command {args} { ::if {![::llength $args]} {::return $_callback_command;} ::set _callback_command $args; ::return $this; } public method print_preview {} { ::if {!$_ready} { ::qw::throw "??????????????????"; } $_new_document print_preview; ::return $this; } public method printer_Set {Src} { ::set _printer $Src; ::return $this; } public method printer_Get {} { ::set PrinterName [$_word active_printer_Get]; ::return [$::nv2::print::printers item_from_excel_name $PrinterName]; } public method print {} { ::if {!$_ready} { ::qw::throw "??????????????????"; } ::if {$_printer ne ""} { $_word active_printer_Set [$_printer excelname]; } $_new_document print; ::return $this; } public method file_save {} { $_new_document name_Set [::file nativename $newfilename]; $_new_document file_save; } public method file_close {} { ::if {$_new_document ne ""} { $_new_document mark_file_saved; $_new_document close; } ::if {$_main_document ne ""} { $_main_document activate; ;#// no effect, either way? $_main_document close; } } public method init {} { ::if {$_ready} { ::return; } ::if {$mainfilename eq ""} {::qw::throw "-mainfilename not configured.";} ::if {[owner_Get] eq ""} {::qw::throw "The owner has not been set.";} ::if {[callback_command] eq ""} {::qw::throw "The callback_command has not been set.";} qw::try { ::set Handle [::open $mainfilename]; } catch Exception { ::qw::throw "Error attempting to open main file $mainfilename" $Exception; } ::close $Handle; qw::try { ::set Handle [::open $datafilename a+]; } catch Exception { ::qw::throw "Error attempting to open data file $datafilename" $Exception; } ::close $Handle; ::qw::try { ::set _word [[::qw::get_com_applications] factory -application "Word" -filename $mainfilename -destination $destination]; $_word visible_Set 0; ::set _main_document [$_word cget -filename_handle]; ::set _mailmerge [$_main_document mailmerge]; ::switch -- $destination { "file" - "display" {$_mailmerge configure -destination "document";} "printer" {$_mailmerge configure -destination "printer";} "email" {$_mailmerge configure -destination "email";} } $_mailmerge configure -datasource $datafilename; $_word active_printer_Set [$_printer excelname]; ::set _ready 1; } catch Exception { ::if {$_word ne ""} { [::qw::get_com_applications] destroy $_word; ::set _word ""; ::set _main_document ""; ::set _mailmerge ""; } ::qw::throw $Exception; } } public method sections_per_pdf_file {} { ::return [[$_main_document handle_property Sections] Count]; } public method merge {} { init; ::set _new_document [$_mailmerge merge]; ::switch -- $destination { "display" { visible_Set 1; } "email" { } "file" { } "printer" { } default {::qw::throw "Invalid -destination \"$Src\". -destination must be one of \"file\", \"display\", \"printer\", or \"email\".";} } ::return $this; } public method abort {} { ::set _abort 1; ::return $this; } public method can_print {} { ::if {[$_word active_printer_Get] eq ""} {::return 0;} ::return 1; } public method main_document_contents {} { init; ::return [$_main_document contents]; } public method main_document_merge_fields {} { init; ::return [$_main_document merge_fields]; } public method create_pdf_file {s_args} { ::set Result [$_new_document create_pdf_file $s_args]; ::return $Result; } } ::itcl::class ::qw::print::managers { inherit ::qw::print::collection; constructor {args} { ::eval ::qw::print::collection::constructor $args; } { ::eval configure $args; } destructor { } public method init {} { chain; ::return $this; } public method factory {args} { ::array set Args $args; ::set Platform [::string tolower $::tcl_platform(platform)]; ::switch -- $Platform { "windows" { } default {::qw::throw "NewViews cannot print on this operating system.";} } ::if {![::info exists Args(-method)]} { ::qw::throw "-method not specified."; } ::set Method [::string tolower $Args(-method)]; ::unset Args(-method); ::if {![::info exists Args(-type)]} { ::qw::throw "-type not specified."; } ::set Type [::string tolower $Args(-type)]; ::unset Args(-type); ::switch -- $Method { "template" { ::switch -- $Type { "test" - "check" - "check::ap" - "check::pay" - "payroll_report" - "statement" - "invoice" {} "donor_receipt" {} "donor_statement" {} "roe" {} "t4" {} "t4_summary" {} "t4a" {} "t4a_summary" {} "releve1" {} "w2" {} "1099" {} "t5018" {} "t5018_summary" {} "t5" {} "t5_summary" {} "nvnph_rent_receipt" {} "receipt" {} default { ::set Text "Unknown template -type \"$Type\""; ::qw::throw $Text; } } } "table" { ::switch -- $Type { "plain" - "account" - "freeform" - "transactions" - "postings" {} default { ::qw::throw "Unknown table -type \"$Type\", -type must be one of \"plain\", \"account\", \"freeform\", or \"postings\"."; } } } "text" { ::switch -- $Type { "document" - "mailmerge" {} default { ::qw::throw "Unknown text -type \"$Type\", -type must be one of \"document\" or \"mailmerge\"."; } } } default {::qw::throw "Unknown -method \"$Method\". -method must be \"text\", \"template\" or \"table\".";} } ::set Class "::qw::print::${Platform}::${Method}::${Type}"; ::return [::eval chain -kid_class $Class [::array get Args]]; } } ::namespace eval ::nv2 {}; ::namespace eval ::nv2::print {}; ::namespace eval ::nv2::print::managers {}; ::set ::nv2::print::managers [::qw::print::managers ::qw::print::managers::#auto]; ::set ::nv2::print::printers [::qw::printers ::qw::printers::#auto]; ::proc ::qw::get_print_managers {} { ::return $::nv2::print::managers; } ::proc ::qw::get_printers {} { ::return $::nv2::print::printers; } $::nv2::print::printers init;