Container Royalty System High Level Design Container Royalty System for Container Royalty Central Collection Fund / ILA Rev. 1.7 28 May 2014 Revision History Rev. # 1.0 1.1 Rev. Date Rev. By Description th Chris Boothroyd Initial draft. th 25 February 2014 28 February 2014 Chris Boothroyd Issued for internal review. th Chris Boothroyd Revised following internal review. th Chris Boothroyd Minor typo. Corrected. Chris Boothroyd Updated to reflect clarification of funding rules (vessel based) and moratorium limits. th Chris Boothroyd Updated following team review. th Chris Boothroyd Updated stored procedure definitions to reflect practicalities of working with ODP.NET. nd 1.2 4 March 2014 1.2.1 4 March 2014 th 1.3 29 March 2014 1.4 17 April 2014 1.5 25 April 2014 1.6 2 May 2014 Chris Boothroyd Tweaked user information table/object and corrected an error in the FundRateRules table. 1.6 28 May 2014 Chris Boothroyd Corrected Entity Model diagrams. High Level Design 1.7 1 of 61 Container Royalty System Table of Contents Container Royalty System ............................................................................................................................................................ 1 Container Royalty Central Collection Fund / ILA .......................................................................................................................... 1 Revision History ........................................................................................................................................................................... 1 Table of Contents ......................................................................................................................................................................... 2 1 2 Introduction and Purpose .....................................................................................................................................3 1.1 Purpose of Document .................................................................................................................................................... 3 1.2 Intended Audience ........................................................................................................................................................ 3 1.3 Background.................................................................................................................................................................... 3 1.4 NOTE.............................................................................................................................................................................. 3 Naming Conventions .............................................................................................................................................4 2.1 Database Entities ........................................................................................................................................................... 4 2.2 Classes and Objects ....................................................................................................................................................... 4 2.3 UI Objects ...................................................................................................................................................................... 5 2.4 Visual Studio Solution Structure .................................................................................................................................... 6 3 Security Model ......................................................................................................................................................7 4 Web Pages ............................................................................................................................................................8 5 6 4.1 Site Pages ...................................................................................................................................................................... 8 4.2 Master Pages ............................................................................................................................................................... 10 4.3 Page Types ................................................................................................................................................................... 11 4.4 Page Descriptions ........................................................................................................................................................ 14 4.5 Flow of Control ............................................................................................................................................................ 19 Data Entity Model ...............................................................................................................................................22 5.1 Entity Model Diagrams ................................................................................................................................................ 22 5.2 Common Table Columns ............................................................................................................................................. 27 5.3 Column Types .............................................................................................................................................................. 27 5.4 Triggers ........................................................................................................................................................................ 27 5.5 Relationships and Foreign Keys ................................................................................................................................... 27 5.6 Views ........................................................................................................................................................................... 28 5.7 Functions ..................................................................................................................................................................... 35 5.8 Stored Procedures ....................................................................................................................................................... 36 5.9 Lookups ....................................................................................................................................................................... 44 Object Model ......................................................................................................................................................46 6.1 NOTES .......................................................................................................................................................................... 46 6.2 Object Model Diagrams ............................................................................................................................................... 47 High Level Design 1.7 2 of 61 Container Royalty System 6.3 7 Class Details ................................................................................................................................................................. 53 Integration with QuickBooks Enterprise .............................................................................................................57 7.1 IBiz Integrator for QuickBooks ..................................................................................................................................... 57 7.2 Populating QuickBooks Bills ........................................................................................................................................ 58 7.3 Populating QuickBooks Invoices .................................................................................................................................. 60 8 Topics Not Yet Explored ......................................................................................................................................61 1 Introduction and Purpose 1.1 Purpose of Document This document is intended to communicate the design concepts, standards and approaches to be applied in development of the CRCCF royalty management application. 1.2 Intended Audience The document is intended to be read by engineers, programmers and project management from the ILA, CRCCF and Catalyst Design Group. 1.3 Background The ILA and USMX agreed to create the CRCCF to manage and operate the central collection and disbursement function for container royalty fees paid by transoceanic carriers. Carriers are required to pay royalty fees to the ILA in accordance with the Master Agreement. The basis for royalty fees, for the purposes of this document, is the total freight tonnage loaded and offloaded in the ILA serviced ports in the eastern and southern US. Shippers are required to pay a royalty fee to the ILA for providing the labor to load and unload their ships in various US ports of call. These fees are currently assessed for 5 different funds, all of which must be calculated individually based on the total cargo tonnage as reported by the shippers (manifest data). 1.4 NOTE This document is intended as a guide to development. The approaches and concepts outlined here are intended to provide structure and direction for developers. Despite the best efforts of the author and reviewers some inconsistencies and omissions may be present in released version(s). Additionally, while suggestions and examples are made for implementation approaches, developers should apply their domain expertise to determine the actual implementation approach (bearing in mind ease of implementation, ease of maintenance, performance, robustness, etc). High Level Design 1.7 3 of 61 Container Royalty System 2 Naming Conventions 2.1 Database Entities All tables shall have meaningful names – as dictated by the entity model. For example: o ADDRESSES o PORTS o VESSELS All views and stored procedures shall have names that represent the function of the view and/or stored procedure (typically the primary table name shall feature in the view name). For example: o vwAddresses o vwApplicableFundingRates o spSyncPorts o spSearchVoyages All views shall be prefixed vw All stored procedures shall be prefixed sp All stored procedure parameters shall be prefixed with p All local variables shall be prefixed with l 2.2 Classes and Objects All classes and their objects will have meaningful names – as dictated by the object model. E.g. o Carrier o Container Local variables (or private properties) shall begin with a lower case letter Global variables (or Public properties) shall begin with an upper case letter Where a class, variable or method name, includes several words, then the first letter of each word shall be capitalized (the exception being the first letter of the name – for local variables). E.g. o ExternalUnitCode o currentFundingLevel Data Layer classes shall have names that are the plural of their AppLogic layer equivalents. E.g. o Carrier (AppLogic) and Carriers (DataLayer) o Container (AppLogic) and Containers (DataLayer) o Etc. Object instances shall reflect the name of the class that they instantiate. E.g. o carrier o container High Level Design 1.7 4 of 61 Container Royalty System Protected properties shall being with an upper case letter Variable names shall be singular (e.g. container) while arrays, list of other collections of objects shall be plural (e.g. containers). Method names shall be meaningful and reflect the purpose of the method. 2.3 o ConvertWeightUnits() o GetPageData() o Etc. All method names shall start with an upper case letter, regardless of the method scope. UI Objects Labels will be prefixed with lbl (e.g. lblWeight) Textboxes will be prefixed with edit (e.g. editWeight) Checkboxes will be prefixed with chk (e.g. chkActive) Dropdown lists will be prefixed with pick (e.g. pickPort) Grids will be prefixed with (e.g. gridVoyageActivities) User defined controls will take the name of the control (e.g. AddressCtl) unless more than one such control is present on the current page – in which case a descriptive name shall be give to each instance (e.g. ActivityDate and VoyageDate). High Level Design 1.7 5 of 61 Container Royalty System 2.4 Visual Studio Solution Structure 2.4.1 Projects The solution as a whole will include four discrete projects (which can be independently built and deployed): CRCCF-Common – A DLL project, containing the application logic and data access layer CRCCF-Web – a web application project containing the bulk of the web application Utilities – the shared utility class (existing assets) CRCCF-Services – a WCF project containing the web services 1 2.4.2 CRCCF-Common Project Structure The CRCCF-Common project will include the following folders: AppLogic – a set of C# class files that form the application logic layer DataLayer – a set of C# class files that make up the data access layer 2.4.3 CRCCF-Web Project Structure The CRCCF-Common project will include the following folders: Masters – holds the master pages for this project UI – holds the user controls for this project Styles – holds the cascading style sheets for this project Scripts – holds the javascript files for this project Images – holds the image files for this project Users – holds the login, user registration and account management pages. Ports – holds the pages for port specific users Admin – holds the pages for use by administrators only CRCCF – holds the pages for use by CRCCF users Carriers – holds the pages for use by carrier specific users EmailTemplates – holds the html files used to define email templates 2.4.4 CRCCF-Services Project Structure Each service will be created in its own, unique, folder. 1 WCF = Windows Communication Foundation – a Microsoft framework for managing services. WCF services can be consumed as traditional web services but other communications protocols are also supported. High Level Design 1.7 6 of 61 Container Royalty System 3 Security Model User accounts will be created and managed using the ASP.NET membership model, with access to pages being controlled through declarations in the web.config for the web site. In addition, the minimum required role for accessing each page will be checked by the Master Page (see below) for that page. The following roles will be created: System Admin – Has full read-write access to all pages and functions CRCCF Admin – Has read-write access to all pages (excluding all master pages but user management) CRCCF Operator – Had read-write access to core pages (but cannot add/remove users) CRCCF Read Only – Can view all reports Port Admin – Has read-write access to all port specific pages Port Operator – Has read-write access to all port specific pages (excluding port admin pages) Port Read Only – Can view port-specific reports Carrier Admin – Has read-write access to all carrier specific pages Carrier Operator – Has read-write access to all carrier specific pages (excluding carrier admin pages) Carrier Read Only – Can view carrier-specific reports NOTES: 1. CRCCF roles will have visibility to data for all ports and all carriers 2. Port roles will have visibility to data related to their port only 3. Carrier roles will have visibility to data related to their carrier only. High Level Design 1.7 7 of 61 Container Royalty System 4 4.1 Web Pages Site Pages Login Users Login page automatically redirects the user to the most appropriate page for them to begin activities. Register E.g. Port Home, CRCCF Home Password Management Admin View ESB Activity Manage User Accounts A common navigation menu will enable authorized users to navigate to any of the different pages within the site – but only pages available to the user will be visible Approve New User ExternalNames Master Data Application Settings Admin Home Lookups Carriers Ports Weight Conversions Port Home Funding Rules Scheduled Activities ILA/Ports Vessels Due Vessel Verification Container Verification Station Receivables by Carrier by Fund Month To Date Tonnage by Station Report Viewer ILA/Port Reports High Level Design Tonnage by Station Trend 1.7 8 of 61 Container Royalty System View Billing Errors CRCCF Home CRCCF Year To Date/Month To Date Tonnage by Fund CRCCF Reports Tonnage by Fund Tonnage by Container Carriers Home View Files Uploaded Carriers View Invoices Carrier Adjustments Carrier Reports Year To Date/Month To Date Tonnage by Carrier Year To Date/Month To Date Royalties by Carrier Carrier Aging Report All pages within a page group can be accessed by accounts who have the appropriate user role. CRCCF users will be able to view all reports. Administrative users will be able to access all pages. High Level Design 1.7 9 of 61 Container Royalty System 4.2 Master Pages 4.2.1 Purpose of Master Pages A ASP.NET aster page pro ides a o o e ha is for applyi g a ski to a e page – so that all web pages using that Master page will have the same styles (such as fonts, colors and images), layout, menus, etc. In addition, master pages can provide common behaviours. For example: initializing database connections and/or enforcing role-based security. A web page referencing a master page will inherit the visual and behavioural aspects of that master page. 4.2.2 CRCCF Master Pages The following master pages will be created for the CRCCF Fund Management Application: Master Page Name Description Root.Master Abstract page – contains common code that is inherited by the other master pages (e.g. Is someone logged in? fetch the current user, etc.) User.Master Master page for the pages that manage, or access, user accounts, such as the login page, the register for an account page, etc. NOTE: These pages do NOT require the user to be authenticated. Admin.Master Verifies that the user has the Admin user role CRCCF.Master Verifies that the user has the CRCCF user (or Admin) user role. Port.Master Verifies that the user has the ILA/Port user (or Admin) user role. Carrier.Master Verifies that the user has the Carrier user (or Admin) user role. NOTE: When using the ASP.NET authentication model, it is not strictly necessary for the user role to be verified by a master page – the authentication requirements can (and will) be laid out in the web configuration file (and are then enforced by the .NET Framework itself). However, this approach provides an additional level of security for minimal additional effort. High Level Design 1.7 10 of 61 Container Royalty System 4.3 Page Types Web pages in business applications tend to fall into common patterns and layouts – based upon the required behaviour of that page. This helps users to become familiar with the way in which they interact with the site – as well as reducing the complexity for implementation and maintenance of the application as a whole. NOTE: The figures below are intended to communicate the concepts of the various page types – not the specifics of the page layout or styling. 4.3.1 Edit Form Type A common need is to allow the user to edit the details of a particular record – such as a voyage activity. These pages consist of a table of fields and controls, combined with action buttons at the bottom of the form. For example: High Level Design 1.7 11 of 61 Container Royalty System 4.3.2 Search Criteria / Grid Results Type Another common need is to allow the user to search for a set of information and then allow them to act on the results. The potential actions are also similar from page-to-page (edit/delete or add to results) – although context specific actions might also be required (such as view a report or PDF file). Depending upon the complexity of the item to be edited, the Edit button may invoke in line editing (see below), or may open an additional browser window with an edit form. High Level Design 1.7 12 of 61 Container Royalty System 4.3.3 Dashboard Type Home pages and management information pages will often be made up of several parts consisting of charts; summary tables and general information (text, photographs, etc.). High Level Design 1.7 13 of 61 Container Royalty System 4.4 Page Descriptions The follow pages will be created for the CRCCF Fund Management Application. Where appropriate, the master page and page type are identified. Folder Page Name Description Users Register.aspx Allows a potential user to sign-up for an application user account. The user will be asked to enter: Master Page: User.Master Page Type: Form Their first and last name Their email address Password (entered twice for confirmation) User name Requested role (Port, Carrier or CRCCF ) Port or Carrier (Port/Carrier users only) Security question (e.g. Name of first pet) Answer to security question (e.g. Sam). 2 After submitting the request, the user account will be created – but in an inactive state. The prospective user will be sent an email informing them that their request for an account has been received and is pending approval. The information that they entered will be included in the email (apart from the password). An email will also be sent to one (or more) administrators – who will then be able to click on a link (login) and approve/deny the request. Once approved the new user will be sent an email confirming that their account has been created and inviting them to login to the application. This page ill also i lude a CAPTCHA o trol to help prevent automated cyber attacks. Users Login.aspx Master Page: User.Master Page Type: Form Users PasswordManagement.aspx Master Page: User.Master Allows an authorized user to login to the application with a user name and password. Verifies that the user name and password are valid (and active). Authenticated users are then redirected to one of several home pages – ased upo the user s pri ary role. Allows an authorized user to change their existing password and/or have the system automatically generate a new password for them. The user is informed of the new password via email. Page Type: Form 2 Only Admin users will be able to create new Admin users – via the Manage User Accounts page. High Level Design 1.7 14 of 61 Container Royalty System Folder Ports 3 Page Name Description PortHome.aspx Provides authorized users a summary of: Chart of forecast and actual tonnages for the current fiscal year. Table of forecast and actual tonnages for the current fiscal year. List of Trustees Address of the port/fund Support contacts Link to procedures Master Page: Ports.Master Page Type: Dashboard Ports VesselsDue.aspx Master Page: Ports.Master Page Type: Search/Grid Shows the user a list of vessels that are due at the port in the date range provided. The date range will default to the current week but the user will be able to override those defaults. The grid will show the scheduled arrival date and pier, as well as the total number of containers to be loaded / unloaded and the total tonnage. The grid actions include: Vessel Verification – opens the vessel verification page New Vessel – allows the user to enter summary information for a vessel that was not identified as being due. (Uses the Vessel Verification page with blank entries for actual data). See Activities – opens the View Scheduled Activities page with the filter conditions pre-set to show just the activities for the selected vessel/voyage. NOTE: The grid should always show all unconfirmed activities – no matter what date range is shown. Ports VesselsVerification.aspx Master Page: Ports.Master Page Type: Simple Form Displays su ary i for atio a out the s heduled essel s arrival and allows the following information to be entered: Actual Arrival Date Total # of Containers Loaded/Unloaded Total # of Tonnage of Containers Loaded/Unloaded 3 All port pages will show port-specific-users data for their port only. Users with Admin and CRCCF roles will be presented with a drop down list of ports allowing them to select the port that they wish to view. High Level Design 1.7 15 of 61 Container Royalty System Folder Page Name Description Ports ViewScheduledActivities.aspx Shows the user a list of activities scheduled for the user s port, for the given search criteria which include: Master Page: Ports.Master Page Type: Search/Grid Date range Activity type Carrier Voyage Vessel The grid actions include: External Bill – indicates that the container was either stripped, or stuffed. Edit – allows the weight loaded/unloaded to be adjusted. Delete – allows the status of the activity to be set to DELETED, which will hide it from most pages and reports. New – add a new voyage activity. NOTE: Requests to mark a payment as externally billed, or to delete a payment will both require confirmation before being acted upon. Ports ContainerVerification.aspx Master Page: Ports.Master Page Type: Search/Grid / ReportViewer.aspx Master Page: Root.Master CRCCF Home.aspx Master Page: CRCCF.Master Allows authorized port employees to review voyage activities, mark them as complete and confirm that the weight unloaded matches the weight reported by the carrier. NOTES: This page will be styled specifically for rendering on a tablet PC, with the objective of supporting a remote worker at the dockside who is comparing the planned activities with the physical containers being loaded or unloaded. Allows authorized users to view a given report. The report URL is passed in as a URL parameter. Provides the user a summary of CRCCF activities, payments and funding levels – similar to the Port Home page but portindependant. Page Type: Dashboard CRCCF ViewBillingErrors.aspx Provides authorized users with a list of billing errors. Master Page: CRCCF.Master Page Type: Search/Grid Admin Home.aspx Master Page: Admin.Master Admin ViewESBActivity.aspx Master Page: Admin.Master Provides a series of links to pages for administration of the system, maintenance of master data, etc. Provides authorized users a summary of the status of information transfers to/from the Accounting System, files uploaded, etc. Page Type: Search/Grid High Level Design 1.7 16 of 61 Container Royalty System Folder Page Name Description Admin ManageUserAccounts.aspx Allows authorized users to add/update user accounts including: Master Page: Admin.Master Name Page Type: Search/Grid User Role(s) Port or Carrier (as applicable) Email address Password Status (active/ inactive) Security Question and Answer Admin ApproveNewUser.aspx Master Page: Admin.Master Page Type: Search/Grid Admin ExternalNames.aspx Master Page: Admin.Master Allows authorized users to approve/deny a request for a new user account. The details entered by the prospective user (name, user name, email address, requested role, port/carrier, etc.) are displayed for information. Allows authorized users to add/modify the external names that carriers have for (for examples) vessels and map those to a standard internal name. Page Type: Search/Grid Admin ApplicationSettings.aspx Allows authorized users to modify system variables – such as: Master Page: Admin.Master The SMTP server used to send emails Page Type: Search/Grid The default e ail fro The active directory domain name The email address to which system exception notifications should be sent Etc. address The page will display a table of settings and their values with an Edit button next to each value. High Level Design 1.7 17 of 61 Container Royalty System Folder Page Name Description Admin Lookups.aspx Allows authorized users to add/modify system dropdown list entries, such as: Master Page: Admin.Master Page Type: Search/Grid Voyage Status Codes Transfer Status Codes Countries Etc. The page will initially display a dropdown for selection of the lookup type (Countries, Voyage Status Codes, etc). Upon selection of a lookup type, table of lookup entries with their values and sort orders will be presented with Edit and Delete buttons next to each value. A New button will be displayed at the top of the table. NOTE: Deletion will require confirmation – and only lookup values for which no reference exists will be deleted. Admin Carriers.aspx Master Page: Admin.Master Allows authorized users to add/modify the list of carriers and their associated information. Page Type: Search/Grid Admin Ports.aspx Master Page: Admin.Master Allows authorized users to add/modify the list of ports and their associated information. Page Type: Search/Grid Admin WeightConversions.aspx Master Page: Admin.Master Allows authorized users to add/modify the list of weight units and the factors required to convert weights into long tons. Page Type: Search/Grid Admin FundingRules.aspx Allows authorized users to add/modify the list of funding rules. Master Page: Admin.Master Includes a sub-form for adding/modifying entries in the PortCarrierFundRateRules table. Page Type: Search/Grid Carriers 4 Home.aspx Master Page: Carriers.Master Provides authorized users a summary of voyages, activities and invoices for the carrier – similar to the Port Home page but carrier-specific. Page Type: Dashboard Carriers ViewFilesUploaded.aspx Master Page: Carriers.Master Provides authorized users a summary of files uploaded; their upload status and the number of voyage activities created as a result of the upload. Page Type: Search/Grid 4 All carrier pages will show carrier-specific-users data for their carrier only. Users with Admin and CRCCF roles will be presented with a drop down list of carriers allowing them to select the port that they wish to view. High Level Design 1.7 18 of 61 Container Royalty System Folder Page Name Description Carriers ViewInvoices.aspx Provides authorized users a set of search criteria with which to find invoices and a table of invoices that match the criteria. Master Page: Carriers.Master Page Type: Search/Grid Users will be able to view invoices online as well as print them. 4.5 Flow of Control 4.5.1 File Import, Validation and Error Correction Upload to FTP No later than 48 hours before the first scheduled arrival or departure Voyage Activity File File Upload Process CargoFiles Manual Error Correction Periodically (e.g. once a minute) Timer Import Summary CargoFiles Voyages Carriers Vessels Ports Containers Import Voyage End VoyageActivities Containers UloadedFiles UploadedItems High Level Design 1.7 19 of 61 Container Royalty System 4.5.2 Accounting System Integration Timer Voyages Carriers Vessels Ports Containers VoyageActivities Invoices FundPaymentsDue Generate Voyage Charges and Invoice Entries Voyage is complete 7 days and 24 hours after final scheduled departure date- or earlier, if status is changed to completed Check for Completed Voyages Timer Create Invoice Header QuickBooks Payments Received Checks Paid Check for Payments Made Set Voyage Status to Billed QuickBooks Bills Invoices Payments Export to Accounting System Weight Ajustments Timer Generate Supplementary Charges and Invoice Entries Create Supplementary Invoice Header Export to Accounting System QuickBooks Bills Invoices Credit Memos Invoices FundPaymentsDue High Level Design 1.7 20 of 61 Container Royalty System 4.5.3 User Interaction Login to Web Site CRCCF/ADMIN CARRIER PORT Import Error Correction View Port Activities View Voyages View Voyages Port Reconciliation Activity Adjustments Activity Adjustments Activity Adjustments View Invoices View Invoices View Fund Payments Reports View Port Activities Reports Etc. Port Reconciliation Etc. Activity Adjustments View Fund Payments Reports Update System Data and Rules Etc. Logoff High Level Design 1.7 21 of 61 Container Royalty System 5 Data Entity Model 5.1 Entity Model Diagrams CargoFiles PK Unique voyage identified by (fixed) Voyage Date, Carrier Code, VesselName and Voyage Number ID Voyages PK ID FileName CarrierID NominalVoyageDate DateOfUpload Moritoriums Carriers Invoices PK ID VoyageDate CarrierCode VoyageNumber CarrierName VesselID BillingAddressID VoyageStatusID * CarrierCode VesselName IMO_VesselNo CarrierStatusID * Vessels VoyageNumber AccountingName PortCode PK ID USMX_MemberID * ActivityDate IMO_VesselNo VesselName Ports WeightUnits PK ContainerType AutomationLevelID* ID PortCode ContainerIDPrefix VoyageActivities PortName PK ContainerNumber VoyageActivityDetails Weight ID AccountingName VoyageID ContainerActivityCode PierID FIRMS_Code Piers ActivityDate VoyageID PK ID ActivityTypeID * PortID Could be used to store a history of all files uploaded, or just the most recent upload per voyage. ConfirmedActivityDate FIRMS_Code ConfirmedContainerCount Description Voyage ID is added after import process has completed – for cross reference only. ConfirmedTonnage ConfirmedBy ConfirmedDate Addresses Required columns in bold. High Level Design * Denotes that the attribute holds a Lookup ID – see below 1.7 22 of 61 Container Royalty System Charges VoyageActivityDetails PK VoyageActivites ID VoyageActivityID ContainerID WeightID ContainerConfirmed Containers ConfirmedWeightID PK ConfirmedBy ID ContainerType ConfirmedDate ContainerIDPrefix ActivityStatusDetailID * ContainerNumber IncludeInBilling IncludeInBilling is true unless the container is stripped /stuffed (CFS containers) WeightAdjustments PK ID VoyageActivityDetailID Weights CorrectiveActionID * PK ID OldWeightID UnitConversionRates Weight NewWeightID PK UnitID ID Notes Unit CorrectiveActionID tells us whether the container information was added/ removed or modified. Description ConversionRate Because we need to be able to track deletions, deleting an activity detail should not actually delete it. Rather it should set the status to deleted – enabling the audit trail to be maintained. Adjusted By and Adjustment Date would be held in the standard CREATED_BY/ CREATED_DATE columns. High Level Design 1.7 23 of 61 Container Royalty System Invoices PK ID ID VoyageID PK ID FundID FundCode AutomationLevelID Description CarrierID AccountingName PortID FundTypeID * RateID InvoiceNumber InvoiceDate DueDate TransferStatusID * AccountingRequestID Fund type tells us whether payments are port specific, ILA global, or USMX. FundRates PK AccountTransactionID ID Payments Rate PK ID ApplicableFromDate PaymentTypeID * ApplicableToDate Moritoriums PK ReferenceID VoyageActivityDetails ID BankReference FundID AmountPaid Charges CarrierID PK PaymentDate ID MoritoriumStartDate VoyageActivityDetailID FundPaymentsDue MoritoriumEndDate PaymentTypeID tells us whether this is a payment received for an invoice (in which case ReferenceID will be an invoice ID) or a fund payment made (in which case ReferenceID will be a payment due ID) PK Funds Voyages FundRateRules FundRateID PK Credit ID Charge TransactionDate Carriers Allocated DueDate FundRateID captured so we can tell which rule and rate was applied – e.g. to add the rate to the invoice line items. Since fund payments due (which will eventually become QuickBooks Bills) will be generated on a calendar based schedule, we need to have a way to tie them back to the individual charges. High Level Design ChargesDue PortID FundID TransferStatusID * FundPaymentsDueID AccountingRequestID ChargeID AccountingTransactionID 1.7 24 of 61 Container Royalty System Addresses Carriers PK ID Address1 States Address2 PK ID City CountryID StateOrProvinceID StateOrProvince CountyStateOrProvince StateOrProvinceName Postcode Contacts PK CountryID * ID FirstName LastName JobTitle DateOfBirth C UserInfo Much of this contact information is required to identify a new user for approval. However, it is really generic contact information so stored separately from the user details. When the system generates email notifications (e.g. to confirm a password reset) the body and subject of the email will be defined by this table (and associated HTML files). EmailTemplates PhoneNumber PK ID Extension TemplateName MobilePhone FileName StoredProcedure Holds system configuration parameters, such as who to send exception emails to; address of email server; etc. AppConfig PK Subject Lookups PK CrccfInfo will have a single record and will be used to populate reports (such as invoices) with CRCCF related information ID CrccfInfo ID LookupType AppName LookupName ParameterName LookupValue AddressID ParameterValue SortOrder Telephone High Level Design PK 1.7 ID 25 of 61 Container Royalty System Port a d arrier user s ill e associated with either a specific port, or with a specific carrier, respectively. UserInfo PK ID UserId NOTE: It may be preferable to have a single column (e.g. OwnerID) CarrierID PortID ContactID HiringManagerContactID Contacts Approved_By Approval_Date Approval_Notes ASP.NET User Management Tables High Level Design 1.7 26 of 61 Container Royalty System 5.2 Common Table Columns 5 Although not explicitly shown in the Entity Model Diagram(s), all tables will have the following columns: Created_By - The name of the user who created this entity Created_Date - The date that the entity was created (set by trigger) Modified_By - The name of the user who last modified this entity Modified_Date - The date when the entity was last modified 5.3 Column Types A full data dictionary is not provided in the entity model at this time. However, the following is provided as a guideline. Column Name or Description Oracle Data Type Comment ID INTEGER Table specific sequence numbers, updated by trigger (see below) Dates DATE Weights NUMBER(18,2) Weight conversion units NUMBER(18,2) Currency values NUMBER(18,2) Strings of predictable length NCHAR(n) Very long strings LONG VARCHAR UserId CHAR(36) ASP.NET user id Logical/Boolean CHAR(1) constrained to Y/N 5.4 Where n is the maximum length Triggers 5.4.1 Common Triggers When? What? On INSERT Set CreatedByDate and ModifiedByDate to the current date and time. Fetch the next sequence number for the ID column (if appropriate). Set ModifiedByDate to the current date and time. On UPDATE 5.5 Relationships and Foreign Keys Foreign keys should be implemented on each table, reflecting the relationships identified in the entity model diagrams. 5 With the exception of the ChargeDue table, which exists to link the FundPaymentsDue with the Charges table. High Level Design 1.7 27 of 61 Container Royalty System 5.6 Views Name Description vwPorts These views will simply select all columns from their respective tables. vwMoratoriums Although the initial value of the views is limited (since they have little to offer over simply selecting directly from the table), they allow for future expansion of the views to include additional information, without also requiring modification of associated stored procedures. vwStates vwLookups vwAppConfig vwCrccfInfo vwEmailTemplates vwFunds vwFundRateRules vwPiers vwAddresses Presents a logical view of addresses (with countries and states). Joins the Addresses table with the States table (on StateOrProvinceID). Addresses: o Address1 o Address2 o City o StateOrProvinceID o StateOrProvince = vwCarriers If States.StateOrProvinceName is not NULL then States.StateOrProvinceName otherwise CountyStateOrProvince. o Postalcode o CountryID o Country (text) Presents information from the Carriers table and vwAddresses (on BillingAddressID) Carriers: o All columns o CarrierStatus (text) 6 vwAddresses: o All columns 6 E.g. CarrierStatus (text) means the lookup name for the Lookup with an ID equal to CarrierStatusID; VoyageStatus (text) means the lookup name for the Lookup with an ID equal to VoyageStatusID; etc. These may be fetched using a JOIN or using the function fnGetLookupName(). High Level Design 1.7 28 of 61 Container Royalty System Name Description vwVessels Presents information from the Vessels table vwFundRateRulesByDate Vessels: o All columns o AutomationLevel (text) Presents information from about the rate that apply for given vessels, carriers and ports at a point in time. Joins the FundRateRules table with the FundRates table (on RateID) FundRateRules: o FundRates: o vwUserInfo All columns All columns Presents information about the current user, including the type of user, port/carrier that they represent, contact information and account verification information. Joins the UserInfo table with the Contacts table (on ContactID) and with the aspnet_Users and aspnet_Membership tables (on UserId) UserInfo: o Contacts: o vwContainers All Columns Aspnet_Users: o UserName o LastActivityDate aspnet_Membership o Email o IsApproved o IsLockedOut o CreatedDate o LastLoginDate Presents information from the Containers table along with a calculated column: High Level Design All columns Containers: o All Columns o ContainerCode = ContainerType+ - +ContainerIDPrefix+ +ContainerNumber+ - +ContainerActivityCode 1.7 29 of 61 Container Royalty System Name Description vwWeights Presents both raw and converted weights (in Long Tons) along with their units. Joins the Weights table with the UnitConversionRates table (on UnitID). Weights: o vwWeightAdjustments All columns UnitConversionRates: o All columns o StandardWeight = Weight * ConversionRate Presents information about adjustments made to vessel loading/unloading weights: Joins the WeightAdjustments table with vwWeights (on OldWeightID – outer join) and (again) with vwWeights (on NewWeightID – outer join). vwVoyages WeightAdjustments: o All columns o CorrectiveAction (text) vwWeights (on OldWeightID): o OldWeight = Weight o OldWeightUnitID = WeightUnitID o OldWeightUnit = WeightUnit o StandardOldWeight = StandardWeight vwWeights (on NewWeightID): o NewWeight = Weight o NewWeightUnitID = WeightUnitID o NewWeightUnit = WeightUnit o StandardNewWeight = StandardWeight Presents a logical view of the voyage showing carrier information. Joins the Voyages table (on VoyageID) with vwVessels (on VesselID) and vwCarriers (on CarrierID). Voyages: o All Columns o VoyageStatus (text) o VoyageCode = CarrierCode+ - + VesselNumber+ - +VoyageNumber+ +VoyageDate vwVessels: o vwCarriers: o High Level Design All columns All columns 1.7 30 of 61 Container Royalty System Name Description vwVoyageActivities Presents a logical view of the voyage activity, showing carrier, vessel, port and container information. Joins the VoyageActivities table with vwVoyages (on VoyageID), the Ports table (on PortID) and the Piers table (on PierID). VoyageActivities: o vwVoyages: o vwVoyageActivityByPort All columns All Columns Ports: o Port Code o PortName o PortAccountingName = AccountingName Piers: o FIRMS_Code o Description Presents a summary of the voyage activity details, including total weight and container count, by port. Joins vwVoyageActivities with the VoyageActivityDetails table (on VoyageActivityID) and vwWeights (on WeightID), grouping by Port ID. vwVoyageActivities: o High Level Design All columns VoyageActivityDetails: o ContainerCount = COUNT(ContainerID) o Tonnage = SUM(StandardWeight) 1.7 31 of 61 Container Royalty System Name Description vwVoyageActivityDetails Presents a logical view of the voyage activity, showing carrier, vessel, port and container information. Joins the ActivitiyDetailsTable table with vwVoyageActivities (on VoyageActivityID), the Containers table (on ContainerID) and vwWeights (on WeightID) and (again) with vwWeights (on ConfirmedWeightID – outer join). VoyageActivity: o vwVoyageActivities: o vwInvoiceHeader All columns All columns vwWeights (on WeightID): o Weight o WeightUnitID o WeightUnit o StandardWeight vwWeights (on ConfirmedWeightID): o ConfirmedWeight = Weight o ConfirmedWeightUnitID = WeightUnitID o ConfirmedWeightUnit = WeightUnit o StandardConfirmedWeight = StandardWeight Presents all the pertinent information for an invoice header to be viewed. Joins the Invoices table with vwVoyages (on VoyageID) Invoices: o vwVoyages: o High Level Design All columns All columns 1.7 32 of 61 Container Royalty System Name Description vwCharges Presents all the pertinent information for fund allocations/carrier changes to be viewed. Joins vwVoyageActivityDetails with the Charges table (on VoyageActivityID), the Funds table (on FundID) and FundRateRules table (on FundRateRuleID). NOTE: This view excludes voyage activities that have been marked as DELETED. vwVoyageActivityDetails: o Charges: o FundID o Charge Funds: o FundCode o FundAccountingName FundRateRules: o vwFundAllocationsByPort All columns Rate Presents all the pertinent information for fund allocations to be viewed by port and fund. Summarizes vwCharges, combining the charges for ports and fund by voyage – grouping by VoyageID, PortID and FundID. High Level Design vwCharges: o VoyageID o VoyageCode o PortID o PortCode o PortAccountingName o FundID o TotalCharge = The sum of Charge o FundCode o FundAccountingName 1.7 33 of 61 Container Royalty System Name Description vwUsers Presents information about the ASP.NET user accounts and any associated user information – primarily intended for personalizing emails. Joins the aspnet_Users table with the aspnet_Membership table (on UserId) and the UserInfo table (on UserId) and the Contacts table (on ContactID). aspnet_Users: o vwChargesDue UserId Aspnet_Membership: o Email o IsApproved o IsLockedOut UserInfo: o CarrierID o PortID ContactID: o Contacts o FirstName o LastName Present information about a single charge that will be (nominally) paid along with other charges linked to the same FundPaymentsDue entity. Joines the ChargesDue table with vwCharges (on Charge ID) ChargesDue: o vwCharges o vwFundPaymentsDueDetail All columns All columns Presents information about a collection of charges that will (nominally) be paid to their fund in a single transaction. Joins the FundPaymentsDue table with vwChargesDue (on FundPaymentDueID). FundPaymentsDue: o All columns o TransferStatus (text) vwChargesDue: o vwFundPaymentsDue All columns Presents a smmary of charges that will (nominally) be paid to their fund in a single transaction. Utilizes vwFundPaymentsDueDetails, grouped by FundPaymentID. High Level Design 1.7 34 of 61 Container Royalty System Name Description vwMoritoriumCredits vwFundPaymentsDue: o FundPaymentDueID o FundID o PortID o TransferStatusID o TransferStatus o AccountingRequestID o AccountingTransactionID o TotalCharge = SUM(Charge) Provides a summary of the total credit that has been applied to date for a given moratorium. Joins vwCharges with vwInvoices (on VoyageID) and the Moritoriums table (ON FundID and CarrierID), selecting all charges that were invoiced between the MoritoriumStartDate and MoritoriumEndDate, grouped by MoritoriumID. vwCharges: o 5.7 TotalToDate = SUM(Charge) Functions Name Description fnGetLookupName Returns the lookup name column matching the given lookup ID. Parameters: o Returns: o pLookupID LookupName Pseudo-code: Select the Lookups record with an ID equal to LookupID NOTE: This function is proposed for ease of development and maintenance. However, views which need to translate lookup IDs into names may be implemented using table joins for performance reasons. High Level Design 1.7 35 of 61 Container Royalty System 5.8 Stored Procedures 5.8.1 All Database Access via Stored Procedures All access to database tables by web applications, web services, reporting tools and/or the Enterprise Service Bus shall be via stored procedures. This helps to avoid SQL injection attacks as well as allowing enabling better control over table access. For example, a user can be granted access to a stored procedure but not to the table(s) that the stored procedure references. So that user can only perform operations on the tables that the stored procedure offers. 5.8.2 Common Stored Procedures 5.8.2.1 Entity Sync For each entity, there will be a single stored procedure that will enable an entity to be: Read (SELECT) Added (INSERT) Modified (UPDATE) Removed (DELETE). These procedures will be named spSync<entityName> (e.g. spSyncAddresses) The parameters will, of course, be specific to the entity. However, all sync procedures will have a minimum of three parameters: Name Description pID Unique identifier of this entity (null if the entity is to be inserted) pActionFlag Integer indicating one of the four actions (1 through 4) pCurrentUserName pActionFlag = 1 – SELECT pActionFlag = 2 (or pID IS NULL) – INSERT pActionFlag = 3 – UDPDATE pActionFlag = 4 – DELETE The name of the user who created, or modified, this entity NOTE: All stored procedure parameters should default to NULL – unless otherwise specified. 5.8.2.2 SELECT Action Will select all columns from the view named: vw<entityName> where the ID matches the ID supplied in the parameter list. For example: SELECT * FROM vwPorts WHERE ID=pID NOTE: In order that the results of write operations can be made available to the caller of the stored procedure, the SELECT action will always be applied as the final operation of the sync stored procedure. 5.8.2.3 INSERT Action In addition to inserting the record, the new ID sequence number is captured and returned to the caller. High Level Design 1.7 36 of 61 Container Royalty System 5.8.2.4 Example – spSyncVessels CREATE OR REPLACE PROCEDURE spSyncVessels ( pID IN Vessels.ID%TYPE, pActionFlag IN INTEGER, pCurrentUserName IN VARCHAR DEFAULT '', pIMO_VesselNo IN Vessels.IMO_VesselNo%TYPE DEFAULT NULL, pVesselName IN Vessels.VesselName%TYPE DEFAULT NULL, pAutomationLevelID IN Vessels.AutomationLevelID%TYPE DEFAULT NULL, pResultSet OUT sys_refcursor ) AS BEGIN DECLARE lID INTEGER; BEGIN SAVEPOINT BeginTransaction; IF pActionFlag = 2 OR pID IS NULL THEN lID := seqVessels.NextVal7; INSERT INTO Vessels ( ID, IMO_VesselNo, VesselName, AutomationLevelID, Created_By ) VALUES ( lID, pIMO_VesselNo, pVesselName, pAutomationLevelID, pCurrentUserName ); END IF; IF pActionFlag = 3 THEN UPDATE Vessels SET IMO_VesselNo = pIMO_VesselNo, VesselName = pVesselName, AutomationLevelID = pAutomationLevelID, Modified_By = pCurrentUserName WHERE ID = pID; END IF; IF pActionFlag = 4 THEN DELETE FROM Vessels WHERE ID=pID; END IF; OPEN pResultSet FOR SELECT * FROM vwVessels WHERE ID=NVL(lID, pID); EXCEPTION WHEN OTHERS THEN ROLLBACK TO BeginTransaction; 7 If sequence numbers are allocated by trigger, then the ID column would be omitted from the INSERT statement and pID would be set after the INSERT statement. High Level Design 1.7 37 of 61 Container Royalty System RAISE; END; END; / 5.8.2.5 List of Sync Procedures Most of the sync procedures will be relatively straightforward operations on a single table. These are: spSyncCarriers spSyncVessels spSyncPorts spSyncPiers spSyncContainers spSyncVoyages spSyncVoyageActivities spSyncWeights spSyncUnitConversionRates spSyncWeightAdjustments spSyncFunds spSyncFundRateRules spSyncMoritoriums spSyncCharges spSyncInvoices spSyncPayments spSyncChargesDueSynch spSyncFundPaymentsDue spSyncAddresses spSyncStates spSyncContacts spSyncLookups spSyncCrccfInfo spSyncAppConfig spSyncEmailTempaltes spSyncCargoFiles spSyncUserInfo spSyncImportFile High Level Design 1.7 38 of 61 Container Royalty System Some synch procedures will be slightly more complex: Stored Procedure Name Parameters (in addition to standard parameters) spSyncVoyageActivityDetails pVoyageActivityID, pWeightID, pWeight, pWeightUnitID, pContainerConfirmed, pConfirmedWeightID, pConfirmedWeight, pConfirmedWeightUnitsID, pIncludeInBilling, pActivityStatusDetailID, pAdjustmentNotes NOTES: 4. All operations should be enclosed within a transaction wrapper, since they involve (potentially) updating multiple tables. All Write Actions: 5. SELECT the current weight and unit id for this activity detail into local variables lOldWeight and lOldWeightUnitsID to NULL 6. Call spWeightsSync with pActionFlag, pWeightID, pWeight and pWeightUnitID 7. If the either pConfirmedWeightID or pConfirmedWeight are NOT NULL a. 8. spSyncChargesDue Call spWeightsSync with pActionFlag, pConfirmedWeightID, pConfirmedWeight and pConfirmedWeightUnitID Perform INSERT/UPDATE/DELETE operation on VoyageActivityDetail table. a. If lOldWeight or lOldWeightUnitID do not match pWeight and pWeightUnit (or this is a DELETE operation): b. Call spWeightAdjustments with pID, pCurrentUserName, pActionFlag, lOldWeight, lOldWeightUnitID, pWeight, pWeightUnitID and pAdjustmentNotes pFundPaymentDueID, pChargeID This behaves much like other Synch stored procedures, except that the standard parameters (pID, pActionFlag and pCurrentUserName) are ommitted. High Level Design 1.7 39 of 61 Container Royalty System 5.8.3 Entity Search For certain entities, there will be stored procedures for returning a collection of data that matches a given search criteria. These procedures will be named spSearch<entityName> (e.g. spSearchVoyageActivityDetail) The search criteria will, of course, be specific to each entity type. However, all search procedures will have a minimum of five parameters: Name Description pID Unique identifier of an entity: if provided then the record matching that ID, and only that record, is returned. pPageNo The number of the page of data to be returned (used by table/grid paging operations). pPageSize The maximum number of records to be returned (used by table/grid paging operations). pSortOrder The name of the column on which to sort the data. pSortDirection The direction of the sort (ascending or descending) If any parameter passed is null (or an empty string), then that shall indicate an inclusive search for that column i.e. A value of NULL for the pPortID implies that results for ALL ports should be included. 5.8.3.1 List of Search Procedures Stored Procedure Name Parameters (in addition to standard parameters) spSearchVoyages pVoyageNumber, pCarrierID, pIMO_VesselNo, pVesselName, pVesselID, pVoyageFromDate, pVoyageToDate, pVoyageStatusID spSearchVoyageActivities pVoyageID, pVoyageNumber, pCarrierID, pIMO_VesselNo, pVesselName, pVesselID, pVoyageDate, pPortID, pPierID, pActivityTypeID, pActivityFromDateDate, pActivityToDate spSearchVoyageActivityDetails pVoyageID, pVoyageActivityID, pVoyageNumber, pCarrierID, pIMO_VesselNo, pVesselName, pVesselID, pVoyageDate, pPortID, pPierID, pActivityTypeID, pActivityFromDateDate, pActivityToDate, pContainerID, pContainerCode spSearchFundRateRules pFundID, pVesselID, pCarrierID, pPortID , pActivityDateFrom, pActivityDateTo NOTE: uses vwFundRateRulesByDate. spSearchVoyageInvoices pVoyageID, pVoyageNumber, pCarrierID, pIMO_VesselNo, pVesselName, pVesselID, pVoyageFromDate, pVoyageToDate, pInvoiceNumber, pInvoiceFromAmount, pInvoiceToAmount spSearchCargoFiles pFileName, pVoyageNumber, pNominalVoyageDateFrom, pNominalVoyageDateTo, pCarrierCode, pDateOfUploadFrom, pDateOfUploadTo, pIMO_VesselNo, pVesselName, pPortCode, pFIRMS_Code, pActivityDateFrom, pActivityDateTo, pContainerCode, pImportResultID spSearchPaymentsDue pCarrierID, pVoyageID, pIMO_VesselNo, pVesselName, pVesselID, pVoyageDate, pPortID, pPierID, pFundID, pActivityFromDateDate, pActivityToDate, pTransactionFromDate, pTransactionToDate, pPaid High Level Design 1.7 40 of 61 Container Royalty System Stored Procedure Name Parameters (in addition to standard parameters) spSearchCharges pCarrierID, pVoyageID, pVoyageActivityID, pVoyageActivityDetailID, pIMO_VesselNo, pVesselName, pVesselID, pVoyageDate, pPortID, pPierID, pFundID, pActivityFromDateDate, pActivityToDate, pTransactionFromDate, pTransactionToDate , pAllocated 5.8.3.2 Entity Search Sample - spSearchVessels CREATE OR REPLACE PROCEDURE spSearchVessels ( pID IN INTEGER DEFAULT NULL, pPageNo IN INTEGER DEFAULT 0, pPageSize IN INTEGER DEFAULT 100000, pSortOrder IN VARCHAR DEFAULT 'ID', pSortDirection IN VARCHAR DEFAULT 'ASC', pVesselText IN VARCHAR DEFAULT NULL, pAutomationLevelID IN INTEGER DEFAULT NULL, pResultSet OUT sys_refcursor ) AS BEGIN DECLARE lPageNo NUMBER; lPageSize NUMBER; lFirstRow NUMBER; lLastRow NUMBER; BEGIN lPageNo := NVL(pPageNo,0)+1; -- .NET counts pages from Zero, not One. lPageSize := NVL(pPageSize, 10000); lFirstRow := (lPageNo-1)*lPageSize+1; lLastRow := lFirstRow+pPageSize-1; IF (pSortDirection = 'ASC') THEN OPEN pResultSet FOR SELECT * FROM ( SELECT v.*, ROW_NUMBER() OVER ( ORDER BY DECODE(pSortOrder, 'IMO_VesselNo', v.IMO_VesselNo, 'VesselName',v.VesselName, 'AutomationLevel', v.AutomationLevel, 'ID', LPAD(TO_CHAR(v.ID),38,'0') ) ASC 8 ) AS RowNo FROM vwVessels v WHERE (pID IS NULL OR v.ID=pID) AND (pVesselText IS NULL OR v.VesselName LIKE pVesselText || '%' OR v.IMO_VesselNo LIKE pVesselText || '%') AND (pAutomationLevelID IS NULL OR v.AutomationLevelID=pAutomationLevelID) ) WHERE RowNo BETWEEN lFirstRow AND lLastRow; ELSE OPEN pResultSet FOR SELECT * FROM 8 The use of DECODE() combined with duplicate query instances (one for ascending sort and one for descending sorts) is only one implementation strategy, but does alleviate the need for dynamic SQL. High Level Design 1.7 41 of 61 Container Royalty System ( SELECT v.*, ROW_NUMBER() OVER ( ORDER BY DECODE(pSortOrder, 'IMO_VesselNo', v.IMO_VesselNo, 'VesselName',v.VesselName, 'AutomationLevel', v.AutomationLevel, 'ID', LPAD(TO_CHAR(v.ID),38,'0') ) DESC ) AS RowNo FROM vwVessels v WHERE (pID IS NULL OR v.ID=pID) AND (pVesselText IS NULL OR v.VesselName LIKE pVesselText || '%' OR v.IMO_VesselNo LIKE pVesselText || '%') AND (pAutomationLevelID IS NULL OR v.AutomationLevelID=pAutomationLevelID) ) WHERE RowNo BETWEEN lFirstRow AND lLastRow; END IF; END; END; / 5.8.4 Entity Count For each entity search procedure, there will be a matching procedure to count the number of records that would be returned by the search operation. These procedures will be named spCount<entityName> (e.g. spCountVoyageActivityDetail) and have the same parameter set as the matching search function. The procedures need to return the number of records matching the search criteria. 5.8.4.1 Entity Count Sample – spCountVessels CREATE OR REPLACE PROCEDURE spCountVessels ( pID IN INTEGER DEFAULT NULL, pVesselText IN VARCHAR DEFAULT NULL, pAutomationLevelID IN INTEGER DEFAULT NULL, pResult OUT INTEGER ) AS BEGIN SELECT COUNT(*) INTO pResult FROM vwVessels v WHERE (pID IS NULL OR v.ID=pID) AND (pVesselText IS NULL OR v.VesselName LIKE pVesselText || '%' OR v.IMO_VesselNo LIKE pVesselText || '%') AND (pAutomationLevelID IS NULL OR v.AutomationLevelID=pAutomationLevelID); END; / High Level Design 1.7 42 of 61 Container Royalty System 5.8.5 Other Stored Procedures Stored Procedure Name Parameters (in addition to standard parameters) spImportNewVoyage Imports all records from the CargoFiles table with a status of Imported into the Voyages, VoyageActivities, VoyageActivityDetails, Containers and Weights tables, as required. spWeightAdjustments pID, pCurrentUserName, pOriginalActionFlag, pOldWeight, pOldWeightUnitID, pWeight, pWeightUnitID, pNotes Updates the WeightAdjustments and Weights tables, adding a new weight adjustment. NOTES: 1. All operations should be enclosed within a transaction wrapper, since they involve updating multiple tables. 2. Determine the corrective action ID: 3. If the original action flag was for an INSERT operation: 4. 5. spGetUserInfoByUserID a. Call spSyncWeights for pNewWeight & pNewWeightUnitID with an action code of 2 (INSERT) b. INSERT a record into WeightAdjustments table with pOldWeightID=NULL, pNewWeightID from above and the corrective action code of 155 (Added) If the original action flag was for an UPDATE operation: a. Call spSyncWeights for pOldWeight & pOldWeightUnitID with an action code of 2 (INSERT) b. Call spSyncWeights for pNewWeight & pNewWeightUnitID with an action code of 2 (INSERT) c. INSERT a record into WeightAdjustments table with pOldWeightID and pNewWeightID from above and the corrective action code of 156 (Changed Weight) If the original action flag was for an DELETE operation – 155 (Removed) a. Call spSyncWeights for pNewWeight & pNewWeightUnitID with an action code of 2 (INSERT) b. INSERT a record into WeightAdjustments table with pOldWeightID from above, pNewWeightID =NULL and the corrective action code of 157 (Removed) pUserID Fetches information about the current user (including, for example, which port or carrier they represent) from selecting from vwUserInfo where the ASP.NET user ID matches the one supplied. High Level Design 1.7 43 of 61 Container Royalty System 5.9 Lookups Entities with no particular significance to the data model as a whole, but which will populate dropdown lists and other choices within the system, shall be stored in a single table called Lookups. Lookups shall be grouped by LookupType into meaningful collections of text entries (LookupName) with an associated (unique) identifier. For example: a set of status codes for a carrier might be: Active, Inactive and Test. These could be stored in the Lookups table as follows: ID LookupType LookupName LookUpValue SortOrder 1001 CarrierStatus Active 1 1002 CarrierStatus Inactive 2 1003 CarrierStatus Test 3 5.9.1 Sort Order of Lookups The SortOrder column shall allow the list entries to be sorted by criteria other than the alphanumeric sequence of the lookup names. For example: ID LookupType LookupName LookUpValue SortOrder 2001 ActivityStatus Scheduled 1 2002 ActivityStatus In Process 2 2003 ActivityStatus Complete 3 2004 ActivityStatus Invoiced 4 Now the activity status can be displayed in the order representing the logic sequence of status changes. 5.9.2 Lookup Values The LookupValue column shall allow a specific value to be associated with the given lookup. The meaning of that value is context specific. For example: ID LookupType LookupName LookUpValue SortOrder 3001 Country USA 1 1 3002 Country Canada 1 2 3003 Country United Kingdom 0 3 Here the LookupValue of a country can tell us whether or not to show a drop down list for state or province, or whether to allow free format entry. High Level Design 1.7 44 of 61 Container Royalty System 5.9.1 Lookup Items The following table summarizes the specific lookup values that will be created for the CRCCF project: ID LookupType LookupName LookUpValue SortOrder 1 Country USA 1 1 2 Country Canada 1 2 100 TransferStatus Not Transferred 1 101 TransferStatus Failed 3 102 TransferStatus Transfer Complete 2 110 CarrierStatus Active 1 111 CarrierStatus Inactive 2 112 CarrierStatus Test 3 120 ActivityDetailStatus Scheduled 1 121 ActivityDetailStatus In Process 2 122 ActivityDetailStatus Complete 3 123 ActivityDetailStatus Billing Error 4 124 ActivityDetailStatus Invoiced 5 125 ActivityDetailStatus Deleted 6 130 VoyageStatus New 1 131 VoyageStatus Underway 2 132 VoyageStatus Completed 3 133 VoyageStatus Invoiced with Errors 4 134 VoyageStatus Invoiced 5 135 VoyageStatus Paid 6 140 CarrierStatus Active 1 142 CarrierStatus Inactive 2 145 PaymentType Fund Payment 1 146 PaymentType Invoice 2 150 ActivityType Loading 1 151 ActivityType Unloading 2 155 CorrectiveAction Added 1 156 CorrectiveAction Changed Weight 2 157 CorrectiveAction Removed 3 170 VesselAutomationLevel Fully Automated 1 171 VesselAutomationLevel Partially Automated 2 High Level Design 1.7 45 of 61 Container Royalty System ID LookupType LookupName 172 VesselAutomationLevel Not Automated 3 180 FundType Port Specific 1 181 FundType ILA 2 182 FundType USMX 3 190 USMX Membership USMX Member 1 191 USMX Membership USMX Subscriber 2 192 USMX Membership Non Member 3 200 UserType I am an ILA Member at a Port/Station 1 201 UserType I work for (or represent) a Carrier 2 202 UserType I work for the Container Royalty Central Collection Fund (CRCCF) 3 6 6.1 LookUpValue SortOrder Object Model NOTES Classes in purple represent existing library classes and/or classes that can be readily adapted from existing library classes. Since most objects will inherit from the Avatar_Object or Avatar_Collection classes, for the sake of clarity those inheritance lines are omitted on most pages. Instead, the inheritance is indicated next to the class name: o : AO inherits from Avatar_Object o : AC inherits from Avatar_Collection Data layer classes are not explicitly shown here. In general, for each application logic layer class, there will be an equivalent data layer class. High Level Design 1.7 46 of 61 Container Royalty System 6.2 Object Model Diagrams Avatar_Object ID ActionFlag CreatedBy CreatedDate ModifiedBy ModifiedDate UtilityDataInstance CurrentAspNetUserName Avatar_Object() DefaultValues() GetFromNameAndEmail() NewInstance() GetList() Count() Save() Delete() Write() CloseConnectionAndCommit() SaveSubObject() DeleteSubObject() DeleteAll() SetActionFlag() SetActionFlagOnSubObjects() Serialize() LookupIsValid() MultiChoiceIsValid() GetAspNetUserID() Avatar_Collection Lookup UtilityInstance Collection SearchStoredProcedure CountStoredProcedure Avatar_Collection(SearchFilter) Count() LookupID LookupType LookupName LookupValue Get() GetLookups() BindDropDownList() GetAll() BindRadioButtonList() FindCurrentListItem() GetIDByName() GetNameByID() Set() SetList() GetFromList() Equals() BaseAddress Address1 Address2 City StateOrProvince StateCountyOrProvince Country CityStatePostCode USPS_API ValidationErrorCode ValidationErrorText Copy() Verify() GetCityAndState() Country IsUSA County() DataLayer.Avatar_Objects OracleUtilities DbUtilsSessionName UtilException ConnectionString OracleUtilities() StoredProcedure() SelectStoredProcedure() NewParameter() CloseConnection() High Level Design DBUtilitiesInstance SynchStoredProcedure Get() Count() Search() DB2Object() GetSubObjects() PopulateWriteParameters() Write() WriteObjectWhichTheParentReferences() WriteObjectsThatReferenceTheParent() StateProvinceTerritory StateOrProvince StateOrProvinceName Country 47 of 61 Container Royalty System SearchFilter High Level Design VoyageID InvoiceNumber InvoiceFromAmount InvoiceToAmount InvoiceDateFrom InvoiceDateTo VoyageActivityFilter VoyageID Pier ActivityTypeID ContainerActivityCode PierFilter VoyageActivityDetailFilter VoyageActivityID Container WeightFrom WeightTo IncludedInBilling ContainerFilter ContainerFilter FileName NominalVoyageDateFrom NominalVoyageDateTo UploadDateFrom UploadDateTo CarrierCode IMO_VesselNumber VesselName PortCode FIRMS_Code ActivityDateFrom ActivityDateTo ImportResultID Container ContainerActivityCode InvoiceFilter CarrierFilter VoyageNumber Carrier Vessel DateFrom DateTo StatusID FundID AutomationLevelID PortID CarrierID FromDate ToDate CargoFilesFilter VoyageFilter VesselFilter FundRateRuleFilter ID PageNo PageSize SortOrder SortDirection PopulateFilterParameters() VoyageActivityDetailSubFilter 48 of 61 Container Royalty System VoyageActivityDetailFilter VoyageActivityDetailSubFilter VoyageActivityDetailID WeightAdjustmentsFilter NewWeightFrom NewWeightTo OldWeightFrom OldWeightTo AdjustedBy AdjustedOnFromDate AdjustedOnToDate Notes VoyageActivityDetailFilter PaymentsDueFilter TransactionDateFrom TransactionDateTo Paid VoyageFilter ChargesFilter ContainerFilter : SearchFilter ContainerType ContainerPrefix ContainerNumber VesselFilter Allocated Name IMO_Number AutomationLevelID UserInfoFilter PCF_Filter Code Name UserID UserName VoyageActivityFilter PierFilter Port FIRMS_Code PortFilter CarrierFilter VoyageFilter StatusID USMX_MemberID High Level Design 49 of 61 Container Royalty System VoyageCollection : AC PCF Code Name AccountingName Voyage : AO Lookup VoyageDate Vessel Carrier VoyageNumber Status Activities GenerateCharges() CreateInvoice() VoyageActivityCollection : AC Vessel : AO IMO_VesselNo VesselName AccountingName Carrier : AO BaseAddress BillingAddress Status USMX_Member VoyageActivity : AO Lookup Pier : AO Port FIRMS_Code Description ActivityType ActivityDate Pier Details ContainerCount Tonnage ConfirmedActivityDate ConfirmedContainerCount ConfirmedTonnage ConfirmedBy Lookup VoyageActivityDetailCollection : AC VoyageActivityDetail : AO Container : AO Port High Level Design ContainerType ContainerIDPrefix ContainerNumber Weight ConfirmedWeight ConfirmedBy Container ConfirmedDate ActivityDetailStatus Weight : AO Lookup Weight Units StandardWeight 50 of 61 Container Royalty System FinancialDocumentCollection : AC FundRateRuleCollection : AC GetPaymentsFromQuickBooks() GetApplicableRate() FundRateRule : AO ChargesCollection : AC FundID PortID CarrierID AutomationLevelID RateID Rate ApplicableFrom ApplicableTo Charge : AO VoyageActivityDetailID FundRateID Fund Amount PCF FinancialDocument : AO Lookup TransactionDate DueDate Charges TransferStatus AccountingRequestID AccountingTransactionID Payments GetCharges() SendToQuickBoks() GetPayments() Fund : AO Lookup InvoiceCollection FundType Moritoriums GetMoritoriums() Invoice : AO PaymentCollection : AC VoyageID InvoiceNumber Invoice(Voyage) FundPaymentDueCollection MoritoriumCollection : AC FundPaymentDue Port Fund FundPaymentDue(Date, FundID, PortID) Moritorium : AO FundID CarrierID StartDate EndDate OverallCredit CreditAvailable High Level Design Payment: AO Lookup PaymentType ReferenceID BankReference AmountPaid 51 of 61 Container Royalty System ASP.NET User Management Classes MembershipUser UserName Email IsApproved IsLockedOut ChangePassword() GetPassword() ResetPassword() UnlockUser() Membership GetUser() Roles ProfileBase GetRolesForUser() GetAllRoles() AddUserToRole() UserInfo : AO UserId CarrierID PortID UserContact HiringManagerContact Approved ApprovedBy ApprovalNotes GetPrimaryRole() GetHomePage() RedirectToHome() IsPortUser() IsCarrierUser() IsCRCCFUser() IsAdmin() CrccfProfile Contact : AO FirstName LastName JobTitle DateOfBirth PhoneNumber Extension PhoneNumberAndExtension MobilePhone UnitConversionRate : AO Unit Description Rate High Level Design Create() Allows the user to save preferences for their default page and/or to save their preferred search conditions DefaultPageName LastVoyageNumber LastVoyageID LastIMO_VesselNo LastVesselName LastVesselID LastCarrierID LastVoyageFromDate LastVoyageToDate LastVoyageActivityID LastPortID LastPierID LastVoyageActivityDetailID LastVoyageActivityDateFrom LastVoyageActivityDateTo LastContainerID LastcontainerCode LastWeightFrom LastWeightTo LastIncludedInBilling LastNewWeightFrom LastAdjustedBy LastAdjustmentDate LastComment 52 of 61 Container Royalty System 6.3 Class Details 6.3.1 FundRateRuleCollection 6.3.1.1 FundRateRuleCollection Overloaded Constructor(s) Name Description FundRateRuleCollection(SearchFilter filter) Initializes a new fund rate rule collection from all enties matching the search criteria specified in the filter. 6.3.1.2 FundRateRuleCollection GetApplicableRate() Name Description GetApplicableRate(int FundID, int portIDint carrierID, int destinationPortID, DateTime activityDate) Selects the applicable fund rate rule from within the Collection list. Pseudo-code: Search FundRateRules for a rate matching FundID, VesselID, PortID and CarrierID for the activity date: If no rate found: Search FundRateRules for a rate matching FundID, VesselID and PortID for the activity date: If no rate found: Search FundRateRules for a rate matching FundID, VesselID for the activity date: If no rate found: Raise an exception. 6.3.1 Invoice 6.3.1.1 Invoice Overloaded Constructor(s) Name Description Invoice(Voyage voyage) Initializes a new invoice with details from the voyage object provided. 6.3.1.2 Invoice – SendToQuickBooks() SendToQuickBooks() Transfers the details of this Invoice object to a QuickBooks Invoice. High Level Design Container Royalty System 6.3.1 InvoiceCollection 6.3.1.1 InvoiceCollection – Overloaded Constructor(s) Name Description InvoiceCollection(SearchFilter filter) Initializes an invoicecollection from all enties matching the search criteria specified in the filter. For example, could be used to find all invoices that are unpaid. 6.3.1.2 InvoiceCollection – GetPaymentsFromQuickBooks() GetPaymentsFromQuickBooks() Searches QuickBooks for any payments for the invoices in the collection. 6.3.2 Voyage 6.3.2.1 Voyage CreateInvoice() CreateInvoice () Creates a formal invoice record linked to the set of charges for all of the activites in the voyage. Create a new Invoice object using the Voyage overloaded constructor. Call the GenerateCharges() method to ensure that all charges are up to date, storing the return value in invoice.Charges(). If no errors occurred during GenerateCharges(): o If errors DID occur during GenerateCharges(): o Set the voyage Status to Billed Set the voyage Status to I oi ed ith Errors Save the voyage and invoice High Level Design Container Royalty System 6.3.2.2 Voyage GenerateCharges() GenerateCharges (bool out errors) Generates and saves a set of charges for all of the activites in the voyage. Set errors to false. Create a new FundRateRulesCollection and populate it with all rules for the oyage s arrier usi g the SearchFilter overloaded constructor with CarrierID set accordingly. Create a new ChargesCollection and populate it with any existing charges for this voyage, using the SearchFilter overloaded constructor with Vessel set accordingly. Set the ActionFlag for all Charges in the ChargesCollection to Delete (so charges not updated are removed). For each Activity in the Voyage: o For each ActivityDetail in the Activity: For each fund: Find the Charge in the collection that matches the current charge, creating a new charge if a match is not found. Find the FundRateRule for the fund, port, carrier and activity date: If a FundRateRule is found: o Calculate the charge based upon the rule Update the Charge object and set its ActionFlag to Insert/Update (depending upon whether the Charge already has a valid ID) Add the charge to the ChargesCollection If a FundRateRule is NOT found: o Set the a ti ity detail status to Billi g Error a d the status ote to Could ot fi d fu d rate rule for – adding text to describe the activity, vessel, port and carrier. o Save() the ActivityDetail. o Set errors to true. For each Charge in the ChargesCollection: o If the rate is not equal to zero: Write() the activity (applies the ActionFlag – Insert/Update/Delete) Return the ChargesCollection. High Level Design Container Royalty System 6.3.3 FundPaymentDue 6.3.3.1 FundPaymentDue – Overloaded Constructors(s) FundPaymentDue (DateTIme transactionDate, int fundID, Nullable<int> portID) Generates a collection of existing charges for all voyages that have been invoiced but have not yet been added to a FundPaymentDue. Set the TransactionDate, FundID and PortID properties from the parameters provided. Create a new ChargesCollection and populate it with any existing charges for this voyage, using the SearchFilter overloaded constructor with Allocated set to false. 6.3.3.2 FundPaymentDue – SaveAll() SaveAll () Saves the FundPaymentsDue object and all the entries in the associated ChargesCollection(). Wraps the operation in a transaction to ensure that all/none of the udpates are completed. 6.3.3.3 FundPaymentDue – SendToQuickBooks() SendToQuickBooks() Transfers the details of this FundPaymentDue object to a QuickBooks Bill. 6.3.1 FundPaymentsDueCollection 6.3.1.1 FundPaymentsDueCollection – Overloaded Constructor(s) Name Description FundPaymentsDueCollection(SearchFilter filter) Initializes a fund payments due collection from all enties matching the search criteria specified in the filter. For example, could be used to find all FundPaymentDue entities that are unpaid. 6.3.1.2 FundPaymentsDueCollection – GetPaymentsFromQuickBooks() GetPaymentsFromQuickBooks() Searches QuickBooks for any payments for the FundPaymentDue objects in the collection. High Level Design Container Royalty System 7 Integration with QuickBooks Enterprise 7.1 IBiz Integrator for QuickBooks Integration with QuickBooks will be achieved using the .Net edition of the IBiz Integrator for QuickBooks, published rd by /n software. This 3 party class library provides C# classes that can communicate with a QuickBooks database instance; retrieving and storing information as required. 7.1.1 Classes Four important classes from the IBiz Integrator for QuickBooks will be used to implement the solution: nsoftware.IBizQB.Bill nsoftware.IBizQB.Invoice - Enables retrieval and storage of QuickBooks customer invoices nsoftware.IBizQB.Objsearch - Enables searching for various QuickBooks objects nsoftware.IBizQB.Vendor - Enables retrieval and storage of QuickBooks vendor records nsoftware.IBizQB.Customer - Enables retrieval and storage of QuickBooks customer records - Enables retrieval and storage of QuickBooks vendor bills 7.1.2 QB Web Service In order for the Enterprise Service Bus to easily communicate with QuickBooks a web service wrapper will be provided that will encapsulate high level operations involving one, or more, QuickBooks objects. Operations provide by this web service shall include: Add Invoice Add Bill Fetch Invoice Payments Fetch Bill Payments High Level Design Container Royalty System 7.2 Populating QuickBooks Bills Property Description Source APAccountName Reference to the Accounts Payable account. Co sta t alue: Accounts Payable APAccountId Reference to the Accounts Payable account where money goes. Defaults from the account name. Amount Amount of transaction. Calculated by QuickBooks DueDate Date when payment is due. TBD ExpenseAccountName Expense line property: the account for this expense. TBD ExpenseAmount Expense line property: amount of the expense. TBD ExpenseCustomerName Expense line property: The customer for whom the expense was undertaken. CarrierAccountingName ExpenseMemo Expense line property: Memo for this line. <blank> Memo Memo to appear on internal reports only. VoyageInvoiceNumber + Probably: Charge / + VoyageCode NOTE: Can be used to find bills associated with a given invoice/voyage. QBConnectionString An aggregate consisting of various QuickBooks connection properties. This includes the QuickBooks file name, as well as a unique application name that must be authorized to connect to QuickBooks. High Level Design Filename = TBD ApplicationName = CRCCFMGT Container Royalty System Property Description Source QBRequestId The Id of the next message to be sent to QuickBooks. Important for transaction handling. The QB Web Service will assign unique essage ID s to ea h Bill that is added. This ensures that QuickBooks can roll-back any related transaction in the event of a communications (or other) failure. This will be saved in the AccountingRequestID column of the FundPaymentsDueTable. RefId An alphanumerical identifier generated by QuickBooks. This will be saved in the AccountingRequestID column of the FundPaymentsDueTable RefNumber Reference number for the transaction. VoyageCode + PortCode + TBD TermsId Reference to terms of payment. Default TermsName Reference to terms of payment. Default TransactionDate Date of transaction. Date that the bill is created VendorName Reference to the vendor for this transaction. PortAccountingName VendorId Reference to the vendor for this transaction. Default from the Vendor Record High Level Design Container Royalty System 7.3 Populating QuickBooks Invoices Property Description Source ARAccountName Reference to the Accounts Receivable account where money goes. Co sta t alue: Accounts Receivable ARAccountId Reference to the Accounts Receivable account where money goes. Defaults from the account name. CustomerName A reference to the customer or customer job. CarrierAccountingName DueDate Date when payment is due. TBD ItemAmount Line item property: the total amount of this line. Calculated by QuickBooks ItemDescription Line item property: Description of item. Default ItemName Line item property: Reference to the kind of item. TBD ItemQuantity Line item property: Quantity of item or item group. TBD BillAddress The billing address for this invoice. From customer object. ItemRate Unit rate of item. TBD Probably 1 Probably TotalWeight Memo Memo to appear on internal reports only. WorkOrderID + LocationAbbreviatedName + LocationNumber + (Date-Time Of Bill Creation) PONumber P.O. number. TBD QBConnectionString An aggregate consisting of various QuickBooks connection properties. Refer to section 7.2—Populating QuickBooks Bills High Level Design Container Royalty System Property Description Source QBRequestId The Id of the next message to be sent to QuickBooks. Important for transaction handling. The QB Web Service will assign unique essage ID s to ea h Bill that is added. This ensures that QuickBooks can roll-back any related transaction in the event of a communications (or other) failure. This will be saved in the AccountingRequestID column of the Invoices table. RefId An alphanumerical identifier generated by the server. This will be saved in the AccountingRequestID column of the Invoices table RefNumber Reference number for the transaction. InvoiceNumber SalesTaxTotal Total amount of sales tax. TBD TransactionDate Date of transaction. Date that the invoice is created ShippingAddress Shipping Address <blank> 8 Topics Not Yet Explored INDEXES High Level Design
© Copyright 2026 Paperzz